-
Paygol ipn help!
heyy im using a paygol IPN that was released here on ragezone, and someone helped me make it give rank 2, but when i test it, it doesn't give rank 2 it doesn't do anything:L
here is my code
<?php
$MySQL_host = 'localhost';
$MySQL_user = 'root';
$MySQL_pw = 'Mypassword';
$MySQL_db = 'ph';
$MySQL_db_table = 'users';
$PayGol_IPs = array
(
'109.70.3.48',
'109.70.3.146',
'109.70.3.58'
);
$min_price = 0;
$allowed_currencies = array('GBP');
$logging = true;
$log_path = 'log_paygol_'; // error|success
function pgLog($type, $msg)
{
global $logging, $log_path;
if (!$logging) return false;
$fh = @fopen($log_path . $type, 'a');
if ($fh)
{
fwrite($fh, "------\n Date: " . date('d.m.Y H:i:s') . "\tIP: " . $_SERVER['REMOTE_ADDR'] . (isset($_GET['sender']) ? ("\tSender: " . $_GET['sender']) : "") . "\n Msg: " . $msg . "\n------\n");
fclose($fh);
}
else
{
echo '!!! Not allowed to write to ' . $log_path . $type . ' !!!' . PHP_EOL;
echo 'whoami: ' . @exec('whoami') . PHP_EOL;
}
}
try
{
if (!in_array($_SERVER['REMOTE_ADDR'], $PayGol_IPs))
{
throw new Exception('Invalid remote IP');
}
if ($_GET['price'] < $min_price)
{
throw new Exception('Too low price: ' . $_GET['price']);
}
if (!in_array($_GET['currency'], $allowed_currencies))
{
throw new Exception('Invalid currency');
}
$db = new mysqli($MySQL_host, $MySQL_user, $MySQL_pw, $MySQL_db);
if ($db->connect_error)
{
throw new Exception('MySQL connect error (' . $db->connect_errno . '): ' . $db->connect_error);
}
if (@$db->query('UPDATE `'users '` SET `rank` = `2`) . '\' '))
{
if ($db->affected_rows == 0)
{
throw new Exception('Query: No rows affected (non-existing user-id? custom = ' . $_GET['custom'] . ')');
}
}
else
{
throw new Exception('Query error (' . $db->errno . '): ' . $db->error);
}
$db->close();
header('Content-Type: text/plain');
echo 'OK';
pgLog('success', "User-Id: " . $_GET['custom'] . "\tPrice: " . $_GET['price']);
}
catch (Exception $ex)
{
header('HTTP/1.1 400 Bad Request');
header('Content-Type: text/plain');
pgLog('error', $ex->getMessage());
echo $ex->getMessage();
exit;
}
?>