3v4l.org

run code in 300+ PHP versions simultaneously
<? // Phil Blackman <phil.blackman@tmnplc.com> 2009 // feed.php // arse over tit script for dealing with PureLead data $start_time = date("c"); set_time_limit(180000); //include("/home/phil/uploads/database.php"); // Connect to the Database //$con_ptr = mysql_connect('db-02-03.tmnplc.com:3306','campaigns_web','pH4q.fQB23!'); //$con_ptr = connect_sym_live(); //$con_ptr = connect_sbm(); // Connect to the Database $con_ptr = mysql_connect("db-08-02.tmnplc.com", "keila_web","Zircon500"); //$con_ptr = mysql_connect("db-08-01.tmnplc.com", "mailman","6Zyj8xj7"); // database //$db = "mailman"; // testing $db = "surveycentral"; // live // telephone validation stuff $phone_db = "surveycentral"; // Report simple running errors error_reporting(E_ERROR | E_WARNING | E_PARSE); $user_tbl = $db.".Users"; $mobile_tbl = $db.".MobileData"; $landline_tbl = $db.".LandLineData"; // data8 login details $d8username = "tmngroup_data8"; $d8password = "AxUcmOkj12"; if($_POST) { foreach($_POST as $key => $value) { // for form debugging //echo $key." --- ".$value."<br>"; $$key = $value; } } if($_GET) { foreach($_GET as $key => $value) { // for form debugging //echo $key." --- ".$value."<br>"; $$key = $value; } } error_reporting(E_ALL); $logdir = "/var/www/purelead/log_files/external_feed_log/"; $time = date("c"); function blacklist($ip, $time = '') { global $con_ptr, $ip_blacklist_table; if(!empty($time)) { $update = "UPDATE ".$ip_blacklist_table." SET active = 0 WHERE ip = '".$ip."' AND ts < '".$time."'"; //echo $update; die; if(mysql_query($update)){ return true; } } // check to see if the IP exists $sql = "SELECT * FROM ".$ip_blacklist_table." WHERE ip = '".$ip."'"; $res = mysql_query($sql, $con_ptr); $num_rows = mysql_num_rows($res); if($num_rows == 1){ $update = "UPDATE ".$ip_blacklist_table." SET active = 1, ts = '".date("c")."' WHERE ip = '".$ip."'"; mysql_query($update); return true; } else { $insert = "INSERT INTO ".$ip_blacklist_table." (ip) VALUES ('".$ip."')"; mysql_query($insert); return true; } } function checkIP($ip) { global $con_ptr, $UsersTbl, $ip_blacklist_table; // first remove the entries from the blacklist $fiveminsago = date("c", mktime(date("H"), date("i")-5, date("s"), date("m") , date("d"), date("Y"))); blacklist($ip, $fiveminsago); // then check to see if we've had a reg from the same IP $sql = "SELECT * FROM ".$UsersTbl." WHERE ip = '".$ip."' ORDER BY time DESC"; //echo $sql; die; $res = mysql_query($sql, $con_ptr); $num_rows = mysql_num_rows($res); if($num_rows > 1) { $row = mysql_fetch_array($res); $reg_timestamp = strtotime($row['time']); $timestamp_now = time(); $difference = $timestamp_now - $reg_timestamp; if($difference < 60) { blacklist($ip); return false; } else { // now check they aren't in the blacklist table $sql = "SELECT * FROM ".$ip_blacklist_table." WHERE ip = '".$ip."' AND active = 1"; $res = mysql_query($sql, $con_ptr); $num_rows = mysql_num_rows($res); if($num_rows == 1){ blacklist($ip); return false; } else { return true; } } } else { return true; } } // data8 bits function LineIsValid($telephone, $d8username, $d8password) { global $landline_tbl, $phone_ptr; // first we check to see if we've already searched for this number in the 3 months so we don't cane our credits $three_months_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i"), date("s"), date("m")-3, date("d"), date("Y"))); $sql = "SELECT * FROM ".$landline_tbl." WHERE Number = '".$telephone."' AND dos > '".$three_months_ago."'"; //echo "sasf".$d8username.$d8password; $res = mysql_query($sql, $phone_ptr); $numrows = mysql_num_rows($res); if($numrows > 0) { $row = mysql_fetch_array($res); if($row['Result'] != 'Invalid') { return true; } else { return false; } } $params = array( "username" => $d8username, "password" => $d8password, "number" => $telephone ); //$client = new SoapClient("http://webservices.data-8.co.uk/TelephoneValidation.asmx?WSDL"); $client = new SoapClient("http://webservices.data-8.co.uk/TelephoneLineValidation.asmx?WSDL"); $result = $client->IsValidAdvanced($params); //echo $number."\n"; //var_dump($result); //echo "\n"; $data = iterateObject($result); $sql = "INSERT INTO ".$landline_tbl." VALUES ('', '".$telephone."', '".$data['Success']."', '".$data['CreditsRemaining']."', '".$data['Result']."', NOW())"; //echo $sql; mysql_query($sql, $phone_ptr); logResults($result, date("c"), "LandLineCheck.log", $telephone); if ($result->IsValidAdvancedResult->Result != "Valid") { return false; } else { return true; } } function MobileIsValid($telephone, $d8username, $d8password) { global $mobile_tbl, $phone_ptr; // first we check to see if we've already searched for this number in the 3 months so we don't cane our credits $three_months_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i"), date("s"), date("m")-3, date("d"), date("Y"))); $sql = "SELECT * FROM ".$mobile_tbl." WHERE Number = '".$telephone."' AND dos > '".$three_months_ago."'"; //echo $sql; $res = mysql_query($sql, $phone_ptr); $numrows = mysql_num_rows($res); if($numrows > 0) { $row = mysql_fetch_array($res); if($row['Result'] != 'Invalid') { return true; } else { return false; } } $params = array( "username" => $d8username, "password" => $d8password, "number" => $telephone ); $client = new SoapClient("http://webservices.data-8.co.uk/MobileValidation.asmx?WSDL"); if($numrows == 0) { $result = $client->IsValid($params); } logResults($result, date("c"), "MobileCheck.log", $telephone); // insert into the mobile table $data = iterateObject($result); $sql = "INSERT INTO ".$mobile_tbl." VALUES ('', '".$telephone."', '".$data['Success']."', '".$data['CreditsRemaining']."', '".$data['Result']."', '".$data['CountryISO']."', '".$data['Organisation']."', '".$data['NetworkName']."', '".$data['NetworkType']."', '".$data['Ported']."', '".$data['PortedFromOrganisation']."', '".$data['PortedFromNetwork']."', '".$data['LocationISO']."', NOW())"; //echo $sql; mysql_query($sql, $phone_ptr); //print_r($result); if ($result->IsValidResult->Result != "Success") { return false; } else { return true; } } // function for checking if the number is on TPS function IsCallable($telephone, $d8username, $d8password) { $params = array( "username" => $d8username, "password" => $d8password, "number" => $telephone ); $client = new SoapClient("http://webservices.data-8.co.uk/TPS.asmx?WSDL"); $result = $client->IsCallable($params); //var_dump($result); if ($result->IsCallableResult->Status->Success == 0) { //echo "Error: " . $result->IsCallableResult->Status->ErrorMessage; // didn't get a response so we'll assume it's callable - we'll validate it anyway return true; } else { // Results can be extracted from the following fields: if($result->IsCallableResult->Callable == false) { return false; } else { // then it's callable return true; } } } // function for validating the phone number with our 3rd party supplier function validateTelephoneNumber($telephone) { global $d8username, $d8password; // first do the freebie check if(telephoneNumber($telephone) == false) { return false; } else { // now do the data8 check $match = "/^07[0-9]{9,10}/"; if(preg_match($match, $telephone)) { // then it's a mobile if(MobileIsValid($telephone, $d8username, $d8password) != true) { return false; } } else { // then it's a landline if(LineIsValid($telephone, $d8username, $d8password) != true) { return false; } } // if we get to here than we can assume it's valid return true; } } // todays date $today = date("Ymd"); // Call the getAge function if (isset($_POST['birth_date'])) { $age = getAge($birth_date); } //Or fail else echo'false - no dob provided'; { } function getAge($birth_date){ list($year, $month, $day) = explode("-", $birth_date); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($day_diff < 0) { $month_diff--; } if ($month_diff < 0) { $year_diff--; } return $year_diff; } // logs the reuslts function logResults($values, $logfile){ global $logdir, $time; // count the values $num_vals = count($values); // open the log file $resfile = fopen($logdir.$logfile, "a"); //write data to the log file foreach($values as $key => $value){ $value = str_replace("'", "", $value); $value = trim($value, "\n\r"); $value = ereg_replace("\r", " ", $value); $value = ereg_replace("\n", " ", $value); fwrite($resfile, $key." --> ".$value); fwrite($resfile, ","); } fwrite($resfile, $time); fwrite($resfile, "\n"); // close the log file fclose($resfile); } LineIsValid(($_POST['telephone']), $d8username, $d8password); MobileIsValid(($_POST['telephone']), $d8username, $d8password); IsCallable(($_POST['telephone']), $d8username, $d8password); validateTelephoneNumber(($_POST['telephone'])); $curl = curl_init(); if ( !$curl ) { print "Failed to initalise cURL object\n"; } else { $url = "https://v3.lolagrove.com/data.ashx?id=7941.1674&paid_creditors_six_months=Yes&email=".urlencode($email)."&firstname=".urlencode($firstname)."&lastname=".($lastname)."&address1=".urlencode($address1)."&towncity=".urlencode($towncity)."&postcode=".urlencode($postcode)."&telephone=".urlencode($telephone)."&age=".urlencode($age)."&debt_amount=".urlencode($debt_amount)."&debt_with=".urlencode($debt_with)."&disposable_income=".urlencode($disposable_income)."&iva_bankruptcy=".urlencode($iva_bankruptcy)."&securekey=6e5af886-22e5-4f04-b97b-946539aa70f1"; $curl_opts = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_FAILONERROR => true, ); if ( !curl_setopt_array( $curl, $curl_opts ) ) { print "Unable to set properties on CURL object\n"; } else { $response = curl_exec( $curl ); $responseCode = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); if ( is_bool( $response ) && $response == false ) { // Failed to make HTTP request to tracking URL echo 'Error from CURL in livefeed: "', curl_error( $curl ), '" ', var_export( curl_getinfo( $curl ), TRUE ); } else if ( ! ( $responseCode >= 200 && $responseCode <= 299 ) ) { // We got an HTTP response, but it was not successful print "Error: Tracking URL returned HTTP $responseCode\n"; } else { // All good print "Success, response was:\n"; echo var_export( $response ), "\n"; } } } curl_close( $curl ); // log the values $values[] = $response; $values[] = $responseCode; $values[] = $url; logResults($values, 'Madison_financial');

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0120.00318.43
8.3.50.0100.00316.24
8.3.40.0220.00018.90
8.3.30.0120.00319.10
8.3.20.0000.00820.34
8.3.10.0070.00022.08
8.3.00.0040.00422.37
8.2.180.0060.00916.32
8.2.170.0120.00322.96
8.2.160.0000.01322.26
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0050.00319.66
8.2.110.0090.00019.30
8.2.100.0040.00817.59
8.2.90.0060.00319.04
8.2.80.0000.00817.97
8.2.70.0100.00317.25
8.2.60.0000.00817.80
8.2.50.0000.00718.07
8.2.40.0040.00417.91
8.2.30.0030.00517.94
8.2.20.0030.00617.66
8.2.10.0070.00017.45
8.2.00.0050.00317.46
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0060.00322.14
8.1.230.0040.00820.71
8.1.220.0000.00817.74
8.1.210.0090.00018.77
8.1.200.0000.00917.22
8.1.190.0040.00417.41
8.1.180.0040.00418.48
8.1.170.0000.00818.49
8.1.160.0080.00022.14
8.1.150.0000.00718.43
8.1.140.0020.00517.29
8.1.130.0030.00317.71
8.1.120.0000.00717.43
8.1.110.0000.01017.37
8.1.100.0030.00417.35
8.1.90.0070.00017.28
8.1.80.0000.00817.32
8.1.70.0030.00317.24
8.1.60.0030.00517.47
8.1.50.0030.00517.32
8.1.40.0070.00017.27
8.1.30.0000.00817.43
8.1.20.0050.00217.39
8.1.10.0050.00317.33
8.1.00.0000.00717.28
8.0.300.0030.00618.77
8.0.290.0000.00716.63
8.0.280.0040.00418.39
8.0.270.0000.00817.22
8.0.260.0000.00616.65
8.0.250.0030.00316.86
8.0.240.0040.00416.83
8.0.230.0000.00716.88
8.0.220.0030.00316.68
8.0.210.0000.00716.66
8.0.200.0030.00316.86
8.0.190.0040.00416.75
8.0.180.0080.00316.84
8.0.170.0050.00316.63
8.0.160.0030.00316.76
8.0.150.0000.00716.69
8.0.140.0020.00516.71
8.0.130.0000.00713.59
8.0.120.0000.00816.70
8.0.110.0050.00216.66
8.0.100.0080.00016.62
8.0.90.0020.00516.79
8.0.80.0130.00316.81
8.0.70.0030.00316.74
8.0.60.0000.00716.67
8.0.50.0000.00816.58
8.0.30.0110.00816.80
8.0.20.0100.01417.40
8.0.10.0000.00716.93
8.0.00.0120.00616.55
7.4.330.0020.00215.00
7.4.320.0060.00016.42
7.4.300.0000.00716.38
7.4.290.0030.00316.48
7.4.280.0040.00416.47
7.4.270.0070.00016.32
7.4.260.0000.00716.38
7.4.250.0070.00016.46
7.4.240.0060.00216.46
7.4.230.0030.00316.54
7.4.220.0120.01316.43
7.4.210.0050.01016.48
7.4.200.0000.00716.30
7.4.190.0000.00716.35
7.4.160.0050.01016.27
7.4.150.0040.01317.40
7.4.140.0090.00917.86
7.4.130.0110.00716.43
7.4.120.0130.01016.26
7.4.110.0100.00716.54
7.4.100.0130.00616.30
7.4.90.0150.00816.54
7.4.80.0120.00819.39
7.4.70.0090.00916.23
7.4.60.0030.01416.45
7.4.50.0020.00216.32
7.4.40.0040.01422.77
7.4.30.0120.01116.46
7.4.00.0000.01714.91
7.3.330.0030.00313.54
7.3.320.0000.00513.36
7.3.310.0050.00216.24
7.3.300.0070.00016.02
7.3.290.0030.01016.20
7.3.280.0120.00516.15
7.3.270.0060.01217.40
7.3.260.0120.00616.18
7.3.250.0080.01016.39
7.3.240.0110.00616.11
7.3.230.0070.01016.44
7.3.210.0080.00816.54
7.3.200.0100.00719.39
7.3.190.0090.01416.33
7.3.180.0070.01016.09
7.3.170.0030.01716.32
7.3.160.0090.00616.14
7.3.120.0080.00514.57
7.3.110.0000.01314.34
7.3.100.0090.00614.96
7.3.90.0070.00414.49
7.3.80.0070.00714.64
7.3.70.0100.00714.55
7.3.60.0110.00014.54
7.3.50.0000.01214.75
7.3.40.0040.01014.78
7.3.30.0090.00314.54
7.3.20.0060.00616.36
7.3.10.0000.01416.78
7.3.00.0000.01416.61
7.2.330.0090.01116.27
7.2.320.0120.00616.33
7.2.310.0040.01416.41
7.2.300.0070.01016.49
7.2.290.0000.01616.46
7.2.240.0060.00614.75
7.2.230.0040.01115.09
7.2.220.0070.00715.07
7.2.210.0120.00314.78
7.2.200.0000.01614.83
7.2.190.0060.00814.76
7.2.180.0040.00914.52
7.2.170.0130.00315.03
7.2.160.0100.00314.90
7.2.150.0070.00716.82
7.2.140.0100.00616.93
7.2.130.0100.00616.58
7.2.120.0100.00716.56
7.2.110.0000.01216.79
7.2.100.0000.01816.93
7.2.90.0120.00316.66
7.2.80.0080.00516.64
7.2.70.0090.00916.81
7.2.60.0050.00616.84
7.2.50.0060.01116.81
7.2.40.0070.01016.54
7.2.30.0070.01116.63
7.2.20.0070.01016.98
7.2.10.0070.00716.74
7.2.00.0070.00818.13
7.1.330.0070.00715.71
7.1.320.0070.00715.68
7.1.310.0060.00815.71
7.1.300.0030.00615.52
7.1.290.0000.01015.46
7.1.280.0100.00315.56
7.1.270.0000.01315.49
7.1.260.0070.00715.66
7.1.250.0090.00615.61
7.1.200.0030.01015.39
7.1.100.0000.01118.00
7.1.70.0050.00517.33
7.1.60.0130.00619.82
7.1.50.0100.01016.67
7.1.00.0100.05322.48
7.0.200.0000.00816.64
7.0.140.0030.07321.93
7.0.100.0130.09020.14
7.0.90.0200.05020.20
7.0.80.0100.04320.16
7.0.70.0030.09020.08
7.0.60.0070.07320.07
7.0.50.0130.04320.49
7.0.40.0100.04020.13
7.0.30.0000.05020.09
7.0.20.0070.04020.05
7.0.10.0130.04320.08
7.0.00.0070.04020.07
5.6.280.0030.07320.99
5.6.250.0130.07720.79
5.6.240.0100.08020.84
5.6.230.0030.07020.71
5.6.220.0070.04720.69
5.6.210.0030.07720.70
5.6.200.0130.06721.20
5.6.190.0030.04321.17
5.6.180.0070.05021.02
5.6.170.0030.04321.09
5.6.160.0070.04021.04
5.6.150.0070.04021.10
5.6.140.0070.06721.16
5.6.130.0030.05321.09
5.6.120.0030.04321.10
5.6.110.0070.04321.13
5.6.100.0070.08021.23
5.6.90.0070.04021.07
5.6.80.0030.04320.63
5.6.70.0070.07320.50
5.6.60.0100.06720.43
5.6.50.0030.04020.41
5.6.40.0030.04720.40
5.6.30.0030.04020.48
5.6.20.0000.04320.39
5.6.10.0100.03720.45
5.6.00.0030.04720.41
5.5.380.0130.05720.48
5.5.370.0100.08720.43
5.5.360.0130.04720.49
5.5.350.0100.08020.53
5.5.340.0070.05021.00
5.5.330.0070.04020.88
5.5.320.0030.04320.88
5.5.310.0100.03720.96
5.5.300.0030.03720.89
5.5.290.0070.04020.96
5.5.280.0070.04020.80
5.5.270.0030.08720.96
5.5.260.0030.08720.84
5.5.250.0030.04320.82
5.5.240.0070.03720.35
5.5.230.0070.04020.26
5.5.220.0000.04320.29
5.5.210.0000.04320.26
5.5.200.0100.03320.31
5.5.190.0030.05320.26
5.5.180.0100.03020.08
5.5.160.0030.04320.30
5.5.150.0030.04720.07
5.5.140.0100.03320.23
5.5.130.0030.05320.25
5.5.120.0070.03720.23
5.5.110.0070.03320.25
5.5.100.0130.03320.16
5.5.90.0000.04320.20
5.5.80.0030.03320.18
5.5.70.0070.03720.14
5.5.60.0030.03720.23
5.5.50.0070.04020.08
5.5.40.0000.04320.15
5.5.30.0030.08320.22
5.5.20.0100.07020.22
5.5.10.0130.07320.14
5.5.00.0030.05020.15
5.4.450.0100.03319.38
5.4.440.0070.06319.49
5.4.430.0100.08019.52
5.4.420.0030.08019.44
5.4.410.0100.03319.32
5.4.400.0070.03719.14
5.4.390.0070.03319.05
5.4.380.0100.03019.16
5.4.370.0000.04018.91
5.4.360.0030.03718.91
5.4.350.0070.03719.13
5.4.340.0070.03718.93
5.4.320.0000.04019.29
5.4.310.0030.04318.85
5.4.300.0070.03318.90
5.4.290.0070.03719.07
5.4.280.0000.04719.05
5.4.270.0030.03718.90
5.4.260.0100.02719.07
5.4.250.0070.03319.06
5.4.240.0000.03719.03
5.4.230.0000.03719.22
5.4.220.0100.03318.89
5.4.210.0070.03319.22
5.4.200.0130.06319.13
5.4.190.0070.06719.08
5.4.180.0200.06319.04
5.4.170.0030.08318.95
5.4.160.0030.04719.05
5.4.150.0100.07019.01
5.4.140.0030.06316.34
5.4.130.0000.04716.35
5.4.120.0070.04316.27
5.4.110.0130.06716.54
5.4.100.0000.06716.48
5.4.90.0030.04016.39
5.4.80.0030.05716.55
5.4.70.0030.05716.54
5.4.60.0000.04716.50
5.4.50.0130.05316.53
5.4.40.0100.07016.54
5.4.30.0100.05016.47
5.4.20.0000.04716.30
5.4.10.0100.06716.48
5.4.00.0000.06015.88
5.3.290.0000.04314.54
5.3.280.0030.04314.54
5.3.270.0070.05314.60
5.3.260.0030.07314.56
5.3.250.0070.07714.45
5.3.240.0070.08314.59
5.3.230.0130.07314.42
5.3.220.0070.07014.43
5.3.210.0030.09014.48
5.3.200.0000.05314.56
5.3.190.0100.03714.52
5.3.180.0170.05014.42
5.3.170.0000.05314.53
5.3.160.0100.06714.43
5.3.150.0100.06714.54
5.3.140.0000.07314.51
5.3.130.0100.07314.46
5.3.120.0030.06714.41
5.3.110.0030.07014.41
5.3.100.0070.07713.86
5.3.90.0100.07313.96
5.3.80.0100.06314.00
5.3.70.0100.07013.98
5.3.60.0100.07313.87
5.3.50.0100.07013.89
5.3.40.0030.07013.81
5.3.30.0100.07313.69
5.3.20.0030.07013.47
5.3.10.0070.04313.62
5.3.00.0100.06713.60

preferences:
39.5 ms | 400 KiB | 5 Q