3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP // ini_set('max_execution_time', 6000); // flush(); // ob_flush(); // ------------------------- DB SETUP ------------------ $dbhost = 'faradaypromo.com:3306'; $dbuser = 'priceles_kst'; $dbpass = 'kst33'; $dbname = 'priceles_kst'; $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname); if ($conn->connect_error) { trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); } // ------------------------- READ LIST ------------------- $wlist = "http://faradaypromo.com/aggr_dom2.txt"; $handle = fopen($wlist, "r"); if ($handle) { while (($line = fgets($handle)) !== false) { pinger($line); } } else { // error opening the file. echo "file io error"; } fclose($handle); // ----------------------------FUNCTIONS ------------------- function pinger($ws){ $ch = curl_init(); $options = array( CURLOPT_URL => $ws, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT_MS => 500, CURLOPT_MAXREDIRS => 10, CURLOPT_NOSIGNAL => 1 ); curl_setopt_array( $ch, $options ); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); echo date('H:i:s')." - ".$ws." ".$httpCode."/n"; if ( $httpCode == 200 ){ write_sql($ws, $httpCode); } curl_close($ch); } function write_sql($ws, $code){ $sql = "INSERT INTO websites (cat,uri,status, time) VALUES ('$wlist','$ws',$code,NOW())"; if($conn->query($sql) === false) { trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); } else { $last_inserted_id = $conn->insert_id; $affected_rows = $conn->affected_rows; echo " - ok: id ".$last_inserted_id; } } mysql_close($conn);

preferences:
47.19 ms | 402 KiB | 5 Q