Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!in_array($_SERVER['REMOTE_ADDR'], array('173.0.81.1', '173.0.81.33', '66.211.170.66'))) {
- saveLog('access', $_SERVER['REMOTE_ADDR'] . ' tried to visit this page without permissions.');
- exit;
- }
- function saveLog($transaction_id, $data) {
- $data = $data . PHP_EOL . var_export($_REQUEST, true);
- @file_put_contents('paypal_logs/' . $transaction_id . '.log', $data);
- }
- // Require the functions to connect to database and fetch config values
- require 'config.php';
- require 'engine/database/connect.php';
- $receiverMail = $_REQUEST['receiver_email'];
- $status = $_REQUEST['payment_status'];
- $currency = $_REQUEST['mc_currency'];
- $amount = $_REQUEST['mc_gross'];
- $payerMail = $_REQUEST['payer_email'];
- $account_id = $_REQUEST['custom'];
- $system_transaction_id = $_REQUEST['txn_id'];
- // Check that the payment status is Completed
- if ($status !== 'Completed') {
- saveLog($system_transaction_id, 'Invalid payment status.');
- exit;
- }
- if ($receiverMail == $paypal['mail'] && $currency == $paypal['currency']) {
- $premium_points = 0;
- foreach ($prices as $priceValue => $pointsValue) {
- if ($priceValue == $amount) {
- $premium_points = $pointsValue;
- }
- }
- if ($premium_points > 0 && $account_id > 0) {
- mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '" . $system_transaction_id . "', '" . $payerMail . "', '" . $account_id . "', '" . $amount . "', '" . $premium_points . "')");
- mysql_update("UPDATE `znote_accounts` SET `points` = `points` + " . $premium_points . " WHERE `account_id` = " . $account_id);
- 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"));
- exit;
- } else {
- saveLog($system_transaction_id, 'Invalid number of premium points or account id.');
- }
- } else {
- saveLog($system_transaction_id, 'Invalid receiver mail or money currency.');
- }
- saveLog('error', 'Invalid payment.');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement