Code clean. Убираем идиотские ошибки.

This commit is contained in:
Igor Barkov (iwork) 2020-09-30 15:52:51 +03:00
parent f6b469ddef
commit 733d1cf87b
4 changed files with 16 additions and 21 deletions

View File

@ -3,31 +3,28 @@ session_start();
if (!isset($_SESSION['uid'])) { if (!isset($_SESSION['uid'])) {
exit; exit;
} }
include('config.php'); require_once "functions.php";
include('functions.php');
if ($user['klan'] == '') { if (empty($user->clan)) {
exit; exit;
} }
$is_now = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc(); $is_now = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc();
$clan = db::c()->query('SELECT `glava` FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc(); $clan = db::c()->query('SELECT `glava` FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc();
$cost = array(1, 2, 10, 0.50, 0.80, 1, 1, 0.10, 0.20, 4, 0.02, 20, 10, 1, 1); $cost = [1, 2, 10, 0.50, 0.80, 1, 1, 0.10, 0.20, 4, 0.02, 20, 10, 1, 1];
$mag = array('sleep15', 'sleep30', 'closebattle', 'heal20', 'heal35', 'heal50', 'travmoff', 'attack', 'bloodattack', 'death', 'comment', 'openbattle', 'reamdeath', 'clone', 'unclone'); $mag = ['sleep15', 'sleep30', 'closebattle', 'heal20', 'heal35', 'heal50', 'travmoff', 'attack', 'bloodattack', 'death', 'comment', 'openbattle', 'reamdeath', 'clone', 'unclone'];
function add_klan_abil($ab, $cost) function add_klan_abil($ab, $cost)
{ {
global $user, $banks; global $user, $banks;
$clan = mysql_fetch_array(mysql_query('SELECT `id`, `glava` FROM `clans` WHERE `id` = "' . $user['klan'] . '" LIMIT 1')); $clan = mysql_fetch_array(mysql_query('SELECT `id`, `glava` FROM `clans` WHERE `id` = "' . $user['klan'] . '"'));
if (isset($ab)) { if (isset($ab && $banks['ekr'] >= $cost && $clan['glava'] == $user['id'])) {
if ($banks['ekr'] >= $cost && $clan['glava'] == $user['id']) { $isset = mysql_fetch_array(mysql_query('SELECT `id`, `' . $ab . '` FROM `abils_klan` WHERE `klan` = "' . $user['klan'] . '"'));
$isset = mysql_fetch_array(mysql_query('SELECT `id`, `' . $ab . '` FROM `abils_klan` WHERE `klan` = "' . $user['klan'] . '" LIMIT 1'));
$isset[$ab] += 1; $isset[$ab] += 1;
mysql_query('UPDATE `abils_klan` SET `' . $ab . '` = "' . $isset[$ab] . '" WHERE `klan` = "' . $user['klan'] . '" LIMIT 1'); mysql_query('UPDATE `abils_klan` SET `' . $ab . '` = "' . $isset[$ab] . '" WHERE `klan` = "' . $user['klan'] . '"');
$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;
} }
@ -39,7 +36,7 @@ if (isset($_POST['type'], $_POST['user'])) {
if ($banks['ekr'] >= $price && $user['id'] == $clan['glava']) { if ($banks['ekr'] >= $price && $user['id'] == $clan['glava']) {
if (isset($is_now['id'])) { if (isset($is_now['id'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
if (add_klan_abil($abil, $price) == true) { if (add_klan_abil($abil, $price)) {
echo 'success'; echo 'success';
} else { } else {
echo 'Error'; echo 'Error';

2
ch.php
View File

@ -434,7 +434,7 @@ if (isset($_GET['online']) && $_GET['online'] != null) {
$_GET['text'] = preg_replace('/private \[klan-([a-zA-Z]*)\]/', '', $_GET['text']); $_GET['text'] = preg_replace('/private \[klan-([a-zA-Z]*)\]/', '', $_GET['text']);
if ($user['klan'] == '') { if (empty($user->clan)) {
$_GET['text'] = str_replace('private [klan]', '', $_GET['text']); $_GET['text'] = str_replace('private [klan]', '', $_GET['text']);
$_GET['text'] = str_replace('private [klan]', 'private [klan-' . $user['klan'] . ']', $_GET['text']); $_GET['text'] = str_replace('private [klan]', 'private [klan-' . $user['klan'] . ']', $_GET['text']);
} else { } else {

View File

@ -1,8 +1,7 @@
<? <?
session_start(); session_start();
if(!isset($_SESSION['uid'])) { header('Location: index.php'); exit; } if(!isset($_SESSION['uid'])) { header('Location: index.php'); exit; }
include('config.php'); require_once "functions.php";
include('functions.php');
$hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "'.$user['id'].'" LIMIT 1')); $hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "'.$user['id'].'" LIMIT 1'));
$base = array(1 => array(8, 16, 24, 32), 2 => array(15, 30, 45, 60), 3 => array(25, 50, 75, 100), 4 => array(40, 80, 120, 160)); $base = array(1 => array(8, 16, 24, 32), 2 => array(15, 30, 45, 60), 3 => array(25, 50, 75, 100), 4 => array(40, 80, 120, 160));

View File

@ -1,8 +1,7 @@
<?php <?php
session_start(); session_start();
if(!isset($_SESSION['uid'])) { header('Location: index.php'); exit; } if(!isset($_SESSION['uid'])) { header('Location: index.php'); exit; }
include('config.php'); require_once "functions.php";
include('functions.php');
$d = mysql_fetch_array(mysql_query("SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `setsale` = 0")); $d = mysql_fetch_array(mysql_query("SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `setsale` = 0"));
$in = mysql_fetch_array(mysql_query('SELECT COUNT(*) AS `cnt` FROM `inventory` WHERE `owner` = "-101'.$user['id'].'"')); $in = mysql_fetch_array(mysql_query('SELECT COUNT(*) AS `cnt` FROM `inventory` WHERE `owner` = "-101'.$user['id'].'"'));