Jump to content

Recommended Posts

Hello, I am not a programmer, but I do trial and error attempts at updating scripts.  I have a script that works fine in PHP5.4 but when I modified it for PHP7 it quit working.  When I run this script I get no errors, and the debug portion shows everything the test was successful but in when actual donations are made nothing is entered into the database.   Any help would be appreciated.  FYI, this is from a php-nuke Donations module:

<?php
/************************************************************************/
/* NukeTreasury - Financial management for PHP-Nuke                      */
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash                       */
/*                       thrash@fragnastika.com                         */
/*                       thrashn8r@hotmail.com                          */
/*                                                                      */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/* This program is distributed in the hope that it will be useful, but  */
/* WITHOUT ANY WARRANTY; without even the implied warranty of           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU     */
/* General Public License for more details.                             */
/*                                                                      */
/* You should have received a copy of the GNU General Public License    */
/* along with this program; if not, write to the Free Software          */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  */
/* USA                                                                  */
/************************************************************************/

/* NOTE: This file is accessed by PayPal directly, and not through PHP-Nuke */

include("../config.php");
$ERR = 0;
$log = "";
$loglvl = $tr_config[ipn_dbg_lvl];
define(_ERR, 1);
define(_INF, 2);

if( isset($_GET[dbg]) )
	$dbg = 1;
else
	$dbg = 0;

if( $dbg )
{
	dprt("Debug mode activated", _INF);
	echo "<br>PHP-Nuke Treasury mod<br><br>PayPal Instant Payment Notification script<br><br>See below for status:<br>";
	echo "----------------------------------------------------------------<br>";
	$receiver_email = $tr_config['receiver_email'];
}

$ipnppd = mysqli_connect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

if( $ipnppd )
	dprt("Connection to db - OK!", _INF);
else
	dprt("Connection to db - **FAILED**", _ERR);

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

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";

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$txn_type = $_POST['txn_type'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

dprt("Opening connection and validating request with PayPal...", _INF);

$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);

if (!$fp) {
	// HTTP ERROR
	dprt("FAILED to connect to PayPAl", _ERR);
	die();
}

dprt("OK!", _INF);

fputs ($fp, $header . $req);

// Perform PayPal email account verification
if( !$dbg && strcasecmp( $_POST['business'], $tr_config['receiver_email']) != 0)
{
	dprt("Incorrect receiver email: $receiver_email , aborting", _ERR) ;
	$ERR = 1;
}

//$insertSQL = "";
// Look for duplicate txn_id's
if( $txn_id )
{
	$sql = "SELECT * FROM transactions WHERE txn_id = '$txn_id'";
	$Recordset1 = mysqli_query($ipnppd,$sql) or die(mysqli_error($ipnppd));
	$row_Recordset1 = mysqli_fetch_assoc($Recordset1); 
	$NumDups = mysqli_num_rows($Recordset1);
}

while (!$dbg && !$ERR && !feof($fp)) 
{
	$res = fgets ($fp, 1024);
	if (strcmp ($res, "VERIFIED") == 0)
	{
		dprt("PayPal Verified", _INF);
		// Ok, PayPal has told us we have a valid IPN here

		// Check for a reversal for a refund
		if( strcmp($payment_status, "Refunded") == 0)
		{
			// Verify the reversal
			dprt("Transaction is a Refund", _INF);
			if( ($NumDups == 0) || strcmp($row_Recordset1[payment_status], "Completed") || 
				(strcmp($row_Recordset1[txn_type], "web_accept") != 0 && strcmp($row_Recordset1[txn_type], "send_money") != 0) )
			{
				// This is an error.  A reversal implies a pre-existing completed transaction
				dprt("IPN Error: Received refund but missing prior completed transaction", _ERR);
				foreach( $_POST as $key => $val )
				{
					dprt("$key => $val", $_ERR);
				}
				break;
			}
			if( $NumDups != 1 )
			{
				dprt("IPN Error: Received refund but multiple prior txn_id's encountered, aborting", _ERR);
				foreach( $_POST as $key => $val )
				{
					dprt("$key => $val", $_ERR);
				}
				break;
			}
			
			// We flip the sign of these amount so refunds can be handled correctly
			$mc_gross = -$_POST['mc_gross'];
			$mc_fee = -$_POST['mc_fee'];
			$insertSQL = sprintf("INSERT INTO transactions (`txn_id`,`business`,`item_name`, `item_number`, `quantity`, `invoice`, `custom`, `memo`, `tax`, `option_name1`, `option_selection1`, `option_name2`, `option_selection2`, `payment_status`, `payment_date`, `txn_type`, `mc_gross`, `mc_fee`, `mc_currency`, `settle_amount`, `exchange_rate`, `first_name`, `last_name`, `address_street`, `address_city`, `address_state`, `address_zip`, `address_country`, `address_status`, `payer_email`, `payer_status`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", 
				$_POST['txn_id'],$_POST['business'],$_POST['item_name'],$_POST['item_number'],$_POST['quantity'],$_POST['invoice'],$_POST['custom'],$_POST['memo'],$_POST['tax'],$_POST['option_name1'],$_POST['option_selection1'],$_POST['option_name2'],$_POST['option_selection2'],$_POST['payment_status'],strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])),$_POST['txn_type'],$mc_gross,$mc_fee,$_POST['mc_currency'],$_POST['settle_amount'],$_POST['exchange_rate'],$_POST['first_name'],$_POST['last_name'],$_POST['address_street'],$_POST['address_city'],$_POST['address_state'],$_POST['address_zip'],$_POST['address_country'],$_POST['address_status'],$_POST['payer_email'],$_POST['payer_status']);

			// We're cleared to add this record
			dprt($insertSQL, _INF);
			$Result1 = mysqli_query($ipnppd, $insertSQL) or die(mysqli_error($ipnppd));
			dprt("SQL result = " . $Result1, _INF);
	
			break;
		} else // Look for anormal payment
		if( (strcmp($payment_status, "Completed") == 0) && ((strcmp($txn_type, "web_accept")== 0) || (strcmp($txn_type, "send_money")== 0)) )
		{
			dprt("Normal transaction", _INF);
			if( $lp ) fputs($lp, $payer_email . " " . $payment_status . " " . $_POST['payment_date'] . "\n");

			// Check for a duplicate txn_id
			if( $NumDups != 0 )
			{
				dprt("Valid IPN, but DUPLICATE txn_id! aborting", _ERR);
				foreach( $_POST as $key => $val )
				{
					dprt("$key => $val", $_ERR);
				}
				break;
			}
			
			$insertSQL = sprintf("INSERT INTO transactions (`txn_id`,`business`,`item_name`, `item_number`, `quantity`, `invoice`, `custom`, `memo`, `tax`, `option_name1`, `option_selection1`, `option_name2`, `option_selection2`, `payment_status`, `payment_date`, `txn_type`, `mc_gross`, `mc_fee`, `mc_currency`, `settle_amount`, `exchange_rate`, `first_name`, `last_name`, `address_street`, `address_city`, `address_state`, `address_zip`, `address_country`, `address_status`, `payer_email`, `payer_status`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", 
				$_POST['txn_id'],$_POST['business'],$_POST['item_name'],$_POST['item_number'],$_POST['quantity'],$_POST['invoice'],$_POST['custom'],$_POST['memo'],$_POST['tax'],$_POST['option_name1'],$_POST['option_selection1'],$_POST['option_name2'],$_POST['option_selection2'],$_POST['payment_status'],strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])),$_POST['txn_type'],$_POST['mc_gross'],$_POST['mc_fee'],$_POST['mc_currency'],$_POST['settle_amount'],$_POST['exchange_rate'],$_POST['first_name'],$_POST['last_name'],$_POST['address_street'],$_POST['address_city'],$_POST['address_state'],$_POST['address_zip'],$_POST['address_country'],$_POST['address_status'],$_POST['payer_email'],$_POST['payer_status']);

			// We're cleared to add this record
			dprt($insertSQL, _INF);
			$Result1 = mysqli_query($ipnppd, $insertSQL) or die(mysqli_error($ipnppd));
			dprt("SQL result = " . $Result1, _INF);

			break;
		} else // We're not interested in this transaction, so we're done
		{
			dprt("Valid IPN, but not interested in this transaction", _ERR);
			foreach( $_POST as $key => $val )
			{
				dprt("$key => $val", $_ERR);
			}
			break;
		}
	}
	else if (strcmp ($res, "INVALID") == 0) 
	{
		// log for manual investigation
		dprt("Invalid IPN transaction, this is an abnormal condition", _ERR);
		foreach( $_POST as $key => $val )
		{
			dprt("$key => $val", $_ERR);
		}
		break;
	}
}

if( $dbg )
{
	$sql = "SELECT * FROM transactions LIMIT 10";
	echo "Selecting database...";
	$res = mysqli_select_db($ipnppd, $database_ipnppd);
	if($res)
		echo "OK!<br>"; 
	 else
		echo "<b>FAILED - err: $res</b><br>";
	echo "Executing test query...";
	$Result1 = mysqli_query($ipnppd, $sql) or die(mysqli_error($ipnppd));
	if($Result1)
		echo "PASSED!<br>";
	else
		echo "<b>FAILED</b><br>";
	echo "PayPal Receiver Email: $tr_config[receiver_email]" ;
}

if( $log )
{
	dprt("Logging events<br>\n", _INF);
	// Insert the log entry
	$sql = "INSERT INTO translog VALUES ('','" . strftime('%Y-%m-%d %H:%M:%S',mktime()) . "', '" 
		 . strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])) . "','" . addslashes($log) . "')";
	$Result1 = mysqli_query($ipnppd, $sql) or die(mysqli_error($ipnppd));

	// Clear out old log entries
	$sql = "SELECT id as lowid FROM translog ORDER BY id DESC LIMIT " . $tr_config[ipn_log_entries];
	$Result1 = mysqli_query($ipnppd, $sql) or die(mysqli_error($ipnppd));
	while($recordSet = mysql_fetch_assoc($Result1))
	{
		$lowid = $recordSet[lowid];
	}
	$sql =  "DELETE FROM translog WHERE id < '" . $lowid . "'";
	$Result1 = mysqli_query($ipnppd, $sql) or die(mysqli_error($ipnppd));
}

fclose ($fp);
if( $lp ) fputs($lp,"Exiting\n");
if( $lp ) fclose ($lp);

if( $dbg)
{
	echo "<br>----------------------------------------------------------------<br>";
	echo "If you don't see any error messages, you should be good to go!<br>";
}
	
function dprt($str, $clvl)
{
	global $dbg, $ipnppd, $lp, $log, $loglvl;

	if( $lp ) fputs($lp, $str . "\n");
	if( $dbg ) echo $str . "<br>";
	if( $clvl <= $loglvl )
		$log .= $str . "\n";
}


?>

 

Edited by doulos
Link to comment
https://forums.phpfreaks.com/topic/309363-very-old-ipn-script-help/
Share on other sites

Well, I do see a number of things that are incorrect, and some things that should be done differently, but so far nothing that would prevent it from working outright.

If you don't see any errors then it means you don't have PHP set up to report them correctly - or at all. Make sure you have

error_reporting = -1
log_errors = on

in your php.ini. Then look in your error log (according to the error_log setting, or else your web server's log) for messages. There will be some, so if you don't see any then it's not set up right.

28 minutes ago, requinix said:

Well, I do see a number of things that are incorrect, and some things that should be done differently, but so far nothing that would prevent it from working outright.

If you don't see any errors then it means you don't have PHP set up to report them correctly - or at all. Make sure you have


error_reporting = -1
log_errors = on

in your php.ini. Then look in your error log (according to the error_log setting, or else your web server's log) for messages. There will be some, so if you don't see any then it's not set up right.

You are right!  I found some errors in the log.  I have made the changes and errors stopped.  Now just to wait until someone donates and see if it shows up in the database.

  • 2 weeks later...

Another attempt at a rewrite gave me this PHP error with $dbg=1  (with $dbg=0 I get no PHP errors - however, it still doesn't post to the database when a donatoin is made)

[22-Oct-2019 23:17:56 UTC] PHP Fatal error:  Uncaught Error: Call to a member function sql_query() on null in /home/me/public_html/modules/Donations/ipn/ipnppd.php:207
Stack trace:
#0 {main}
  thrown in /home/me/public_html/modules/Donations/ipn/ipnppd.php on line 207

Here is the whole script:

<?php
/************************************************************************/
/* NukeTreasury - Financial management for PHP-Nuke                      */
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash                       */
/*                       thrash@fragnastika.com                         */
/*                       thrashn8r@hotmail.com                          */
/*                                                                      */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/* This program is distributed in the hope that it will be useful, but  */
/* WITHOUT ANY WARRANTY; without even the implied warranty of           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU     */
/* General Public License for more details.                             */
/*                                                                      */
/* You should have received a copy of the GNU General Public License    */
/* along with this program; if not, write to the Free Software          */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  */
/* USA                                                                  */
/************************************************************************/

/* NOTE: This file is accessed by PayPal directly, and not through PHP-Nuke */


include('../config.php');


$ERR = 0;
$log = '';
$loglvl = $tr_config['ipn_dbg_lvl'];
define('_ERR', 1);
define('_INF', 2);

if( isset($_GET['dbg']) )
	$dbg = 1;
else
	$dbg = 0;

if( $dbg )
{
	dprt('Debug mode activated', _INF);
	echo '<br />PHP-Nuke Treasury mod<br /><br />PayPal Instant Payment Notification script<br /><br />See below for status:<br />';
	echo '----------------------------------------------------------------<br />';
	$receiver_email = $tr_config['receiver_email'];
}

if($ipnppd) {
	dprt('Connection to db - OK!', _INF);
} else {
	dprt('Connection to db - **FAILED**', _ERR);
}

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

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";

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$txn_type = $_POST['txn_type'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

dprt('Opening connection and validating request with PayPal...', _INF);

$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);

if (!$fp) {
	// HTTP ERROR
	dprt('FAILED to connect to PayPal', _ERR);
	die();
}

dprt('OK!', _INF);

fputs ($fp, $header . $req);

// Perform PayPal email account verification
if( !$dbg && strcasecmp( $_POST['business'], $tr_config['receiver_email']) != 0)
{
	dprt('Incorrect receiver email:' . $receiver_email. ', aborting', _ERR) ;
	$ERR = 1;
}

$insertSQL = '';
// Look for duplicate txn_id's
if( $txn_id )
{
	$result = $db->sql_query('SELECT * FROM `donations_transactions` WHERE txn_id = \'' . $txn_id . '\'');
	$NumDups = $db->sql_numrows($result);
	$row_Recordset1 = $db->sql_fetchrow($result);
}

while (!$dbg && !$ERR && !feof($fp))
{
	$res = fgets($fp, 1024);
	if (strcmp($res, 'VERIFIED') == 0)
	{
		dprt('PayPal Verified', _INF);
		// Ok, PayPal has told us we have a valid IPN here

		// Check for a reversal for a refund
		if( strcmp($payment_status, 'Refunded') == 0)
		{
			// Verify the reversal
			dprt('Transaction is a Refund', _INF);
			if( ($NumDups == 0) || strcmp($row_Recordset1['payment_status'], 'Completed') ||
				(strcmp($row_Recordset1['txn_type'], 'web_accept') != 0 && strcmp($row_Recordset1['txn_type'], 'send_money') != 0) )
			{
				// This is an error.  A reversal implies a pre-existing completed transaction
				dprt('IPN Error: Received refund but missing prior completed transaction', _ERR);
				foreach( $_POST as $key => $val )
				{
					dprt("$key => $val", $_ERR);
				}
				break;
			}
			if( $NumDups != 1 )
			{
				dprt('IPN Error: Received refund but multiple prior txn_id\'s encountered, aborting', _ERR);
				foreach( $_POST as $key => $val )
				{
					dprt("$key => $val", $_ERR);
				}
				break;
			}

			// We flip the sign of these amount so refunds can be handled correctly
			$mc_gross = -$_POST['mc_gross'];
			$mc_fee = -$_POST['mc_fee'];
			$insertSQL = sprintf('INSERT INTO `donations_transactions` '."(`txn_id`,`business`,`item_name`, `item_number`, `quantity`, `invoice`, `custom`, `memo`, `tax`, `option_name1`, `option_selection1`, `option_name2`, `option_selection2`, `payment_status`, `payment_date`, `txn_type`, `mc_gross`, `mc_fee`, `mc_currency`, `settle_amount`, `exchange_rate`, `first_name`, `last_name`, `address_street`, `address_city`, `address_state`, `address_zip`, `address_country`, `address_status`, `payer_email`, `payer_status`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
				$_POST['txn_id'],$_POST['business'],$_POST['item_name'],$_POST['item_number'],$_POST['quantity'],$_POST['invoice'],$_POST['custom'],$_POST['memo'],$_POST['tax'],$_POST['option_name1'],$_POST['option_selection1'],$_POST['option_name2'],$_POST['option_selection2'],$_POST['payment_status'],strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])),$_POST['txn_type'],$mc_gross,$mc_fee,$_POST['mc_currency'],$_POST['settle_amount'],$_POST['exchange_rate'],$_POST['first_name'],$_POST['last_name'],$_POST['address_street'],$_POST['address_city'],$_POST['address_state'],$_POST['address_zip'],$_POST['address_country'],$_POST['address_status'],$_POST['payer_email'],$_POST['payer_status']);

			// We're cleared to add this record
			dprt($insertSQL, _INF);
			$Result1 = $db->sql_query($insertSQL);
			dprt('SQL result = ' . $Result1, _INF);

			break;
		} else // Look for anormal payment
		if( (strcmp($payment_status, 'Completed') == 0) && ((strcmp($txn_type, 'web_accept')== 0) || (strcmp($txn_type, 'send_money')== 0)) )
		{
			dprt('Normal transaction', _INF);
			if( $lp ) fputs($lp, $payer_email . " " . $payment_status . " " . $_POST['payment_date'] . "\n");

			// Check for a duplicate txn_id
			if( $NumDups != 0 )
			{
				dprt('Valid IPN, but DUPLICATE txn_id! aborting', _ERR);
				foreach( $_POST as $key => $val )
				{
					dprt("$key => $val", $_ERR);
				}
				break;
			}

			$insertSQL = sprintf('INSERT INTO `donations_transactions` '."(`txn_id`,`business`,`item_name`, `item_number`, `quantity`, `invoice`, `custom`, `memo`, `tax`, `option_name1`, `option_selection1`, `option_name2`, `option_selection2`, `payment_status`, `payment_date`, `txn_type`, `mc_gross`, `mc_fee`, `mc_currency`, `settle_amount`, `exchange_rate`, `first_name`, `last_name`, `address_street`, `address_city`, `address_state`, `address_zip`, `address_country`, `address_status`, `payer_email`, `payer_status`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
				$_POST['txn_id'],$_POST['business'],$_POST['item_name'],$_POST['item_number'],$_POST['quantity'],$_POST['invoice'],$_POST['custom'],$_POST['memo'],$_POST['tax'],$_POST['option_name1'],$_POST['option_selection1'],$_POST['option_name2'],$_POST['option_selection2'],$_POST['payment_status'],strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])),$_POST['txn_type'],$_POST['mc_gross'],$_POST['mc_fee'],$_POST['mc_currency'],$_POST['settle_amount'],$_POST['exchange_rate'],$_POST['first_name'],$_POST['last_name'],$_POST['address_street'],$_POST['address_city'],$_POST['address_state'],$_POST['address_zip'],$_POST['address_country'],$_POST['address_status'],$_POST['payer_email'],$_POST['payer_status']);

			// We're cleared to add this record
			dprt($insertSQL, _INF);
			$Result1 = $db->sql_query($insertSQL);
			dprt('SQL result = ' . $Result1, _INF);

			break;
		} else // We're not interested in this transaction, so we're done
		{
			dprt('Valid IPN, but not interested in this transaction', _ERR);
			foreach($_POST as $key => $val)
			{
				dprt("$key => $val", $_ERR);
			}
			break;
		}
	}
	else if (strcmp ($res, 'INVALID') == 0)
	{
		// log for manual investigation
		dprt('Invalid IPN transaction, this is an abnormal condition', _ERR);
		foreach($_POST as $key => $val)
		{
			dprt("$key => $val", $_ERR);
		}
		break;
	}
}

if( $dbg )
{
	$sql = 'SELECT * FROM `donations_transactions` LIMIT 10';
	echo 'Executing test query...';
	$Result1 = $db->sql_query($sql);
	if($Result1) {
		echo 'PASSED!<br />';
	} else {
		echo '<b>FAILED</b><br />';
	}
	echo 'PayPal Receiver Email: ' , $tr_config['receiver_email'];
}

if( $log )
{
	dprt('Logging events<br />\n', _INF);
	// Insert the log entry
	$sql = 'INSERT INTO `donations_translog` VALUES '."('','" . strftime('%Y-%m-%d %H:%M:%S',time()) . "', '"
		 . strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])) . "','" . addslashes($log) . "')";
	$Result1 = $db->sql_query($sql);

	// Clear out old log entries
	$sql = 'SELECT `id` as `lowid` FROM `donations_translog` ORDER BY `id` DESC LIMIT ' . $tr_config['ipn_log_entries'];
	$Result1 = $db->sql_query($sql);
	while($recordSet = $db->sql_fetchrow($Result1))
	{
		$lowid = $recordSet['lowid'];
	}
	$sql =  'DELETE FROM `donations_translog` WHERE `id` < \'' . $lowid . '\'';
	$Result1 = $db->sql_query($sql);
}

fclose ($fp);
if( $lp ) fputs($lp,"Exiting\n");
if( $lp ) fclose ($lp);

if( $dbg)

{
	echo '<br />----------------------------------------------------------------<br />';
	echo 'If you don\'t see any error messages, you should be good to go!<br />';
}

function dprt($str, $clvl)
{
	global $dbg, $ipnppd, $lp, $log, $loglvl;

	if( $lp ) fputs($lp, $str . "\n");
	if( $dbg ) echo $str . "<br />";
	if( $clvl <= $loglvl )
		$log .= $str . "\n";
}
?>

Any suggestions?

Edited by doulos
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.