Code clean.

This commit is contained in:
Igor Barkov (iwork) 2020-09-30 15:48:53 +03:00
parent 2fe8b04d18
commit f6b469ddef

12
buy.php
View File

@ -1,9 +1,11 @@
<?php <?php
//Покупка абилок? Тут?! //Покупка абилок? Тут?!
session_start(); session_start();
if (!isset($_SESSION['uid'])) exit; if (empty($_SESSION['uid'])) {
header('Location: Index.php');
exit;
}
include('config.php'); include('config.php');
#include('functions.php');
$is_now = db::c()->query('SELECT `id`, `uid` FROM `abils_user` WHERE `uid` = ?i', $user['id'])->fetch_assoc(); $is_now = db::c()->query('SELECT `id`, `uid` FROM `abils_user` WHERE `uid` = ?i', $user['id'])->fetch_assoc();
function add_user_abil($ab, $cost) function add_user_abil($ab, $cost)
@ -12,9 +14,9 @@ function add_user_abil($ab, $cost)
if (isset($ab) && $banks['ekr'] >= $cost) { if (isset($ab) && $banks['ekr'] >= $cost) {
$isset = mysql_fetch_array(mysql_query('SELECT `id`, `' . $ab . '` FROM `abils_user` WHERE `uid` = "' . $user['id'] . '" LIMIT 1')); $isset = mysql_fetch_array(mysql_query('SELECT `id`, `' . $ab . '` FROM `abils_user` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
$isset[$ab] += 1; $isset[$ab] += 1;
mysql_query('UPDATE `abils_user` SET `' . $ab . '` = "' . $isset[$ab] . '" WHERE `uid` = "' . $user['id'] . '" LIMIT 1'); mysql_query('UPDATE `abils_user` SET `' . $ab . '` = "' . $isset[$ab] . '" WHERE `uid` = "' . $user['id'] . '"');
$banks['ekr'] -= $cost; $banks['ekr'] -= $cost;
mysql_query('UPDATE `bank` SET `ekr` = "' . $banks['ekr'] . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1'); mysql_query('UPDATE `bank` SET `ekr` = "' . $banks['ekr'] . '" WHERE `id` = "' . $user['id'] . '"');
return true; return true;
} }
return false; return false;
@ -31,7 +33,7 @@ if (isset($_POST['type'], $_POST['user'])) {
if ($banks['ekr'] >= $price) { if ($banks['ekr'] >= $price) {
if (isset($is_now['id'])) { if (isset($is_now['id'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
if (add_user_abil($abil, $price) == true) { if (add_user_abil($abil, $price)) {
echo 'success'; echo 'success';
} else { } else {
echo 'Error'; echo 'Error';