Fatal error: Uncaught Error: Cannot use object of type User as array

This commit is contained in:
lopar 2020-08-30 03:55:53 +03:00
parent 4d98acb9f9
commit c6ec8e8084
4 changed files with 134 additions and 172 deletions

View File

@ -9,7 +9,7 @@ if (!$user->clan) {
die(err('Вы не состоите в клане!'));
}
try {
$clanRow = db::c()->query('SELECT * FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc();
$clanRow = db::c()->query('SELECT * FROM `clans` WHERE `id` = ?i', $user->clan)->fetch_assoc();
$polno = unserialize($clanRow['vozm']) ?? [];
} catch (Exception $e) {
echo "MYSQL_ERROR: Таблицы clans не существует! Вся панель — одна сплошная ошибка!";
@ -42,7 +42,7 @@ if ($kr && $kolv > 0) {
$status = 'Не хватает денег!';
}
}
if ($login && $action == 'add_member' && $polno[$user['id']][0] == 1) {
if ($login && $action == 'add_member' && $polno[$user->id][0] == 1) {
$sok = db::c()->query('SELECT id, level, clan FROM users WHERE align = 0 AND login = "?s"', $login)->fetch_assoc();
$proverka = db::c()->query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $sok['id'])->getNumRows();
if (!$proverka) {
@ -57,7 +57,7 @@ if ($login && $action == 'add_member' && $polno[$user['id']][0] == 1) {
$status = 'Не хватает денег, или персонажа не существует.';
}
}
if ($login && $action == 'remove_member' && $polno[$user['id']][0] == 1) {
if ($login && $action == 'remove_member' && $polno[$user->id][0] == 1) {
$sok = db::c()->query('SELECT id FROM users WHERE clan = "?s" AND login = "?s"', $clanRow['id'], $login)->fetch_assoc();
if ($sok['id'] != $clanRow['glava'] && $user->money >= COST_REMOVE_MEMBER) {
db::c()->query('UPDATE users SET money = money - ?i WHERE id = ?i', COST_REMOVE_MEMBER, $_SESSION['uid']);
@ -120,7 +120,7 @@ $clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `roo
Количество рейтинговых очков клана: <span
style="color: #428f21; font-size: larger;"><?= $clanRow['rating'] ?></span><br>
<?php if ($polno[$user['id']][0] == 1): ?>
<?php if ($polno[$user->id][0] == 1): ?>
<div>
<span id="add_member">
<input type="submit" onclick="use('add_member')" value="Принять в клан">
@ -135,12 +135,12 @@ $clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `roo
</div>
<?php endif; ?>
<?php if ($polno[$user['id']][1] == 1 || $clanRow['glava'] == $user['id']): ?>
<?php if ($polno[$user->id][1] == 1 || $clanRow['glava'] == $user->id): ?>
<?php if ($login && $action == 'edit_status' && $sok['id'] != $clanRow['glava']): ?>
<form method='post'>
<input placeholder='Статус' name='new_status'>
<input type="hidden" name="login" value="<?= $login ?>">
<?php if ($clanRow['glava'] == $user['id']): ?>
<?php if ($clanRow['glava'] == $user->id): ?>
<?php if ($polno[$sok['id']][0] == 1): ?>
<br><input type=checkbox name=vin checked> Может принимать/выгонять членов клана
<?php else: ?>
@ -164,7 +164,7 @@ $clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `roo
<?php endif; ?>
<?php endif; ?>
<?php if ($clanRow['glava'] == $user['id']): ?>
<?php if ($clanRow['glava'] == $user->id): ?>
<div>
<span id="change_owner">
<input type="submit" onclick="use('change_owner')" value="Сменить главу клана">

12
dig.php
View File

@ -3,7 +3,7 @@ session_start();
if (!($_SESSION['uid'] > 0)) header("Location: index.php");
require_once 'config.php';
$user = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $playerId)->fetch_assoc();
$user = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $playerId)->fetch_object();
$can_go_ch = 0;
/*if($user['id']==1258)
@ -17,17 +17,17 @@ $can_go_ch = 0;
}
}*/
if ($user['room'] != 49) {
if ($user->room != 49) {
header("Location: main.php");
die();
exit();
}
if ($user['battle'] != 0) {
if ($user->battle) {
header('location: fbattle.php');
die();
exit();
}
//проверяем ЦХ
if ($user['level'] >= 8 && $user['doblest'] >= 50) $can_go_ch = 1;
if ($user->level >= 8 && $user->doblest >= 50) $can_go_ch = 1;
//заходим в ЦХ
if ($_POST['c_haos']) {

View File

@ -7,11 +7,14 @@
*/
session_start();
if (!isset($_SESSION['uid'])) header("Location: index.php");
if (empty($_SESSION['uid'])) {
header("Location: index.php");
}
require_once 'functions.php';
if (!empty($_GET['teleport']) AND $user['admin'] == 1)
if (!empty($_GET['teleport']) and $user->admin == 1) {
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 20,`online`.`room` = 20 WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_SESSION['uid']);
}
?>
@ -23,24 +26,25 @@ if (!empty($_GET['teleport']) AND $user['admin'] == 1)
</head>
<body>
<div style="float: right;">
<?php if ($user['admin'] == 1): ?>
<?php if ($user->admin == 1): ?>
<button onclick="location.href='?teleport=1'">Телепорт на ЦП</button>
<?php endif; ?>
<input type="button" onClick="location.href='main.php';" value="Вернуться">
</div>
<h2>Особые умения</h2>
<div align=center id=hint3></div>
<?php
# ORDEN PHP
$al = db::c()->query('SELECT `accses`,`name` FROM `aligns` WHERE `align` = ?i', $user['align'])->fetch_assoc();
$al = db::c()->query('SELECT `accses`,`name` FROM `aligns` WHERE `align` = ?i', $user->align)->fetch_assoc();
$moj = expa($al['accses']);
function imp($array)
{
$str = '';
foreach ($array as $k => $v) $str .= $k . ";" . $v . ";";
foreach ($array as $k => $v) {
$str .= $k . ";" . $v . ";";
}
return $str;
}
@ -48,53 +52,62 @@ function expa($str)
{
$rarray = '';
$array = explode(";", $str);
for ($i = 0; $i <= count($array) - 2; $i = $i + 2) $rarray[$array[$i]] = $array[$i + 1];
for ($i = 0; $i <= count($array) - 2; $i = $i + 2) {
$rarray[$array[$i]] = $array[$i + 1];
}
return $rarray;
}
if (in_array($_POST['use'], array_keys($moj))) {
//echo $_GET['use'];
$abil = mysql_fetch_array(mysql_query("SELECT `abil` FROM `users` WHERE `id`='{$user['id']}';"));
$abil = db::c()->query('SELECT abil FROM users WHERE id = ?i', $user->id)->fetch_assoc();
$abil = unserialize($abil['abil']);
switch ($_POST['use']) {
case "cure150":
include("./magic/cure150.php");
break;
case "al_neut_power":
if ($abil[0] > 0 && $user['align'] == 2) {
if ($abil[0] > 0 && $user->align == 2) {
include("./magic/al_neut_power.php");
if ($outok == 1) {
$abil[0] -= 1;
mysql_query("UPDATE `users` SET `abil`='" . serialize($abil) . "' WHERE `id`='{$user['id']}';");
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
}
} elseif ($user->align != 2) {
include("./magic/al_neut_power.php");
}
} elseif ($user['align'] != 2) include("./magic/al_neut_power.php");
break;
case "ct1":
if ($abil[0] > 0 && $user['align'] == 6) {
if ($abil[0] > 0 && $user->align == 6) {
include("./magic/ct1.php");
if ($outok == 1) {
$abil[0] -= 1;
mysql_query("UPDATE `users` SET `abil`='" . serialize($abil) . "' WHERE `id`='{$user['id']}';");
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
}
} elseif ($user->align != 6) {
include("./magic/ct1.php");
}
} elseif ($user['align'] != 6) include("./magic/ct1.php");
break;
case "ct2":
if ($abil[1] > 0 && $user['align'] == 6) {
if ($abil[1] > 0 && $user->align == 6) {
include("./magic/ct2.php");
if ($outok == 1) {
$abil[1] -= 1;
mysql_query("UPDATE `users` SET `abil`='" . serialize($abil) . "' WHERE `id`='{$user['id']}';");
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
}
} elseif ($user->align != 6) {
include("./magic/ct2.php");
}
} elseif ($user['align'] != 6) include("./magic/ct2.php");
break;
case "ct3":
if ($abil[2] > 0 && $user['align'] == 6) {
if ($abil[2] > 0 && $user->align == 6) {
include("./magic/ct3.php");
if ($outok == 1) {
$abil[2] -= 1;
mysql_query("UPDATE `users` SET `abil`='" . serialize($abil) . "' WHERE `id`='{$user['id']}';");
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
}
} elseif ($user->align != 6) {
include("./magic/ct3.php");
}
} elseif ($user['align'] != 6) include("./magic/ct3.php");
break;
case "sleep":
@ -151,45 +164,53 @@ if (in_array($_POST['use'], array_keys($moj))) {
break;
case "attack_t":
include("./magic/attack_t.php");
if ($skipper == 1) /* header("Location:fbattle.php");*/
die("<script>location.href='fbattle.php';</script>");
if ($skipper == 1) {
header("Location:fbattle.php");
exit();
}
break;
case "battack":
include("./magic/ebattack.php");
break;
case "attackk_close":
if ($abil[1] > 0 && $user['align'] == 2) {
if ($abil[1] > 0 && $user->align == 2) {
include("./magic/attackk_close.php");
if ($outok == 1) {
$abil[1] -= 1;
mysql_query("UPDATE `users` SET `abil`='" . serialize($abil) . "' WHERE `id`='{$user['id']}';");
die("<script>location.href='fbattle.php';</script>");
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
header("Location:fbattle.php");
exit();
}
} else {
include("./magic/attackk_close.php");
die("<script>location.href='fbattle.php';</script>");
header("Location:fbattle.php");
exit();
}
break;
case "attackk_open":
if ($abil[1] > 0 && $user['align'] == 2) {
if ($abil[1] > 0 && $user->align == 2) {
include("./magic/attackk_open.php");
if ($outok == 1) {
$abil[2] -= 1;
mysql_query("UPDATE `users` SET `abil`='" . serialize($abil) . "' WHERE `id`='{$user['id']}';");
die("<script>location.href='fbattle.php';</script>");
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
header("Location:fbattle.php");
exit();
}
} else {
include("./magic/attackk_open.php");
die("<script>location.href='fbattle.php';</script>");
header("Location:fbattle.php");
exit();
}
break;
case "brat":
include("./magic/brat.php");
if ($skipper == 1) /* header("Location:fbattle.php"); */
die("<script>location.href='fbattle.php';</script>");
if ($skipper == 1) {
header("Location:fbattle.php");
exit();
}
break;
case "vampir":
@ -225,7 +246,6 @@ if (in_array($_POST['use'], array_keys($moj))) {
echo "<table><tr><td><br><br>";
foreach ($moj as $k => $v) {
//echo $k;
switch ($k) {
case "sleep":
$script_name = "runmagic0";
@ -410,33 +430,34 @@ foreach ($moj as $k => $v) {
$abil = db::c()->query('SELECT `abil` FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
$abil = unserialize($abil['abil']);
if ($user['align'] == 2) {
if ($k == 'al_neut_power') {
if ($abil[0] < 1) $action_ok = 0;
if ($user->align == 2) {
if ($k == 'al_neut_power' && $abil[0] < 1) {
$action_ok = 0;
}
if ($k == 'attackk_close') {
if ($abil[1] < 1) $action_ok = 0;
if ($k == 'attackk_close' && $abil[1] < 1) {
$action_ok = 0;
}
if ($k == 'attackk_open') {
if ($abil[2] < 1) $action_ok = 0;
if ($k == 'attackk_open' && $abil[2] < 1) {
$action_ok = 0;
}
}
if ($user['align'] == 6) {
if ($k == 'ct1') {
if ($abil[0] < 1) $action_ok = 0;
if ($user->align == 6) {
if ($k == 'ct1' && $abil[0] < 1) {
$action_ok = 0;
}
if ($k == 'ct2') {
if ($abil[1] < 1) $action_ok = 0;
if ($k == 'ct2' && $abil[1] < 1) {
$action_ok = 0;
}
if ($k == 'ct3') {
if ($abil[2] < 1) $action_ok = 0;
if ($k == 'ct3' && $abil[2] < 1) {
$action_ok = 0;
}
}
}
if ($action_ok > 0) print "<a onclick=\"javascript:$script_name('$magic_name','$k','target','target1') \" href='#'><img src='i/magic/" . $k . ".gif' title='" . $magic_name . "'></a>&nbsp;";
if ($action_ok > 0) {
print "<a onclick=\"javascript:$script_name('$magic_name','$k','target','target1') \" href='#'><img src='i/magic/" . $k . ".gif' title='" . $magic_name . "'></a>&nbsp;";
}
}
if ($user['align'] == 2) // Нейтралы
if ($user->align == 2) // Нейтралы
{
$abil = db::c()->query('SELECT `abil` FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
@ -448,7 +469,7 @@ if ($user['align'] == 2) // Нейтралы
echo("<img src='i/magic/attackk_open.gif' title='Кулачное закрытое нападение'> Кулачное закрытое нападение - " . $abil[2] . "<br />");
}
if ($user['align'] == 6) // Свет
if ($user->align == 6) // Свет
{
$abil = db::c()->query('SELECT `abil` FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
@ -463,78 +484,12 @@ if ($user['align'] == 6) // Свет
echo "</td></tr></table>";
#RELIKT PHP
function vip_relicts()
{
global $user;
$r = '';
if ($user['vip'] > 0 && $user['vip_time'] > time()) {
$abils = db::c()->query('SELECT `id`, `uid`, `sokr`, `zash`, `invisible`, `attack`, `bloodattack`, `sleep30`, `travmoff`, `dontattack`, `unsleep`, `pers_attack` FROM `abils_vip` WHERE `uid` = ?i', $user['id'])->fetch_assoc();
if ($abils['sokr'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=2", "target")\'><img src=\'i/sh/devastate.gif\' title=\'Сокрушение\' /></a><div class="amount">' . $abils['sokr'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/devastate.gif\' style=\'opacity: 0.3;\' title=\'Сокрушение\' /></a><div class="amount">0</div></div>';
}
if ($abils['zash'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=3", "target")\'><img src=\'i/sh/defence.gif\' title=\'Защита от оружия\' /></a><div class="amount">' . $abils['zash'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/defence.gif\' style=\'opacity: 0.3;\' title=\'Защита от оружия\' /></a><div class="amount">0</div></div>';
}
if ($abils['invisible'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=1", "target")\'><img src=\'i/sh/hidden.gif\' title=\'Невидимость\' /></a><div class="amount">' . $abils['invisible'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/hidden.gif\' style=\'opacity: 0.3;\' title=\'Невидимость\' /></a><div class="amount">0</div></div>';
}
if ($abils['attack'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=4", "target")\'><img src=\'i/sh/attack.gif\' title=\'Нападение\' /></a><div class="amount">' . $abils['attack'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/attack.gif\' style=\'opacity: 0.3;\' title=\'Нападение\' /></a><div class="amount">0</div></div>';
}
if ($abils['bloodattack'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=5", "target")\'><img src=\'i/sh/attackb.gif\' title=\'Кровавое нападение\' /></a><div class="amount">' . $abils['bloodattack'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/attackb.gif\' style=\'opacity: 0.3;\' title=\'Кровавое нападение\' /></a><div class="amount">0</div></div>';
}
if ($abils['sleep30'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=6", "target")\'><img src=\'i/sh/silence30.gif\' title=\'Заклятие молчания 30 минут\' /></a><div class="amount">' . $abils['sleep30'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/silence30.gif\' style=\'opacity: 0.3;\' title=\'Заклятие молчания 30 минут\' /></a><div class="amount">0</div></div>';
}
if ($abils['travmoff'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=7", "target")\'><img src=\'i/sh/cure3.gif\' title=\'Лечение травм\' /></a><div class="amount">' . $abils['travmoff'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/cure3.gif\' style=\'opacity: 0.3;\' title=\'Лечение травм\' /></a><div class="amount">0</div></div>';
}
if ($abils['dontattack'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=8", "target")\'><img src=\'i/magic/attack_defence.gif\' title=\'Защита от нападений\' /></a><div class="amount">' . $abils['dontattack'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/magic/attack_defence.gif\' style=\'opacity: 0.3;\' title=\'Защита от нападений\' /></a><div class="amount">0</div></div>';
}
if ($abils['unsleep'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=9", "target")\'><img src=\'i/magic/sleep_off.gif\' title=\'Снять заклятие молчания\'/></a><div class="amount">' . $abils['unsleep'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/sleep_off.gif\' style=\'opacity: 0.3;\' title=\'Снять заклятие молчания\' /></a><div class="amount">0</div></div>';
}
if ($abils['pers_attack'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?use=10", "target")\'><img src=\'i/sh/attackb.gif\' title=\'Личное Кровавое нападение\' /></a><div class="amount">' . $abils['pers_attack'] . '</div></div>';
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/attackb.gif\' style=\'opacity: 0.3;\' title=\'Личное Кровавое нападение\' /></a><div class="amount">0</div></div>';
}
} elseif ($user['vip'] == 0) {
$r = 'Вы не вип пользователь ...';
} elseif ($user['vip_time'] <= time()) {
$r = 'Вы не вип пользователь ...';
} else {
$r = 'Ошибка ...';
}
return $r;
}
function klan_relicts()
{
global $user;
$r = '';
if ($user['klan'] > 0) {
$abils = db::c()->query('SELECT `id`, `klan`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc();
if ($user->clan > 0) {
$abils = db::c()->query('SELECT `id`, `klan`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_klan` WHERE `klan` = ?i', $user->clan)->fetch_assoc();
if ($abils['sleep15'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?useds=1", "target")\'><img src=\'i/sh/silence15.gif\' title=\'Заклятие молчания 15 минут\' /></a><div class="amount">' . $abils['sleep15'] . '</div></div>';
} else {
@ -620,7 +575,7 @@ function user_relicts()
{
global $user;
$r = '';
$abils = db::c()->query('SELECT `id`, `uid`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_user` WHERE `uid` = ?i', $user['id'])->fetch_assoc();
$abils = db::c()->query('SELECT `id`, `uid`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_user` WHERE `uid` = ?i', $user->id)->fetch_assoc();
if ($abils['sleep15'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?used=1", "target")\'><img src=\'i/sh/silence15.gif\' title=\'Заклятие молчания 15 минут\' /></a><div class="amount">' . $abils['sleep15'] . '</div></div>';
} else {
@ -696,7 +651,7 @@ function user_relicts()
} else {
$r .= '<div class="item"><a href=\'javascript: void(0);\'><img src=\'i/sh/antimirror.gif\' style=\'opacity: 0.3;\' title=\'Эфирное воздействие\' /></a><div class="amount">0</div></div>';
}
if ($user['id'] == 10022 || $user['id'] == 9081) {
if ($user->admin) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "main.php?edit=1&use=3651943", "target")\'><img src=\'i/sh/spell_luck.gif\' title=\'Благословление Мусорщика\' /></a><div class="amount">~</div></div>';
}
return $r;
@ -794,9 +749,9 @@ function show_byu($type)
{
global $user;
$type = $type + 20;
if ($user['klan'] != '') {
$clan = db::c()->query('SELECT `id`, `glava` FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc();
if ($clan['glava'] == $user['id']) {
if ($user->clan) {
$clan = db::c()->query('SELECT `id`, `glava` FROM `clans` WHERE `id` = ?i', $user->clan)->fetch_assoc();
if ($clan['glava'] == $user->id) {
$r = '<div style="text-align: center;"><a href="javascript:void(0);" class="byu_klan" id="' . $type . '">купить 1 шт.</a></div>';
} else {
$r = '<div style="text-align: center;"><a href="javascript:void(0);">Вы не глава</a></div>';
@ -807,15 +762,21 @@ function show_byu($type)
return $r;
}
$is_ = db::c()->query('SELECT `id` FROM `abils_user` WHERE `uid` = ?i', $user['id'])->fetch_assoc();
if (empty($is_['id'])) db::c()->query('INSERT INTO `abils_user` (`uid`) VALUES (?i)', $user['id']);
$is_ = db::c()->query('SELECT `id` FROM `abils_user` WHERE `uid` = ?i', $user->id)->fetch_assoc();
if (empty($is_['id'])) {
db::c()->query('INSERT INTO `abils_user` (`uid`) VALUES (?i)', $user->id);
}
$is_ = db::c()->query('SELECT `id` FROM `abils_vip` WHERE `uid` = ?i', $user['id'])->fetch_assoc();
if (empty($is_['id'])) db::c()->query('INSERT INTO `abils_vip` (`uid`) VALUES (?i)', $user['id']);
$is_ = db::c()->query('SELECT `id` FROM `abils_vip` WHERE `uid` = ?i', $user->id)->fetch_assoc();
if (empty($is_['id'])) {
db::c()->query('INSERT INTO `abils_vip` (`uid`) VALUES (?i)', $user->id);
}
if (empty($user['klan'])) {
$is_ = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc();
if (empty($is_['id'])) db::c()->query('INSERT INTO `abils_klan` (`klan`) VALUES (?i)', $user['klan']);
if (empty($user->clan)) {
$is_ = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user->clan)->fetch_assoc();
if (empty($is_['id'])) {
db::c()->query('INSERT INTO `abils_klan` (`klan`) VALUES (?i)', $user->clan);
}
}
$bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['uid'])->fetch_assoc();
@ -840,12 +801,6 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
<?= klan_relicts(); ?>
</fieldset>
</div>
<div style="padding-top: 15px;">
<fieldset style="width: 400px;">
<legend>Vip :</legend>
<?= vip_relicts(); ?>
</fieldset>
</div>
<div style="padding-top: 13px; padding-bottom: 13px;">
<fieldset style="width: 400px;">
<legend>Счёт</legend>
@ -1126,7 +1081,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
$.ajax({
type: 'POST',
url: 'fancy/buy.php',
data: "type=" + type + "&user="+<?=$user['id'];?>+"",
data: "type=" + type + "&user=" + <?= $user->id ?> + "",
success: function (data) {
if (data === 'success') {
$(".child").html('<b style="color: Red;">' + types_user[type - 1] + ' успешно куплено</b>');
@ -1146,7 +1101,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
$.ajax({
type: 'POST',
url: 'fancy/buy_klan.php',
data: "type=" + type + "&user="+<?=$user['id'];?>+"",
data: "type=" + type + "&user=" + <?= $user->id ?> + "",
success: function (data) {
if (data === 'success') {
$(".child").html('<b style="color: Red;">' + types_klan[type - 21] + ' успешно куплено</b>');
@ -1162,5 +1117,3 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
});
});
</script>
<?php

View File

@ -1,20 +1,22 @@
<?php
session_start();
if (!isset($_SESSION['uid'])) {
if (empty($_SESSION['uid'])) {
header('Location: /index.php');
die();
exit();
}
include_once('functions.php');
if ($user['battle'] > 0) {
if ($user->battle) {
header('Location: /fbattle.php');
die();
exit();
}
use Krugozor\Database\Mysql\Mysql as Mysql;
$db = Mysql::create("192.168.20.100", "battles", "bottle-neck-horse")
->setDatabaseName("battles")
->setCharset("utf8");
define('INFO_CHAR_LIMIT', 1500);
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$oldpsw = filter_input(INPUT_POST, 'oldpsw', FILTER_SANITIZE_SPECIAL_CHARS);
$newpsw = filter_input(INPUT_POST, 'newpsw', FILTER_SANITIZE_SPECIAL_CHARS);
@ -29,28 +31,35 @@ if ($name || $color || $hobbie) {
$simbolcount = strlen($hobbie);
switch ($color) {
case 1: $color = 'blue'; break;
case 2: $color = 'green'; break;
default: $color = 'black'; break;
case 1:
$color = 'blue';
break;
case 2:
$color = 'green';
break;
default:
$color = 'black';
break;
}
if ($simbolcount > 1500) {
err('Максимальная длинна поля Хобби: 1500 символов!');
if ($simbolcount > INFO_CHAR_LIMIT) {
err('Максимальная длинна поля Хобби: ' . INFO_CHAR_LIMIT . ' символов!');
} else {
//db::c()->query('UPDATE `users` SET `realname` = "?s", `color` = "?s", `info` = "?s" WHERE `id` = ?i', $name, $color, $hobbie, $user['id']);
$values = ['realname'=>$name, 'color'=>$color, 'info'=>$hobbie];
$values = ['realname' => $name, 'color' => $color, 'info' => $hobbie];
$db->query('UPDATE users SET ?As WHERE id = ?i', $values, $user['id']);
}
}
if ($oldpsw && $newpsw){
if (password_verify($oldpsw, $user['pass'])){
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw,PASSWORD_DEFAULT), $user['id']);
} else err('Неверный текущий пароль!');
if ($oldpsw && $newpsw) {
if (password_verify($oldpsw, $user['pass'])) {
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw, PASSWORD_DEFAULT), $user['id']);
} else {
err('Неверный текущий пароль!');
}
}
?>
<!doctype html>
<html>
<html lang="ru">
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="css/main.css">