paypal IPN indentation fix

This commit is contained in:
Znote 2021-07-18 22:34:17 +02:00
parent df062b56fd
commit 6af276225f

74
ipn.php
View File

@ -1,21 +1,21 @@
<?php <?php
if (gethostbyaddr($_SERVER['REMOTE_ADDR']) !== 'notify.paypal.com') { if (gethostbyaddr($_SERVER['REMOTE_ADDR']) !== 'notify.paypal.com') {
exit(); exit();
} }
// Require the functions to connect to database and fetch config values // Require the functions to connect to database and fetch config values
require 'config.php'; require 'config.php';
require 'engine/database/connect.php'; require 'engine/database/connect.php';
// Fetch and sanitize POST and GET values // Fetch and sanitize POST and GET values
function getValue($value) { function getValue($value) {
return (!empty($value)) ? sanitize($value) : false; return (!empty($value)) ? sanitize($value) : false;
} }
function sanitize($data) { function sanitize($data) {
return htmlentities(strip_tags(mysql_znote_escape_string($data))); return htmlentities(strip_tags(mysql_znote_escape_string($data)));
} }
function VerifyPaypalIPN(array $IPN = null){ function VerifyPaypalIPN(array $IPN = null){
if(empty($IPN)){ if(empty($IPN)){
$IPN = $_POST; $IPN = $_POST;
} }
@ -55,36 +55,36 @@
return false; return false;
} }
return !strcasecmp($Response, 'VERIFIED'); return !strcasecmp($Response, 'VERIFIED');
} }
// Fetch paypal configurations // Fetch paypal configurations
$paypal = $config['paypal']; $paypal = $config['paypal'];
$prices = $config['paypal_prices']; $prices = $config['paypal_prices'];
// Send an empty HTTP 204 OK response to acknowledge receipt of the notification // Send an empty HTTP 204 OK response to acknowledge receipt of the notification
http_response_code(204); http_response_code(204);
// Build the required acknowledgement message out of the notification just received // Build the required acknowledgement message out of the notification just received
$postdata = 'cmd=_notify-validate'; $postdata = 'cmd=_notify-validate';
if(!empty($_POST)){ if(!empty($_POST)){
$postdata.="&".http_build_query($_POST); $postdata.="&".http_build_query($_POST);
} }
// Assign payment notification values to local variables // Assign payment notification values to local variables
$item_name = $_POST['item_name']; $item_name = $_POST['item_name'];
$item_number = $_POST['item_number']; $item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status']; $payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross']; $payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency']; $payment_currency = $_POST['mc_currency'];
$txn_id = getValue($_POST['txn_id']); $txn_id = getValue($_POST['txn_id']);
$receiver_email = getValue($_POST['receiver_email']); $receiver_email = getValue($_POST['receiver_email']);
$payer_email = getValue($_POST['payer_email']); $payer_email = getValue($_POST['payer_email']);
$custom = (int)$_POST['custom']; $custom = (int)$_POST['custom'];
$connectedIp = $_SERVER['REMOTE_ADDR']; $connectedIp = $_SERVER['REMOTE_ADDR'];
mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '0', 'Connection from IP: $connectedIp', '0', '0', '0')"); mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '0', 'Connection from IP: $connectedIp', '0', '0', '0')");
$status = VerifyPaypalIPN(); $status = VerifyPaypalIPN();
if ($status) { if ($status) {
// Check that the payment_status is Completed // Check that the payment_status is Completed
if ($payment_status == 'Completed') { if ($payment_status == 'Completed') {
@ -127,8 +127,8 @@
} }
} }
} }
} else { } else {
// Something is wrong // Something is wrong
mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', 'ERROR: Invalid data. $postdata', '0', '0', '0')"); mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', 'ERROR: Invalid data. $postdata', '0', '0', '0')");
} }
?> ?>