@ 2014-03-18T20:40:34Z <?php
/*
Copyright, 2014 Magictallguy
This file, and all files linked to it, are to be used at Magictallguy's discretion only.
If the file is removed by, or at the request of Magictallguy; then it should not be re-uploaded.
If the file is re-uploaded, or not removed; Magictallguy reserves the right to have it removed by the authorities available at the time
*/
// tell PHP to log errors to ipn_errors.log in this directory
// include(DIRNAME(__DIR__) . '/includes/dbcon.php');
// (DIRNAME(__DIR__) . '/includes/classes.php');
// initiate the IPN listener
//(__DIR__ . '/ipnlistener.php');
$listener = new IpnListener();
// tell the IPN listener not to use the PayPal test sandbox
$listener->use_sandbox = true;
// try to process the IPN POST
try {
$listener->requirePostMethod();
$verified = $listener->processIpn();
} catch (Exception $e) {
error_log($e->getMessage());
exit;
}
$errorMail = 'errors@convict-conflict.com';
// mail($errorMail, 'Payment details: everything', $listener->getTextReport());
if($verified) {
if(!ctype_digit($_POST['item_number']) || !$_POST['item_number']) {
mail($errorMail, 'Payment failed: no pack ID', $listener->getTextReport());
exit;
}
if($_POST['payment_status'] != 'Completed') {
mail($errorMail, 'Payment failed: invalid status', $listener->getTextReport());
exit;
}
// if(!in_array(strtolower($_POST['receiver_email']), array('magictallguy_card@hotmail.co.uk', 'heres_chrissie@hotmail.co.uk'))) {
if(strtolower($_POST['receiver_email']) != 'mtg@magictallguy.tk') {
mail($errorMail, 'Payment failed: invalid receiver email', $listener->getTextReport());
exit;
}
if($_POST['mc_currency'] != 'USD') {
mail($errorMail, 'Payment failed: invalid currency', $listener->getTextReport());
exit;
}
if($_POST['payment_type'] != 'instant') {
mail($errorMail, 'Payment failed: invalid payment type', $listener->getTextReport());
exit;
}
if($_POST['txn_type'] != 'web_accept') {
mail($errorMail, 'Payment failed: invalid transaction type', $listener->getTextReport());
exit;
}
$query = $mtgdb->query("SELECT `id_purchase` FROM `paypal_ipn` WHERE `ipn_data` = '".$mtgdb->escape($_POST['txn_id'])."'");
if($mtgdb->num_rows($query)) {
mail($errorMail, 'Payment failed: double submission', $listener->getTextReport());
exit("You've already submitted this payment");
}
$select = $mtgdb->query("SELECT * FROM `pcstore` WHERE `pack_id` = ".$_POST['item_number']);
if(!$mtgdb->num_rows($select)) {
mail($errorMail, 'Payment failed: Invalid Pack ID', $listener->getTextReport());
exit("Invalid pack ID");
}
$row = $mtgdb->fetch_row($select);
$discount = $mtgdb->fetch_single($mtgdb->query("SELECT `discount` FROM `serverconfig`"));
if($discount)
$row['pack_cost'] -= ($row['pack_cost'] / 100 * $discount);
$custom = explode('|', $_POST['custom']);
$donator = new User($custom[0], $mtgdb);
if(!empty($custom[2]) && $custom[2] != '0.00') {
$_POST['mc_gross'] += $custom[2];
if($donator->storeCredit < $custom[2] || $row['pack_cost'] != $_POST['mc_gross']) {
mail($errorMail, 'Payment failed: Tried to cheat the Store Credit System', $listener->getTextReport());
exit;
}
$mtgdb->query("UPDATE `users` SET `storeCredit` = `storeCredit` - ".$custom[2]." WHERE `id` = ".$donator->id);
} else {
if($_POST['mc_gross'] != $row['pack_cost']) {
mail($errorMail, 'Payment failed: Amount paid doesn\'t match pack: Gross: '.$_POST['mc_gross'].' | Cost: '.$row['pack_cost'], $listener->getTextReport());
exit;
}
}
$mtgdb->query("INSERT INTO `paypal_ipn` VALUES ('', ".$donator->id.", ".time().", '".$mtgdb->escape($_POST['txn_id'])."', '".$row['pack_details']."', '".$custom[1]."', ".$_POST['mc_gross'].", '".$mtgdb->escape($_POST['payer_email'])."')");
if($row['pack_type'] == 'query') {
$sql = "UPDATE `users` SET ".$row['pack_query']." WHERE `id` = ".$donator->id;
mail($errorMail, 'Credit details: query check', $sql, 'From: support@convict-conflict.com');
$mtgdb->query($sql);
if(preg_match('/\`bank\` ?\+ ?[0-9]+/', $row['pack_query'], $match))
translog_add($_SESSION['who'], 'rp store', 'money', preg_replace('/\`bank\` ?\+ ?/', '', $match[0]));
if(preg_match('/\`points\` ?\+ ?[0-9]+/', $row['pack_query'], $match))
translog_add($_SESSION['who'], 'rp store', 'points', preg_replace('/\`points\` ?\+ ?/', '', $match[0]));
if(preg_match('/\`rmdays\` ?\+ ?[0-9]+/', $row['pack_query'], $match))
translog_add($_SESSION['who'], 'rp store', 'rp days', preg_replace('/\`rmdays\` ?\+ ?/', '', $match[0]));
} else if($row['pack_type'] == 'item') {
$items = explode('|', $row['pack_query']);
mail($errorMail, 'Credit details: queryItem/sql', print_r($items, true)."\r\n\r\n".$sql, 'From: support@convict-conflict.com');
foreach($items as $itemQty) {
$item = explode(',', $itemQty);
$selectItem = $mtgdb->query("SELECT `id` FROM `items` WHERE `id` = ".$item[0]);
if($mtgdb->num_rows($selectItem)) {
Give_Item($item[0], $donator->id, $item[1]);
translog_add($donator->id, 'rp store', 'item', $item[0], $item[1]);
}
}
mail($errorMail, 'Payment details: item check', $sql."\r\n\r\n\r\n".$listener->getTextReport());
} else {
$queryItem = explode('.', $row['pack_query']); //$queryItem[0] = [The query] | $queryItem[1] = [the items/qty]
$sql = "UPDATE `users` SET ".str_replace(array('[', ']'), '', $queryItem[0])." WHERE `id` = ".$donator->id;
$mtgdb->query($sql);
mail($errorMail, 'Credit details: queryItem/sql', print_r($queryItem, true)."\r\n\r\n".$sql, 'From: support@convict-conflict.com');
if(preg_match('/\`bank\` ?\+ ?[0-9]+/', str_replace(array('[', ']'), '', $queryItem[0]), $match))
translog_add($_SESSION['who'], 'rp store', 'money', preg_replace('/\`bank\` ?\+ ?/', '', $match[0]));
if(preg_match('/\`points\` ?\+ ?[0-9]+/', str_replace(array('[', ']'), '', $queryItem[0]), $match))
translog_add($_SESSION['who'], 'rp store', 'points', preg_replace('/\`points\` ?\+ ?/', '', $match[0]));
if(preg_match('/\`rmdays\` ?\+ ?[0-9]+/', str_replace(array('[', ']'), '', $queryItem[0]), $match))
translog_add($_SESSION['who'], 'rp store', 'rp days', preg_replace('/\`rmdays\` ?\+ ?/', '', $match[0]));
$items = explode('|', str_replace(array('[', ']'), '', $queryItem[1]));
foreach($items as $itemQty) {
$item = explode(',', $itemQty);
$selectItem = $mtgdb->query("SELECT `id` FROM `items` WHERE `id` = ".$item[0]);
if($mtgdb->num_rows($selectItem)) {
Give_Item($item[0], $donator->id, $item[1]);
translog_add($donator->id, 'rp store', 'item', $item[0], $item[1]);
}
}
mail($errorMail, 'Payment details: both check', $sql."\r\n\r\n\r\n".$listener->getTextReport());
}
Send_Event(1, $donator->formattedname." [".$donator->id."] paid for ".$row['pack_name'], 'donations');
Send_Event(2, $donator->formattedname." [".$donator->id."] paid for ".$row['pack_name'], 'donations');
$selectReferral = $mtgdb->query("SELECT `referrer` FROM `referrals` WHERE `referred` = ".$donator->id);
if($mtgdb->num_rows($selectReferral)) {
$referrer = $mtgdb->fetch_single($selectReferral);
$mtgdb->query("UPDATE `users` SET `storeCredit` = `storeCredit` + ".$mtg->formatMoney($_POST['mc_gross'] / 10, false)." WHERE `id` = ".$referrer);
Send_Event($referrer, $donator->formattedname." just upgraded their account. You receive ".$mtg->formatMoney($_POST['mc_gross'] / 10)." as RP Store Credit", 'donations');
}
Send_Event($donator->id, "Your ".$row['pack_name']." has been credited to you. Thank you!", 'donations');
mail($errorMail, 'Valid payment processed', $listener->getTextReport());
$selectDonCount = $mtgdb->query("SELECT `id` FROM `top_donators` WHERE `userid` = ".$donator->id);
if(!$mtgdb->num_rows($selectDonCount))
$mtgdb->query("INSERT INTO `top_donators` (`userid`, `donCount`) VALUES (".$donator->id.", ".$_POST['mc_gross'].")");
else
$mtgdb->query("UPDATE `top_donators` SET `donCount` = `donCount` + ".$_POST['mc_gross']." WHERE `userid` = ".$donator->id);
} else {
mail($errorMail, 'Invalid IPN', $listener->getTextReport());
$donator = new User($donator->id, $mtgdb);
Send_Event(1, $donator->formattedname." [".$donator->id."] failed to pay for ".$row['pack_name'], 'donations');
Send_Event(2, $donator->formattedname." [".$donator->id."] failed to pay for ".$row['pack_name'], 'donations');
exit("Payment failed<br /><a href='http://convict-conflict.com'>Return to ".$mtg->gameSet('game_name')."</a>");
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.2.6 0.013 0.000 16.75 7.2.0 0.006 0.006 19.01 7.1.20 0.008 0.008 15.69 7.1.10 0.008 0.003 18.09 7.1.7 0.005 0.003 17.08 7.1.6 0.006 0.019 19.82 7.1.5 0.010 0.013 16.62 7.1.0 0.003 0.077 22.48 7.0.20 0.000 0.007 16.85 7.0.14 0.003 0.077 21.95 7.0.10 0.043 0.073 20.08 7.0.9 0.040 0.080 20.06 7.0.8 0.033 0.080 20.03 7.0.7 0.037 0.087 20.01 7.0.6 0.053 0.043 19.94 7.0.5 0.020 0.073 20.46 7.0.4 0.003 0.083 20.15 7.0.3 0.000 0.073 20.04 7.0.2 0.013 0.080 20.13 7.0.1 0.007 0.053 19.99 7.0.0 0.000 0.050 20.10 5.6.28 0.010 0.067 21.08 5.6.25 0.013 0.067 20.71 5.6.24 0.007 0.047 20.72 5.6.23 0.003 0.090 20.74 5.6.22 0.003 0.070 20.68 5.6.21 0.010 0.080 20.86 5.6.20 0.003 0.043 21.04 5.6.19 0.007 0.083 21.20 5.6.18 0.007 0.073 21.04 5.6.17 0.003 0.073 21.04 5.6.16 0.007 0.067 21.13 5.6.15 0.003 0.083 21.14 5.6.14 0.010 0.043 21.12 5.6.13 0.007 0.040 21.21 5.6.12 0.000 0.047 21.12 5.6.11 0.007 0.040 21.18 5.6.10 0.003 0.043 21.02 5.6.9 0.003 0.040 21.02 5.6.8 0.003 0.033 20.43 5.6.7 0.000 0.037 20.54 5.6.6 0.003 0.033 20.56 5.6.5 0.007 0.030 20.52 5.6.4 0.003 0.033 20.48 5.6.3 0.010 0.030 20.40 5.6.2 0.000 0.040 20.54 5.6.1 0.007 0.043 20.50 5.6.0 0.007 0.037 20.45 5.5.38 0.007 0.077 20.65 5.5.37 0.007 0.077 20.46 5.5.36 0.007 0.057 20.57 5.5.35 0.013 0.073 20.51 5.5.34 0.000 0.087 20.95 5.5.33 0.010 0.043 20.71 5.5.32 0.003 0.087 20.81 5.5.31 0.003 0.043 20.91 5.5.30 0.003 0.043 20.96 5.5.29 0.007 0.040 21.01 5.5.28 0.003 0.040 20.96 5.5.27 0.003 0.043 20.80 5.5.26 0.003 0.043 20.84 5.5.25 0.000 0.047 20.67 5.5.24 0.007 0.030 20.26 5.5.23 0.000 0.037 20.38 5.5.22 0.007 0.030 20.22 5.5.21 0.000 0.037 20.19 5.5.20 0.010 0.033 20.30 5.5.19 0.007 0.087 20.32 5.5.18 0.000 0.040 20.07 5.5.16 0.010 0.027 20.27 5.5.15 0.003 0.033 20.32 5.5.14 0.000 0.043 20.32 5.5.13 0.003 0.043 20.35 5.5.12 0.007 0.037 20.26 5.5.11 0.003 0.043 20.31 5.5.10 0.007 0.037 20.18 5.5.9 0.003 0.033 20.24 5.5.8 0.007 0.027 20.15 5.5.7 0.010 0.033 20.00 5.5.6 0.007 0.033 20.23 5.5.5 0.003 0.033 20.12 5.5.4 0.003 0.033 20.23 5.5.3 0.007 0.030 20.14 5.5.2 0.007 0.030 20.16 5.5.1 0.010 0.030 20.20 5.5.0 0.000 0.037 20.07 5.4.45 0.010 0.043 19.39 5.4.44 0.007 0.037 19.35 5.4.43 0.003 0.040 19.29 5.4.42 0.007 0.037 19.39 5.4.41 0.010 0.033 19.23 5.4.40 0.010 0.030 18.92 5.4.39 0.003 0.037 18.80 5.4.38 0.000 0.043 19.23 5.4.37 0.000 0.037 19.23 5.4.36 0.013 0.057 19.16 5.4.35 0.003 0.033 19.07 5.4.34 0.010 0.053 18.97 5.4.32 0.000 0.043 19.04 5.4.31 0.007 0.040 18.97 5.4.30 0.003 0.037 19.12 5.4.29 0.000 0.033 19.23 5.4.28 0.003 0.043 19.07 5.4.27 0.003 0.037 18.84 5.4.26 0.003 0.043 18.91 5.4.25 0.003 0.040 19.03 5.4.24 0.003 0.040 18.97 5.4.23 0.003 0.040 18.79 5.4.22 0.007 0.030 19.04 5.4.21 0.000 0.033 19.11 5.4.20 0.017 0.020 19.05 5.4.19 0.003 0.033 18.95 5.4.18 0.003 0.030 18.83 5.4.17 0.003 0.037 18.80 5.4.16 0.003 0.030 19.14 5.4.15 0.000 0.037 19.05 5.4.14 0.007 0.027 16.34 5.4.13 0.003 0.033 16.35 5.4.12 0.000 0.033 16.34 5.4.11 0.010 0.027 16.50 5.4.10 0.003 0.030 16.50 5.4.9 0.003 0.030 16.50 5.4.8 0.000 0.033 16.27 5.4.7 0.007 0.027 16.40 5.4.6 0.007 0.027 16.47 5.4.5 0.007 0.070 16.47 5.4.4 0.010 0.067 16.39 5.4.3 0.003 0.040 16.35 5.4.2 0.003 0.033 16.25 5.4.1 0.010 0.060 16.33 5.4.0 0.010 0.073 15.85 5.3.29 0.003 0.040 14.72 5.3.28 0.007 0.033 14.54 5.3.27 0.000 0.037 14.70 5.3.26 0.007 0.033 14.56 5.3.25 0.000 0.033 14.64 5.3.24 0.000 0.033 14.64 5.3.23 0.007 0.030 14.68 5.3.22 0.017 0.017 14.61 5.3.21 0.003 0.030 14.62 5.3.20 0.000 0.040 14.50 5.3.19 0.013 0.037 14.62 5.3.18 0.010 0.023 14.62 5.3.17 0.007 0.033 14.57 5.3.16 0.003 0.030 14.60 5.3.15 0.007 0.037 14.63 5.3.14 0.010 0.067 14.60 5.3.13 0.007 0.033 14.64 5.3.12 0.007 0.067 14.61 5.3.11 0.003 0.077 14.63 5.3.10 0.000 0.057 14.04 5.3.9 0.000 0.040 14.02 5.3.8 0.007 0.030 14.11 5.3.7 0.010 0.057 13.96 5.3.6 0.010 0.067 14.10 5.3.5 0.007 0.073 14.04 5.3.4 0.003 0.043 14.01 5.3.3 0.003 0.033 13.99 5.3.2 0.007 0.040 13.70 5.3.1 0.007 0.047 13.68 5.3.0 0.000 0.063 13.59
preferences:dark mode live preview
32.94 ms | 400 KiB | 5 Q