2018-01-29 19:24:30 +00:00
|
|
|
|
<?php
|
2020-09-30 12:52:51 +00:00
|
|
|
|
require_once "functions.php";
|
2018-01-29 19:24:30 +00:00
|
|
|
|
|
2021-02-01 16:42:52 +00:00
|
|
|
|
if (empty($user->getClan())) {
|
2020-09-30 12:01:33 +00:00
|
|
|
|
exit;
|
2018-01-29 19:24:30 +00:00
|
|
|
|
}
|
2019-01-09 21:12:57 +00:00
|
|
|
|
$is_now = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc();
|
2018-01-29 19:24:30 +00:00
|
|
|
|
$clan = db::c()->query('SELECT `glava` FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc();
|
2020-09-30 12:52:51 +00:00
|
|
|
|
$cost = [1, 2, 10, 0.50, 0.80, 1, 1, 0.10, 0.20, 4, 0.02, 20, 10, 1, 1];
|
|
|
|
|
$mag = ['sleep15', 'sleep30', 'closebattle', 'heal20', 'heal35', 'heal50', 'travmoff', 'attack', 'bloodattack', 'death', 'comment', 'openbattle', 'reamdeath', 'clone', 'unclone'];
|
2018-01-29 19:24:30 +00:00
|
|
|
|
|
2018-07-02 15:35:25 +00:00
|
|
|
|
function add_klan_abil($ab, $cost)
|
|
|
|
|
{
|
|
|
|
|
global $user, $banks;
|
2020-09-30 12:52:51 +00:00
|
|
|
|
$clan = mysql_fetch_array(mysql_query('SELECT `id`, `glava` FROM `clans` WHERE `id` = "' . $user['klan'] . '"'));
|
2020-09-30 22:12:53 +00:00
|
|
|
|
if (isset($ab) && $banks['ekr'] >= $cost && $clan['glava'] == $user['id']) {
|
2020-09-30 12:52:51 +00:00
|
|
|
|
$isset = mysql_fetch_array(mysql_query('SELECT `id`, `' . $ab . '` FROM `abils_klan` WHERE `klan` = "' . $user['klan'] . '"'));
|
|
|
|
|
$isset[$ab] += 1;
|
|
|
|
|
mysql_query('UPDATE `abils_klan` SET `' . $ab . '` = "' . $isset[$ab] . '" WHERE `klan` = "' . $user['klan'] . '"');
|
|
|
|
|
$banks['ekr'] -= $cost;
|
|
|
|
|
mysql_query('UPDATE `bank` SET `ekr` = "' . $banks['ekr'] . '" WHERE `id` = "' . $user['id'] . '"');
|
|
|
|
|
return true;
|
2018-07-02 15:35:25 +00:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 19:24:30 +00:00
|
|
|
|
if (isset($_POST['type'], $_POST['user'])) {
|
|
|
|
|
if (isset($user['id'])) {
|
|
|
|
|
$price = $cost[$_POST['type'] - 21];
|
|
|
|
|
$abil = $mag[$_POST['type'] - 21];
|
|
|
|
|
if (isset($banks['id'])) {
|
|
|
|
|
if ($banks['ekr'] >= $price && $user['id'] == $clan['glava']) {
|
|
|
|
|
if (isset($is_now['id'])) {
|
|
|
|
|
if ($user['battle'] == 0) {
|
2020-09-30 12:52:51 +00:00
|
|
|
|
if (add_klan_abil($abil, $price)) {
|
2018-01-29 19:24:30 +00:00
|
|
|
|
echo 'success';
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Error';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Не в бою ...';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo 'NULL';
|
|
|
|
|
}
|
|
|
|
|
} elseif ($user['id'] != $clan['glava']) {
|
|
|
|
|
echo 'Вы не глава клана';
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Не хватает средств';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo '<small>Выберите счёт в банке</small>';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo "Вы не авторизированы ...";
|
|
|
|
|
}
|
|
|
|
|
}
|