Guest User

Untitled

a guest
Sep 21st, 2010
1,626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2. function write2LogFile( $message, $file = "mylog.txt" ) { $file = fopen($file, "a"); fputs($file, "[".date('d-m-Y')."] ".$message."\n"); fclose($file); }
  3. $req = 'cmd=_notify-validate';
  4. foreach ($_POST as $key => $value)
  5. {
  6.     $value = urlencode(stripslashes($value));
  7.     $req .= "&$key=$value";
  8. }
  9. $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  10. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  11. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  12. $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
  13. if (!$fp) {
  14.     write2LogFile( "ERROR Can not connect to paypal!" );
  15. }
  16. else
  17. {
  18.     fputs ($fp, $header . $req);
  19.     while (!feof($fp))
  20.     {
  21.         $res = fgets ($fp, 1024);
  22.         if (strcmp ($res, "VERIFIED") == 0)
  23.         {
  24.             $payment_status = $_POST['payment_status'];
  25.             $transaction_id = $_POST['txn_id'];
  26.             $payer_email    = $_POST['payer_email'] );
  27.             $custom_field   = $_POST['custom'];
  28.  
  29.             if ( $payment_status == 'Completed' )
  30.             {          
  31.                 // Payment/Donation is completed. Give points here
  32.             }
  33.             else if ( $payment_status == 'Canceled_Reversal' )
  34.             {
  35.                 // Player was stupid enough to make a dispute/claim or used a stolen credit card info
  36.                 // Basically we ban his account here.
  37.             }
  38.         }
  39.     }
  40.     fclose ($fp);
  41. }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment