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

View File

@ -7,11 +7,14 @@
*/ */
session_start(); session_start();
if (!isset($_SESSION['uid'])) header("Location: index.php"); if (empty($_SESSION['uid'])) {
header("Location: index.php");
}
require_once 'functions.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']); 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> </head>
<body> <body>
<div style="float: right;"> <div style="float: right;">
<?php if ($user['admin'] == 1): ?> <?php if ($user->admin == 1): ?>
<button onclick="location.href='?teleport=1'">Телепорт на ЦП</button> <button onclick="location.href='?teleport=1'">Телепорт на ЦП</button>
<?php endif; ?> <?php endif; ?>
<input type="button" onClick="location.href='main.php';" value="Вернуться"> <input type="button" onClick="location.href='main.php';" value="Вернуться">
</div> </div>
<h2>Особые умения</h2> <h2>Особые умения</h2>
<div align=center id=hint3></div> <div align=center id=hint3></div>
<?php <?php
# ORDEN 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']); $moj = expa($al['accses']);
function imp($array) function imp($array)
{ {
$str = ''; $str = '';
foreach ($array as $k => $v) $str .= $k . ";" . $v . ";"; foreach ($array as $k => $v) {
$str .= $k . ";" . $v . ";";
}
return $str; return $str;
} }
@ -48,53 +52,62 @@ function expa($str)
{ {
$rarray = ''; $rarray = '';
$array = explode(";", $str); $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; return $rarray;
} }
if (in_array($_POST['use'], array_keys($moj))) { if (in_array($_POST['use'], array_keys($moj))) {
//echo $_GET['use']; $abil = db::c()->query('SELECT abil FROM users WHERE id = ?i', $user->id)->fetch_assoc();
$abil = mysql_fetch_array(mysql_query("SELECT `abil` FROM `users` WHERE `id`='{$user['id']}';"));
$abil = unserialize($abil['abil']); $abil = unserialize($abil['abil']);
switch ($_POST['use']) { switch ($_POST['use']) {
case "cure150": case "cure150":
include("./magic/cure150.php"); include("./magic/cure150.php");
break; break;
case "al_neut_power": case "al_neut_power":
if ($abil[0] > 0 && $user['align'] == 2) { if ($abil[0] > 0 && $user->align == 2) {
include("./magic/al_neut_power.php"); include("./magic/al_neut_power.php");
if ($outok == 1) { if ($outok == 1) {
$abil[0] -= 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; break;
case "ct1": case "ct1":
if ($abil[0] > 0 && $user['align'] == 6) { if ($abil[0] > 0 && $user->align == 6) {
include("./magic/ct1.php"); include("./magic/ct1.php");
if ($outok == 1) { if ($outok == 1) {
$abil[0] -= 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; break;
case "ct2": case "ct2":
if ($abil[1] > 0 && $user['align'] == 6) { if ($abil[1] > 0 && $user->align == 6) {
include("./magic/ct2.php"); include("./magic/ct2.php");
if ($outok == 1) { if ($outok == 1) {
$abil[1] -= 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; break;
case "ct3": case "ct3":
if ($abil[2] > 0 && $user['align'] == 6) { if ($abil[2] > 0 && $user->align == 6) {
include("./magic/ct3.php"); include("./magic/ct3.php");
if ($outok == 1) { if ($outok == 1) {
$abil[2] -= 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; break;
case "sleep": case "sleep":
@ -151,45 +164,53 @@ if (in_array($_POST['use'], array_keys($moj))) {
break; break;
case "attack_t": case "attack_t":
include("./magic/attack_t.php"); include("./magic/attack_t.php");
if ($skipper == 1) /* header("Location:fbattle.php");*/ if ($skipper == 1) {
die("<script>location.href='fbattle.php';</script>"); header("Location:fbattle.php");
exit();
}
break; break;
case "battack": case "battack":
include("./magic/ebattack.php"); include("./magic/ebattack.php");
break; break;
case "attackk_close": case "attackk_close":
if ($abil[1] > 0 && $user['align'] == 2) { if ($abil[1] > 0 && $user->align == 2) {
include("./magic/attackk_close.php"); include("./magic/attackk_close.php");
if ($outok == 1) { if ($outok == 1) {
$abil[1] -= 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);
die("<script>location.href='fbattle.php';</script>"); header("Location:fbattle.php");
exit();
} }
} else { } else {
include("./magic/attackk_close.php"); include("./magic/attackk_close.php");
die("<script>location.href='fbattle.php';</script>"); header("Location:fbattle.php");
exit();
} }
break; break;
case "attackk_open": case "attackk_open":
if ($abil[1] > 0 && $user['align'] == 2) { if ($abil[1] > 0 && $user->align == 2) {
include("./magic/attackk_open.php"); include("./magic/attackk_open.php");
if ($outok == 1) { if ($outok == 1) {
$abil[2] -= 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);
die("<script>location.href='fbattle.php';</script>"); header("Location:fbattle.php");
exit();
} }
} else { } else {
include("./magic/attackk_open.php"); include("./magic/attackk_open.php");
die("<script>location.href='fbattle.php';</script>"); header("Location:fbattle.php");
exit();
} }
break; break;
case "brat": case "brat":
include("./magic/brat.php"); include("./magic/brat.php");
if ($skipper == 1) /* header("Location:fbattle.php"); */ if ($skipper == 1) {
die("<script>location.href='fbattle.php';</script>"); header("Location:fbattle.php");
exit();
}
break; break;
case "vampir": case "vampir":
@ -225,7 +246,6 @@ if (in_array($_POST['use'], array_keys($moj))) {
echo "<table><tr><td><br><br>"; echo "<table><tr><td><br><br>";
foreach ($moj as $k => $v) { foreach ($moj as $k => $v) {
//echo $k;
switch ($k) { switch ($k) {
case "sleep": case "sleep":
$script_name = "runmagic0"; $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 = db::c()->query('SELECT `abil` FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
$abil = unserialize($abil['abil']); $abil = unserialize($abil['abil']);
if ($user['align'] == 2) { if ($user->align == 2) {
if ($k == 'al_neut_power') { if ($k == 'al_neut_power' && $abil[0] < 1) {
if ($abil[0] < 1) $action_ok = 0; $action_ok = 0;
} }
if ($k == 'attackk_close') { if ($k == 'attackk_close' && $abil[1] < 1) {
if ($abil[1] < 1) $action_ok = 0; $action_ok = 0;
} }
if ($k == 'attackk_open') { if ($k == 'attackk_open' && $abil[2] < 1) {
if ($abil[2] < 1) $action_ok = 0; $action_ok = 0;
} }
} }
if ($user['align'] == 6) { if ($user->align == 6) {
if ($k == 'ct1') { if ($k == 'ct1' && $abil[0] < 1) {
if ($abil[0] < 1) $action_ok = 0; $action_ok = 0;
} }
if ($k == 'ct2') { if ($k == 'ct2' && $abil[1] < 1) {
if ($abil[1] < 1) $action_ok = 0; $action_ok = 0;
} }
if ($k == 'ct3') { if ($k == 'ct3' && $abil[2] < 1) {
if ($abil[2] < 1) $action_ok = 0; $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(); $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 />"); 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(); $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>"; echo "</td></tr></table>";
#RELIKT PHP #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() function klan_relicts()
{ {
global $user; global $user;
$r = ''; $r = '';
if ($user['klan'] > 0) { 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['klan'])->fetch_assoc(); $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) { 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>'; $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 { } else {
@ -620,7 +575,7 @@ function user_relicts()
{ {
global $user; global $user;
$r = ''; $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) { 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>'; $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 { } else {
@ -696,7 +651,7 @@ function user_relicts()
} else { } 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>'; $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>'; $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; return $r;
@ -794,9 +749,9 @@ function show_byu($type)
{ {
global $user; global $user;
$type = $type + 20; $type = $type + 20;
if ($user['klan'] != '') { if ($user->clan) {
$clan = db::c()->query('SELECT `id`, `glava` FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc(); $clan = db::c()->query('SELECT `id`, `glava` FROM `clans` WHERE `id` = ?i', $user->clan)->fetch_assoc();
if ($clan['glava'] == $user['id']) { if ($clan['glava'] == $user->id) {
$r = '<div style="text-align: center;"><a href="javascript:void(0);" class="byu_klan" id="' . $type . '">купить 1 шт.</a></div>'; $r = '<div style="text-align: center;"><a href="javascript:void(0);" class="byu_klan" id="' . $type . '">купить 1 шт.</a></div>';
} else { } else {
$r = '<div style="text-align: center;"><a href="javascript:void(0);">Вы не глава</a></div>'; $r = '<div style="text-align: center;"><a href="javascript:void(0);">Вы не глава</a></div>';
@ -807,15 +762,21 @@ function show_byu($type)
return $r; return $r;
} }
$is_ = db::c()->query('SELECT `id` FROM `abils_user` WHERE `uid` = ?i', $user['id'])->fetch_assoc(); $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']); 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(); $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($is_['id'])) {
db::c()->query('INSERT INTO `abils_vip` (`uid`) VALUES (?i)', $user->id);
}
if (empty($user['klan'])) { if (empty($user->clan)) {
$is_ = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc(); $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['klan']); 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(); $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(); ?> <?= klan_relicts(); ?>
</fieldset> </fieldset>
</div> </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;"> <div style="padding-top: 13px; padding-bottom: 13px;">
<fieldset style="width: 400px;"> <fieldset style="width: 400px;">
<legend>Счёт</legend> <legend>Счёт</legend>
@ -1126,7 +1081,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'fancy/buy.php', url: 'fancy/buy.php',
data: "type=" + type + "&user="+<?=$user['id'];?>+"", data: "type=" + type + "&user=" + <?= $user->id ?> + "",
success: function (data) { success: function (data) {
if (data === 'success') { if (data === 'success') {
$(".child").html('<b style="color: Red;">' + types_user[type - 1] + ' успешно куплено</b>'); $(".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({ $.ajax({
type: 'POST', type: 'POST',
url: 'fancy/buy_klan.php', url: 'fancy/buy_klan.php',
data: "type=" + type + "&user="+<?=$user['id'];?>+"", data: "type=" + type + "&user=" + <?= $user->id ?> + "",
success: function (data) { success: function (data) {
if (data === 'success') { if (data === 'success') {
$(".child").html('<b style="color: Red;">' + types_klan[type - 21] + ' успешно куплено</b>'); $(".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> </script>
<?php

View File

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