0

我正在尝试设置 Paypal,以便当客户购买我们网站的订阅时,他们的帐户会获得批准。不幸的是,在测试我的 IPN 监听器时,我相信我不小心设法让 Paypal 在我们的网站上发起了拒绝服务攻击。有谁知道这可能是什么原因造成的?这是 IPN 侦听器:

// 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.sandbox.paypal.com', 443, $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'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that receiver_email is your Primary PayPal email
if (($payment_status == 'Completed') && ($receiver_email == $paypalemail))
      { 
    // check that txn_id has not been previously processed

    // check that payment_amount/payment_currency are correct
    // process payment
    if ($clientstatus == PENDING){
    $query = "UPDATE clients SET clientStatus = 'APPROVED', substatus = '1'
    WHERE clientID=$item_number";
    $db2->query( $query );
    }
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
}

?>

此外,我收到了来自我的主机的一封电子邮件,其中包含我们错误日志的最后 100 行 - 基本上是这 10 次,都在 1 秒内。

[Fri May 17 13:07:16 2013] [error] [client 173.0.82.126] PHP Warning:
fgets(): 2 is not a valid stream resource in /var/www/vhosts/
site.com/subdomains/development.site.com/httpdocs/hiddenadmin/ipn/index.phpon
line 33
[Fri May 17 13:07:16 2013] [error] [client 173.0.82.126] PHP Warning:
fclose(): 2 is not a valid stream resource in /var/www/vhosts/
site.com/subdomains/development.site.com/httpdocs/hiddenadmin/ipn/index.phpon
line 53
[Fri May 17 13:07:16 2013] [error] [client 173.0.82.126] PHP Warning:
feof(): 2 is not a valid stream resource in /var/www/vhosts/
site.com/subdomains/development.site.com/httpdocs/hiddenadmin/ipn/index.phpon
line 32
4

1 回答 1

0

PayPal 现在对 IPN 使用 HTTP 1.1。X.com 上的示例脚本已更新以反映更改。我建议尝试使用更新的脚本之一。

您提供的代码也响应沙盒环境。如果您不使用会导致帖子验证失败的沙盒。

于 2013-05-22T21:48:33.750 回答