Location: PHPKode > projects > H-tracker > paypal.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//
require "backend/functions.php";
dbconn(true);

// 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 ('www.paypal.com', 80, $errno, $errstr, 30);

// 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'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$paypal_email = $site_config['PAYPALEMAIL']; 
$clid = $_POST['custom'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {



if ($receiver_email == $paypal_email && $payment_status == "Completed"){
if ($payment_amount == 5)
{$donb = 5368709120; }
elseif ($payment_amount == 10)
{$donb = 10737418240; }
elseif ($payment_amount == 20)
{$donb = 21474836480; }
elseif ($payment_amount == 30)
{$donb = 32212254720; }
elseif ($payment_amount == 40)
{$donb = 42949672960; }
elseif ($payment_amount == 50)
{$donb = 53687091200; }
elseif ($payment_amount == 100)
{$donb = 161061273600; }
else {
$donb = 1073741824*$payment_amount;}

//Set User Invites
if ($payment_amount == 5){
    $invites = 1;
}
elseif ($payment_amount == 10){
    $invites = 1;
}
elseif ($payment_amount == 20){
    $invites = 2;
}
elseif ($payment_amount == 30){
    $invites = 3;
}
elseif ($payment_amount == 40){
    $invites = 4;
}
elseif ($payment_amount == 50){
    $invites = 5;
}
elseif ($payment_amount == 100){
    $invites = 10;
}
else {
$invites = 0;
}
if ($payment_amount == 5 || $payment_amount == 10 || $payment_amount == 20 || $payment_amount == 30 || $payment_amount == 40 || $payment_amount == 50 ) {
if ($class <= 3){
    $class = 3;
}
  $query = "UPDATE users SET donated = donated + '$payment_amount', class=$class, warned ='no', invites = invites + $invites, uploaded = uploaded + $donb where id='$clid'";
  $result = mysql_query($query);
}
}


}
else if (strcmp ($res, "INVALID") == 0) {
header("Refresh: 3;url=account-details.php?id=$clid");
}
}
fclose ($fp);
}
?>
Return current item: H-tracker