Advertisement
Guest User

Untitled

a guest
May 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.01 KB | None | 0 0
  1. <?php
  2. if (!in_array($_SERVER['REMOTE_ADDR'], array('173.0.81.1', '173.0.81.33', '66.211.170.66'))) {
  3.     saveLog('access', $_SERVER['REMOTE_ADDR'] . ' tried to visit this page without permissions.');
  4.     exit;
  5. }
  6.  
  7. function saveLog($transaction_id, $data) {
  8.     $data = $data . PHP_EOL . var_export($_REQUEST, true);
  9.     @file_put_contents('paypal_logs/' . $transaction_id . '.log', $data);
  10. }
  11.  
  12. // Require the functions to connect to database and fetch config values
  13. require 'config.php';
  14. require 'engine/database/connect.php';
  15.  
  16. $receiverMail = $_REQUEST['receiver_email'];
  17. $status = $_REQUEST['payment_status'];
  18. $currency = $_REQUEST['mc_currency'];
  19. $amount = $_REQUEST['mc_gross'];
  20. $payerMail = $_REQUEST['payer_email'];
  21. $account_id = $_REQUEST['custom'];
  22. $system_transaction_id = $_REQUEST['txn_id'];
  23.  
  24. // Check that the payment status is Completed
  25. if ($status !== 'Completed') {
  26.     saveLog($system_transaction_id, 'Invalid payment status.');
  27.     exit;
  28. }
  29.  
  30. if ($receiverMail == $paypal['mail'] && $currency == $paypal['currency']) {
  31.     $premium_points = 0;
  32.     foreach ($prices as $priceValue => $pointsValue) {
  33.         if ($priceValue == $amount) {
  34.             $premium_points = $pointsValue;
  35.         }
  36.     }
  37.  
  38.     if ($premium_points > 0 && $account_id > 0) {
  39.         mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '" . $system_transaction_id . "', '" . $payerMail . "', '" . $account_id . "', '" . $amount . "', '" . $premium_points . "')");
  40.         mysql_update("UPDATE `znote_accounts` SET `points` = `points` + " . $premium_points . " WHERE `account_id` = " . $account_id);
  41.         saveLog($system_transaction_id, 'accountID:' . $account_id . ',mail:' . $payerMail . ',amount:' . $amount . ' ' . $currency . ',points:' . $premium_points . ',system_transaction_id:' . $system_transaction_id . ',addTime:' . date("F j, Y, g:i a"));
  42.         exit;
  43.     } else {
  44.         saveLog($system_transaction_id, 'Invalid number of premium points or account id.');
  45.     }
  46. } else {
  47.     saveLog($system_transaction_id, 'Invalid receiver mail or money currency.');
  48. }
  49.  
  50. saveLog('error', 'Invalid payment.');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement