@ 2014-02-25T12:14:25Z <?
// 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');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.3.0 - 5.3.29 , 7.1.25 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.32 , 8.0.0 - 8.0.12 , 8.0.14 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 <?
// 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'); Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.20 , 7.3.32 - 7.3.33 , 7.4.33 , 8.0.13 Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/Ynbon:13
Stack trace:
#0 {main}
thrown in /in/Ynbon on line 13
Process exited with code 255 . Output for 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 Fatal error: Call to undefined function mysql_connect() in /in/Ynbon on line 13
Process exited with code 255 . preferences:dark mode live preview
346.77 ms | 402 KiB | 347 Q