From c6ec8e8084d65dd788fcee958500a29e438114a0 Mon Sep 17 00:00:00 2001 From: lopar Date: Sun, 30 Aug 2020 03:55:53 +0300 Subject: [PATCH] Fatal error: Uncaught Error: Cannot use object of type User as array --- clan.php | 14 +-- dig.php | 12 +-- user_abilities.php | 239 ++++++++++++++++++--------------------------- user_anketa.php | 41 +++++--- 4 files changed, 134 insertions(+), 172 deletions(-) diff --git a/clan.php b/clan.php index f69d208..785decb 100644 --- a/clan.php +++ b/clan.php @@ -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 Количество рейтинговых очков клана:
- + id][0] == 1): ?>
@@ -135,12 +135,12 @@ $clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `roo
- + id][1] == 1 || $clanRow['glava'] == $user->id): ?>
- + id): ?>
Может принимать/выгонять членов клана @@ -164,7 +164,7 @@ $clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `roo - + id): ?>
diff --git a/dig.php b/dig.php index cffa3a6..87246aa 100644 --- a/dig.php +++ b/dig.php @@ -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']) { diff --git a/user_abilities.php b/user_abilities.php index 4ebee70..7df3c73 100644 --- a/user_abilities.php +++ b/user_abilities.php @@ -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)
- + admin == 1): ?>

Особые умения

- 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(""); + 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(""); + 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(""); + 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(""); + 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(""); + header("Location:fbattle.php"); + exit(); } break; case "brat": include("./magic/brat.php"); - if ($skipper == 1) /* header("Location:fbattle.php"); */ - die(""); + if ($skipper == 1) { + header("Location:fbattle.php"); + exit(); + } break; case "vampir": @@ -225,7 +246,6 @@ if (in_array($_POST['use'], array_keys($moj))) { echo "


"; 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 " "; + if ($action_ok > 0) { + print " "; + } } -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(" Кулачное закрытое нападение - " . $abil[2] . "
"); } -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 "
"; #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 .= '
' . $abils['sokr'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['zash'] > 0) { - $r .= '
' . $abils['zash'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['invisible'] > 0) { - $r .= '
' . $abils['invisible'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['attack'] > 0) { - $r .= '
' . $abils['attack'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['bloodattack'] > 0) { - $r .= '
' . $abils['bloodattack'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['sleep30'] > 0) { - $r .= '
' . $abils['sleep30'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['travmoff'] > 0) { - $r .= '
' . $abils['travmoff'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['dontattack'] > 0) { - $r .= '
' . $abils['dontattack'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['unsleep'] > 0) { - $r .= '
' . $abils['unsleep'] . '
'; - } else { - $r .= '
0
'; - } - if ($abils['pers_attack'] > 0) { - $r .= '
' . $abils['pers_attack'] . '
'; - } else { - $r .= '
0
'; - } - } 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 .= '
' . $abils['sleep15'] . '
'; } 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 .= '
' . $abils['sleep15'] . '
'; } else { @@ -696,7 +651,7 @@ function user_relicts() } else { $r .= '
0
'; } - if ($user['id'] == 10022 || $user['id'] == 9081) { + if ($user->admin) { $r .= '
~
'; } 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 = '
купить 1 шт.
'; } else { $r = '
Вы не глава
'; @@ -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
-
-
- Vip : - -
-
Счёт @@ -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="++"", + data: "type=" + type + "&user=" + id ?> + "", success: function (data) { if (data === 'success') { $(".child").html('' + types_user[type - 1] + ' успешно куплено'); @@ -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="++"", + data: "type=" + type + "&user=" + id ?> + "", success: function (data) { if (data === 'success') { $(".child").html('' + types_klan[type - 21] + ' успешно куплено'); @@ -1161,6 +1116,4 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u }); }); }); - - - \ No newline at end of file diff --git a/user_anketa.php b/user_anketa.php index 8446519..c9852fc 100644 --- a/user_anketa.php +++ b/user_anketa.php @@ -1,20 +1,22 @@ 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('Неверный текущий пароль!'); + } } ?> - +