- Impact
- 25
I have a script that basically checks paypal for a payment, then does a few queries, mails me and then should include the index page, but it doesn't, it does everything but include my index page
I will give all my NP$ and the domain prxa.info to anyone who can fix it.
Here is my code
I will give all my NP$ and the domain prxa.info to anyone who can fix it.
Here is my code
PHP:
<?php
error_reporting(E_ALL);
include("vars.php");
include("dbconnect.php");
session_start();
$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.sandbox.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$memo = $_POST['item_name'];
$userid = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$amount = $_POST['mc_gross'];
$currency = $_POST['mc_currency'];
$batch = $_POST['txn_id'];
$payee = $_POST['receiver_email'];
$business = $_POST['business'];
$payer = $_POST['payer_email'];
$payment_date = $_POST['payment_date'];
if (!$fp)
{
$menu='invalidbuy';
include("index.php");
mysql_close;
exit;
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
// make sure we are using the correct paypal and currency!
if ($business != $site_paypal || $currency!="USD")
{
$menu='invalidbuy';
include("index.php");
mysql_close;
exit;
}
// Get info from the buylog, which is set from buyscript.php
$eredm = mysql_query('SELECT * FROM `buylog` WHERE `bid` = "' . $userid . '"') or die(mysql_error());
$buylog = mysql_fetch_array($eredm);
// Get the scripts main information
$eredm = mysql_query('SELECT * FROM `scripts` WHERE `scriptid` = "' . $buylog['bscript'] . '"') or die(mysql_error());
$script = mysql_fetch_array($eredm);
// Set commission to the price using the price from the buyrights (1,2 or 3)
if ($buylog['brights']==1)
{
$commission = $script['price'];
}
if ($buylog['brights']==2)
{
$commission = $script['priceresell'];
}
if ($buylog['brights']==3)
{
$commission = $script['pricemaster'];
}
// If there is a reseller, set reseller to the resellers ID
if (isset($_SESSION['reseller']))
{
$resell = $_SESSION["reseller"];
}
// If no reseller set, then comission per this sale is just the coder comission
if ($resell=="")
{
$comperc = $coder_com;
}
else
{
$comperc = $coder_com-$reseller_com;
}
$com = $commission * ($comperc/100);
// Update members and add to the balance of the author of the script.
$sql = 'UPDATE `members` SET `balance` = "(balance + ' . $com . ')" WHERE `username` = "' . $script['author'] . '"';
// Do the above query
$eredm = mysql_query($sql) or die(mysql_error());
// Make sure people are not conning us out of monies!
if ($amount != $commission)
{
$menu = 'invalidbuy';
include("index.php");
mysql_close;
exit;
}
// Update the buylog for this item, and set bdone (buying done) to 1 and add the batch number to show paypal transaction
$sql = 'UPDATE `buylog` SET `bbatch` = "' . $batch . '", `bdone` = "1" WHERE `bid` = "' . $userid . '"';
// Do the above query
$eredm = mysql_query($sql) or die(mysql_error());
// Add a row to selling history table, to show this sale of script (this is show in admin)
$sql = 'INSERT INTO `selling_history` SET `sscript` = "' . $buylog['bscript'] . '", `sdate` = "' . date("Y-m-d") . '", `sreseller` = "' . $resell . '", `sprice` = "' . $commission . '", `sstatus` = "0"';
// Do the above query
$eredm = mysql_query($sql) or die(mysql_error());
// Mail the admin to let him/her know a script has been sold
$mailcont = 'Script has been sold!';
mail($adminmail,'Script Sold',$mailcont,"From: $adminmail");
// Set the page (menu) to buydone
$menu = 'buydone';
$script = $buylog['bscript'];
$buyid = $userid;
include("index.php");
}
}
}
fclose ($fp);
// Close the connection!
mysql_close;
exit;
?>
Last edited: