<?php
include("connect.txt");
$amount = $_SESSION['amt'];
$playerKey=$_SESSION['userid'];//
$myFile = "IPNDump.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "==== " . date('r') . " ====" . chr(13) . chr(10);
while (list($key, $value) = each($_POST))
{
if ("" !== $value)
{
$stringData .= "POST: $key = $value" . chr(13) . chr(10);
}
}
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$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) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") === 0) {
$GQ="SELECT `ether` FROM `aom_dps` WHERE `user`='$playerKey' LIMIT 1";
$result1= mysqli_query($cxn,$GQ)or die("Couldn't find in database.");
$grabbedInfo=mysqli_fetch_assoc($result1);
$tamt=$grabbedInfo["ether"]+$amount*10;
$UQ="UPDATE `aom_dps` SET `ether` = '$tamt' WHERE `user` = '$playerKey'";
$result2= mysqli_query($cxn,$UQ)or die("Couldn't update the db.");
}
else if (strcmp ($res, "INVALID") === 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
}
}
fwrite($fh, $stringData);
fclose($fh);
echo "This is an IPN listener. Make sure you have IPN ENABLED in your PayPal control panel, and the correct URL set to point to this file on your server.";
?>
你好,我会保持简短。在搜索了主板并遇到一些有用的标题后,我了解到我可以在ipn脚本中更新我的数据库以进行自适应支付。我一直试图设置它,但一直没有结果可行。所以我很好奇可能会出现什么问题,我会承认我在PHP代码方面不是很好,所以可能就是这样,但我也对在更新数据库或设置这个ipn时可能会犯的其他常见错误感兴趣脚本。从字面上看,其他一切似乎都能正常运作,这是最后一步。
我已经在我的休息时间里工作了4-5天所以我真的很感激,如果有经验的人可以看一看并辨别出我可能为此脚本设置的错误或其他错误。一般情况下会出现这种情况:我进行购买,资金在2个帐户之间正确供资,但数据库在到达IPN脚本时从不更新,这是一个问题,因为这是一个在线游戏,玩家需要访问数据库,以便在线加载正确的数字值到他们的角色。提前谢谢。