hi all,
anyone knows whats wrong with this ipn lister?
its exact same paypal ipn with only few changes in sql query, i get 500 internal server error
however when i use the original paypal ipn script i don't get any error, any help please
<?php
include ('config.php');
/////////////////////////////////////////////////
/////////////Begin Script below./////////////////
/////////////////////////////////////////////////// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";// If testing on Sandbox use:
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$item_number = $_POST;
$payment_status = $_POST;
$txn_id = $_POST;
$payment_date = $_POST;
$payment_status = $_POST;
$payer_email = $_POST;
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0 || 1==1) {//create MySQL connection
$Connect = @mysql_connect($db_host, $db_username, $db_password)
or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
//select database
$Db = @mysql_select_db($db_database, $Connect)
or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
//check if transaction ID has been processed before
$checkquery = "select txnid from users where txnid='".$txn_id."'";
$sihay = mysql_query($checkquery) or die("Duplicate txn id check query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
$nm = mysql_num_rows($sihay);
if ($nm == 0 && $payment_status == 'Completed'){
/////////////////////////////////////////////////
$checkquery2 = "select email from users where email='".$payer_email."'";
$sihay2 = mysql_query($checkquery2) or die("Duplicate email check query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
$nm2 = mysql_num_rows($sihay2);if ($nm2 == 0){
$password = 'dd';
$days = 30;
$strQuery = "insert into users (email,password,days,rsaccount,rspass,hfaccount,hfpass,fsaccount,fspass,muaccount,mupass,date) values ('".$payer_email."','".$password."','".$days."','".$rsaccount."','".$rspass."','".$hfaccount."','".$hfpass."','".$fsaccount."','".$fspass."','".$muaccount."','".$mupass."','".$payment_date."')";$result = mysql_query($strQuery) or die("insert user, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
}
// send an email in any case
echo "Verified";
// mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n $strQuery2");
}
else {
// send an email
echo 'doubl';
//mail($notify_email, "VERIFIED DUPLICATED TRANSACTION", "$res\n $req \n $strQuery\n $struery\n $strQuery2");
}
// if the IPN POST was 'INVALID'...do this
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
echo 'dddd';
mail($notify_email, "INVALID IPN", "$res\n $req");
}
}
fclose ($fp);
}?>