game/autopay.php

97 lines
3.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
date_default_timezone_set('Europe/Moscow');
$c = [
/* MySQL База данных */
'db_name' => 'pay_operations', //Таблица в которую заносятся данные
'db_host' => 'localhost',
'db_user' => 'newcom1_abk',
'db_pass' => '4nWYsIM[c?}P',
'db_base' => 'newcom1_abk',
/* Настройки платежей
'ip_list' => array('127,0,0,1,188.166.34.68,136.243.38.147,136.243.38.149,136.243.38.150,136.243.38.151,136.243.38.189,88.198.88.98'), //Указывать через запятую (Разрешенные IP)
'key' => 'qtzl0igb', //gamedealer key
'id' => '65643' //ID проекта*/
];
function connect_db($c)
{
$db = mysql_connect($c['db_host'], $c['db_user'], $c['db_pass']) or die('Ошибка подключения к MySQL серверу!');
mysql_select_db($c['db_base'], $db) or die('Ошибка подключения к базе данных!');
mysql_query('SET NAMES utf8mb4');
}
//MERCHANT_ORDER_ID=142&P_PHONE=380688028300&P_EMAIL=evhenii_kula%40mail.ru&CUR_ID=94&AMOUNT=90&MERCHANT_ID=65643&SIGN=c0fc70d5446614597d44ff13f2c7a6a5&intid=29728441
/*
MERCHANT_ORDER_ID
P_PHONE
P_EMAIL
CUR_ID
AMOUNT
MERCHANT_ID
SIGN
intid
*/
connect_db($c);
$nick = mysql_fetch_array(
mysql_query('SELECT * FROM `pay_operation` WHERE `id` = "' . $_POST['MERCHANT_ORDER_ID'] . '" LIMIT 1')
);
$user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $nick['uid'] . '" LIMIT 1'));
if (isset ($_POST['MERCHANT_ORDER_ID'])) {
if ($nick['good'] != 0) {
echo "Уже начисленно";
} else {
mysql_query(
'UPDATE `users` SET `money2` = `money2` + ' . $nick['ekr'] . ' WHERE `id` = "' . $nick['uid'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `pay_operation` SET `good` = "' . time(
) . '" WHERE `id` = "' . $_POST['MERCHANT_ORDER_ID'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `users` SET `catch` = `catch` + ' . $nick['ekr'] . ' WHERE `id` = "' . $nick['uid'] . '" LIMIT 1'
);
$cmsg = new ChatMessage();
$cmsg->setCity($user['city']);
$cmsg->setRoom($user['room']);
$cmsg->setLogin('Банкир');
$cmsg->setTo($user['login']);
$cmsg->setText("На Ваш игровой счет зачислено {$nick['ekr']} екр. Благодарим Вас за покупку!");
$cmsg->setType(5);
(new Chat())->sendMsg($cmsg);
if ($nick['ref'] != 0) {
$refecr = round(($nick['ekr'] / 10));
mysql_query(
'UPDATE `users` SET `money2` = `money2` + ' . $refecr . ' WHERE `id` = "' . $nick['ref'] . '" LIMIT 1'
);
$referal = mysql_fetch_array(
mysql_query('SELECT * FROM `users` WHERE `id` = "' . $nick['ref'] . '" LIMIT 1')
);
$cmsg = new ChatMessage();
$cmsg->setCity($referal['city']);
$cmsg->setRoom($referal['room']);
$cmsg->setLogin('Банкир');
$cmsg->setTo($referal['login']);
$cmsg->setText("На Ваш игровой счет зачислено $refecr екр, благодаря вашему рефералу {$user['login']}!");
$cmsg->setType(5);
(new Chat())->sendMsg($cmsg);
}
echo "Покупател: " . $user['login'] . " | ID: " . $nick['uid'] . " | Сумма: " . $nick['ekr'] . " | ID операции: " . $_POST['MERCHANT_ORDER_ID'] . "<br>";
if (isset ($referal['id'])) {
echo "Реферал(тот кто привел): " . $referal['login'] . " | ID: " . $referal['id'] . " | Сумма: " . $refecr . "<br>";
} else {
echo "Пользователь реферал не найден!!";
}
}
} else {
echo "Покупатель не указан!";
}
?>