Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function write2LogFile( $message, $file = "mylog.txt" ) { $file = fopen($file, "a"); fputs($file, "[".date('d-m-Y')."] ".$message."\n"); fclose($file); }
- $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 ('www.paypal.com', 80, $errno, $errstr, 30);
- if (!$fp) {
- write2LogFile( "ERROR Can not connect to paypal!" );
- }
- else
- {
- fputs ($fp, $header . $req);
- while (!feof($fp))
- {
- $res = fgets ($fp, 1024);
- if (strcmp ($res, "VERIFIED") == 0)
- {
- $payment_status = $_POST['payment_status'];
- $transaction_id = $_POST['txn_id'];
- $payer_email = $_POST['payer_email'] );
- $custom_field = $_POST['custom'];
- if ( $payment_status == 'Completed' )
- {
- // Payment/Donation is completed. Give points here
- }
- else if ( $payment_status == 'Canceled_Reversal' )
- {
- // Player was stupid enough to make a dispute/claim or used a stolen credit card info
- // Basically we ban his account here.
- }
- }
- }
- fclose ($fp);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment