• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux IPN Problem Please look

Pheenix

Mr.Plain Awesome
Joined
Mar 28, 2011
Messages
152
Reaction score
14
Location
Sweden
my IPN script:

PHP:
<?php

    // MySQLi connection
    $mysql = new mysqli ('127.0.0.1', 'root', 'mypassword', 'theforgottenserver');
    
    // Variables, don't touch!
    $receiverEmail = $_POST['receiver_email'];
    $paymentStatus = $_POST['payment_status'];
    $mcGross = $_POST['mc_gross'];
    $mcCurrency = $_POST['mc_currency'];
    $customValue = stripslashes(ucwords(strtolower(trim($_POST['custom']))));  
    
    // Prices
    $prices = array('1.00' => 30);
    
    // Setup
    $receiver = '[email protected]';
    $currency = 'EUR';
    $whatToDo = 2; // 1 - delete, 2 - custom

// 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";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);


if(!$fp) {
        die("Error."); // No respons from paypal server

}
@fputs ($fp, $header . $req);
while (!feof($fp)) {
        $res = fgets ($fp, 1024);

        if(strcmp($res, "INVALID") == 0) {
          die("Error."); // INVALID 
        }
}
if(strcmp($res, "VERIFIED") != 0) {
 die("Error."); // Not VERTIFIED
}
    
    if($paymentStatus == 'Completed' && $receiverEmail == $receiver && isset($prices[$mcGross]) && $mcCurrency == $currency)
    {
        $mysql->query('UPDATE `accounts` SET `premium_points` = `premium_points` + ' . $prices[$mc_gross] . ' WHERE `name` = "' . $customValue . '"');
    }
    elseif($paymentStatus == 'Reversed' && $receiverEmail == $receiver)
    {
        if($whatToDo == 1)
        {
            $mysql->query('DELETE FROM `accounts` WHERE `name` = "' . $customValue . '"');
        }
        elseif($whatToDo == 2)
        {
            // if not deleting, what to do?
        }
    }
?>

Paypal:
ipn.png


Mysql accounts table:
mysql.png



Can someone tell me whats wrong? As far as i know, my donation site is working, my paypal gets the donation amount, my ipn site is accessible from paypal, but the script is not altering mysql tables, i also know the script can connect to mysql because i get a "error!" when i view it in a browser (before it said cannot connect to mysql bla bla bla but i fixed that) do i have to edit something in /etc/apache2/apache2.conf or set some privileges on the ipn.php? Please help me!
 
Last edited:
Back
Top