locations-bugs #17

Merged
lopar merged 12 commits from locations-bugs into master 2020-10-28 20:25:45 +00:00
161 changed files with 649 additions and 581 deletions

View File

@ -7,7 +7,7 @@
session_start(); session_start();
//require_once '../functions.php'; //require_once '../functions.php';
$user = new User($_SESSION['uid']); $user = new \Battles\User($_SESSION['uid']);
if (!$user->admin) { if (!$user->admin) {
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
exit; exit;
@ -65,7 +65,7 @@ if ($_POST['ali']) { //Что делает эта штука?
} }
$aligns = db::c()->query('SELECT `img`,`align`,`name` FROM `aligns` ORDER BY `align`'); $aligns = db::c()->query('SELECT `img`,`align`,`name` FROM `aligns` ORDER BY `align`');
Template::header('ᐰdminка'); \Battles\Template::header('ᐰdminка');
?> ?>
<link rel=stylesheet href="/css/admin.css"> <link rel=stylesheet href="/css/admin.css">
<form method='post'> <form method='post'>
@ -554,7 +554,7 @@ foreach ($moj as $k => $v) {
$magic_name = "Лечение"; $magic_name = "Лечение";
break; break;
case "al_neut_power": case "al_neut_power":
$script_name = "RunMagicSelf"; $script_name = "RunmagicSelf";
$magic_name = "Сила нейтралитета"; $magic_name = "Сила нейтралитета";
break; break;
case "ct1": case "ct1":
@ -733,7 +733,7 @@ echo "</div>";
<button onclick="runmagic3('Test','0','0','0')">runmagic3</button> <button onclick="runmagic3('Test','0','0','0')">runmagic3</button>
<button onclick="runmagic4('Test','0','0','0')">runmagic4</button> <button onclick="runmagic4('Test','0','0','0')">runmagic4</button>
<button onclick="runmagicf('Test','0','0','0')">runmagicf</button> <button onclick="runmagicf('Test','0','0','0')">runmagicf</button>
<button onclick="RunMagicSelf('Test','0','0','0')">RunMagicSelf</button> <button onclick="RunmagicSelf('Test','0','0','0')">RunmagicSelf</button>
<button onclick="vipad('Test','0','0','0')">vipad</button> <button onclick="vipad('Test','0','0','0')">vipad</button>
<button onclick="runmagicgold('Test','0','0','0')">new window test</button> <button onclick="runmagicgold('Test','0','0','0')">new window test</button>
@ -960,7 +960,7 @@ if ($_POST['login'] && $_POST['krest']) {
Hint3Closed = false; Hint3Closed = false;
} }
function RunMagicSelf(title, magic, name) { function RunmagicSelf(title, magic, name) {
document.all("hint3").innerHTML = '<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA><tr><td align=center><B>' + title + '</td><td width=20 align=right valign=top style="cursor: hand" onclick="closehint3();"><BIG><B>x</b></BIG></td></tr><tr><td colspan=2>' + document.all("hint3").innerHTML = '<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA><tr><td align=center><B>' + title + '</td><td width=20 align=right valign=top style="cursor: hand" onclick="closehint3();"><BIG><B>x</b></BIG></td></tr><tr><td colspan=2>' +
'<form action="admin.php" method=POST><table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD><tr><td colspan=2><INPUT TYPE=hidden name=sd4 value="<?php echo @$user['id']; ?>"> <INPUT TYPE=hidden NAME="use" value="' + magic + '">' + '<form action="admin.php" method=POST><table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD><tr><td colspan=2><INPUT TYPE=hidden name=sd4 value="<?php echo @$user['id']; ?>"> <INPUT TYPE=hidden NAME="use" value="' + magic + '">' +
'Использовать возможность "Сила Нейтралитета?"</TD></TR><TR><TD align=left><INPUT TYPE=hidden NAME="' + name + '" VALUE="<?php echo @$user['login']; ?>">' + 'Использовать возможность "Сила Нейтралитета?"</TD></TR><TR><TD align=left><INPUT TYPE=hidden NAME="' + name + '" VALUE="<?php echo @$user['login']; ?>">' +

View File

@ -45,7 +45,7 @@ if ($del) {
} }
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del); db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del);
} }
Template::header('ᐰdminка инвентаря'); \Battles\Template::header('ᐰdminка инвентаря');
?> ?>
<h1>Администрирование инвентаря <?php if (isset($_SESSION['player_name'])) echo $_SESSION['player_name']; ?></h1> <h1>Администрирование инвентаря <?php if (isset($_SESSION['player_name'])) echo $_SESSION['player_name']; ?></h1>
<table class='adm'> <table class='adm'>

View File

@ -79,7 +79,7 @@ if ($get == 'exit') {
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', $user->id, $user->id); db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', $user->id, $user->id);
header('Location: city.php'); header('Location: city.php');
} }
Template::header('Академия'); \Battles\Template::header('Академия');
?> ?>
<link href="css/secondary.css" rel="stylesheet"/> <link href="css/secondary.css" rel="stylesheet"/>
<div style="float: right;"> <div style="float: right;">

View File

@ -126,7 +126,7 @@ if (isset($_GET['append'])) {
} }
} }
} }
Template::header('Арена Ангелов'); \Battles\Template::header('Арена Ангелов');
?> ?>
<link href="css/fight.css" rel="stylesheet"/> <link href="css/fight.css" rel="stylesheet"/>
<style> <style>

111
bank.php
View File

@ -16,77 +16,70 @@ if ($user->battle != 0) {
header('location: fbattle.php'); header('location: fbattle.php');
exit; exit;
} }
const BANK_SESSION_NAME = "bankid";
const SUCCESS = "Успешная операция!"; const SUCCESS = "Успешная операция!";
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
if ($get == 'exit') { $bank = new \Battles\Bank($user->id);
$_SESSION[BANK_SESSION_NAME] = null;
}
$bank = new Bank($user->id);
$status = ''; $status = '';
if (isset($_POST['userlogin'])) { $toid = $_POST['to_id'] ?? 0;
$_SESSION[BANK_SESSION_NAME] = $bank->user_id; $summa = $_POST['summa'] ?? 0;
} $submit = $_POST['action'] ?? '';
if ($_SESSION[BANK_SESSION_NAME]) { try {
$toid = (int)$_POST['to_id'] ?? 0; // Зачисление кредитов на счёт.
$summa = (int)$_POST['summa'] ?? 0;
$submit = $_POST['action'] ?? '';
// Зачисление кредитов на счёт.
if ($submit === 'depositMoney' && $summa) { if ($submit === 'depositMoney' && $summa) {
$bank->depositMoney($summa); $operation = $bank->depositMoney($summa);
$user->money = $operation['walletMoney'];
$bank->setMoney($operation['bankMoney']);
$status = SUCCESS; $status = SUCCESS;
} }
// Снятие кредитов со счёта. // Снятие кредитов со счёта.
if ($submit === 'withdrawMoney' && $summa) { if ($submit === 'withdrawMoney' && $summa) {
$bank->withdrawMoney($summa); $operation = $bank->withdrawMoney($summa);
$user->money = $operation['walletMoney'];
$bank->setMoney($operation['bankMoney']);
$status = SUCCESS; $status = SUCCESS;
} }
// Перевод кредитов на другой счёт. // Перевод кредитов на другой счёт.
if ($submit === 'sendMoney' && $summa && $toid) { if ($submit === 'sendMoney' && $summa && $toid) {
$bank->sendMoney($toid, $summa); $user->money = $bank->sendMoney($toid, $summa);
$status = SUCCESS; $status = SUCCESS;
} }
} catch (\Exceptions\GameException $e) {
echo 'Банковская ошибка!';
} finally {
unset($submit, $summa, $toid); unset($submit, $summa, $toid);
} }
Template::header('Банк'); \Battles\Template::header('Банк');
?> ?>
<link href="css/secondary.css" rel="stylesheet"/> <link href="css/secondary.css" rel="stylesheet"/>
<script src="js/main.js"></script> <script src="js/main.js"></script>
<h1>Банк</h1> <?php \Battles\Template::buildingTop(\Battles\Rooms::$roomNames[29], 'strah') ?>
<?php if (!$_SESSION[BANK_SESSION_NAME]): ?> <div><?= $status ?></div>
<a href=# onclick=hrefToFrame('city.php?strah')> ← выйти из банка</a> <div class="appblock appblock-main">
<form method="post"><input type="submit" name="userlogin" value="Управление счётом"></form> <span class="wrap">На счету: <span class="num"><?= $bank->getMoney() ?></span></span>
<?php else: ?> <hr>
<p><a href="?exit"> выйти из счёта</a></p> <span class="wrap">На руках: <span class="num"><?= $user->money ?></span></span>
<div><?= $status ?></div> </div>
<div class="appblock appblock-main"> <div class="appblock">
<span class="legend">ет <?= $bank->user_id ?></span> <span class="legend">Работа со счётом</span>
<span class="wrap">На счету: <span class="num"><?= $bank->money ?></span></span> <form method="post">
<hr> <input size="10" name="summa" placeholder="Сумма">
<span class="wrap">На руках: <span class="num"><?= $user['money'] ?></span></span> <input type="hidden" name="action" value="depositMoney">
</div> <input type="submit" value="Положить деньги">
<div class="appblock"> </form>
<span class="legend">Работа со счётом</span> <form method="post">
<form method="post"> <input size="10" name="summa" placeholder="Сумма">
<input size="10" name="summa" placeholder="Сумма"> <input type="hidden" name="action" value="withdrawMoney">
<input type="hidden" name="action" value="depositMoney"> <input type="submit" value="Снять деньги">
<input type="submit" value="Положить деньги"> </form>
</form> </div>
<form method="post"> <div class="appblock">
<input size="10" name="summa" placeholder="Сумма"> <span class="legend">Перевод кредитов</span>
<input type="hidden" name="action" value="withdrawMoney"> <form method="post">
<input type="submit" value="Снять деньги"> <input size="10" name="summa" placeholder="Сумма">
</form> <input size="10" name="to-id" placeholder="Cчёт"><br>
</div> <input type="hidden" name="action" value="sendMoney">
<div class="appblock"> <input type="submit" value="Перевести кредиты">
<span class="legend">Перевод кредитов</span> </form>
<form method="post"> <span class="wrap">Комиссия: <?= Config::$bank_commission * 100 ?>% от переводимой суммы, но не менее 1 кр.</span>
<input size="10" name="summa" placeholder="Сумма"> </div>
<input size="10" name="to-id" placeholder="Cчёт"><br>
<input type="hidden" name="action" value="sendMoney">
<input type="submit" value="Перевести кредиты">
</form>
<span class="wrap">Комиссия: <?= Config::$bank_comission * 100 ?>% от переводимой суммы, но не менее 1 кр.</span>
</div>
<?php endif; ?>

View File

@ -11,7 +11,7 @@ $ch = $_GET['ch'] ?? null;
if ($header) { if ($header) {
exit; exit;
} elseif ($ch != null) { } elseif ($ch != null) {
Template::header('buttons'); \Battles\Template::header('buttons');
?> ?>
<script language="JavaScript" src="js/ch.js"></script> <script language="JavaScript" src="js/ch.js"></script>
<script language="JavaScript" src="js/sl2.js"></script> <script language="JavaScript" src="js/sl2.js"></script>
@ -235,7 +235,7 @@ if ($header) {
<div id="oMenu" style="position: absolute; border:1px solid #666; background-color:#CCC; display:none; "></div> <div id="oMenu" style="position: absolute; border:1px solid #666; background-color:#CCC; display:none; "></div>
<div id="ClearMenu" style="position: absolute; border:1px solid #666; background-color: #e2e0e0; display: none;"></div> <div id="ClearMenu" style="position: absolute; border:1px solid #666; background-color: #e2e0e0; display: none;"></div>
<? } else { Template::header(buttons); ?> <? } else { \Battles\Template::header('buttons'); ?>
<script language="JavaScript" src="js/chat.js"></script> <script language="JavaScript" src="js/chat.js"></script>
<script language="JavaScript"> <script language="JavaScript">

View File

@ -104,7 +104,7 @@ if ($map_user['Up'] == 1) {
onclick="location.href='?move=true&Dir=Up';" alt="Вверх"> onclick="location.href='?move=true&Dir=Up';" alt="Вверх">
MAP; MAP;
} }
Template::header('forest'); \Battles\Template::header('forest');
?> ?>
<link rel="stylesheet" type="text/css" href="css/hostel.css"/> <link rel="stylesheet" type="text/css" href="css/hostel.css"/>
<style> <style>

View File

@ -103,7 +103,7 @@ if ($in_haos['status'] == 2) {
} }
} }
$in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}' LIMIT 1;")); $in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}' LIMIT 1;"));
Template::header('Цитадель Хаоса'); \Battles\Template::header('Цитадель Хаоса');
?> ?>
<!-- JS --> <!-- JS -->
<script> <script>

View File

@ -130,7 +130,7 @@ if (!$ch_rooms[$in_haos['room']]) {
mysql_query("UPDATE `cit_haos_var` SET bots='',players='' WHERE group='" . $in_haos['group'] . "'; "); mysql_query("UPDATE `cit_haos_var` SET bots='',players='' WHERE group='" . $in_haos['group'] . "'; ");
header('location: c_haos.php'); header('location: c_haos.php');
} }
Template::header('c_haos_in'); \Battles\Template::header('c_haos_in');
?> ?>
<script> <script>
function refreshPeriodic() { function refreshPeriodic() {

View File

@ -121,7 +121,7 @@ if ($_POST['attack']) {
//старт боя - конец //старт боя - конец
Template::header('Городской Парк'); \Battles\Template::header('Городской Парк');
?> ?>
<script> <script>
function refreshPeriodic() { function refreshPeriodic() {

View File

@ -63,7 +63,7 @@ if ($user->room == 403) {
} }
} }
} }
Template::header('canalizaciya'); \Battles\Template::header('canalizaciya');
$ros = mysql_query("SELECT * FROM `labirint` WHERE `user_id`='{$_SESSION['uid']}'"); $ros = mysql_query("SELECT * FROM `labirint` WHERE `user_id`='{$_SESSION['uid']}'");
$mir = mysql_fetch_array($ros); $mir = mysql_fetch_array($ros);

View File

@ -915,7 +915,7 @@ $standingon = $map[$y * 2][$x * 2];
foreach ($party as $k => $v) { foreach ($party as $k => $v) {
$map[$v['y'] * 2][$v['x'] * 2] = "u/" . $v['user']; $map[$v['y'] * 2][$v['x'] * 2] = "u/" . $v['user'];
} }
Template::header('cave'); \Battles\Template::header('cave');
?> ?>
<style> <style>
body { body {

2
ch.php
View File

@ -112,7 +112,7 @@ if (isset($_GET['online']) && $_GET['online'] != null) {
$ch4 = '_passive'; $ch4 = '_passive';
$ch5 = '_passive'; $ch5 = '_passive';
} }
Template::header(sprintf('%s (%s)', $rooms[$user->room], mysql_num_rows($data))); \Battles\Template::header(sprintf('%s (%s)', $rooms[$user->room], mysql_num_rows($data)));
?> ?>
<script> <script>
function fastshow(content) { function fastshow(content) {

View File

@ -50,7 +50,7 @@ function show_messages()
show_messages(); show_messages();
Template::header('chat'); \Battles\Template::header('chat');
?> ?>
<style> <style>
form { form {

View File

@ -30,28 +30,28 @@ switch ($location[0]) {
default: default:
break; break;
case 'cp': case 'cp':
Travel::toRoom(20,$user->room); Battles\Travel::toRoom(20,$user->room);
break; break;
case 'strah': case 'strah':
Travel::toRoom(21,$user->room); Battles\Travel::toRoom(21,$user->room);
break; break;
case 'bps': case 'bps':
Travel::toRoom(26,$user->room); Battles\Travel::toRoom(26,$user->room);
break; break;
case 'ps': case 'ps':
Travel::toRoom(51,$user->room); Battles\Travel::toRoom(51,$user->room);
break; break;
case 'zaliv': case 'zaliv':
Travel::toRoom(2111,$user->room); Battles\Travel::toRoom(2111,$user->room);
break; break;
case 'zamk': case 'zamk':
Travel::toRoom(2601,$user->room); Battles\Travel::toRoom(2601,$user->room);
break; break;
case 'abog': case 'abog':
Travel::toRoom(2655,$user->room); Battles\Travel::toRoom(2655,$user->room);
break; break;
case 'torg': case 'torg':
Travel::toRoom(2702,$user->room); Battles\Travel::toRoom(2702,$user->room);
break; break;
case 'got': case 'got':
if ($user->room == 20) { if ($user->room == 20) {
@ -59,34 +59,34 @@ switch ($location[0]) {
default: default:
break; break;
case 'level1': case 'level1':
Travel::toRoom(1,$user->room); Battles\Travel::toRoom(1,$user->room);
break; break;
case 'level7': case 'level7':
Travel::toRoom(21,$user->room); Battles\Travel::toRoom(21,$user->room);
break; break;
case 'level8': case 'level8':
Travel::toRoom(26,$user->room); Battles\Travel::toRoom(26,$user->room);
break; break;
case 'level13': case 'level13':
header('location: quest_room.php'); header('location: quest_room.php');
break; break;
case 'level222': case 'level222':
Travel::toRoom(2702,$user->room); Battles\Travel::toRoom(2702,$user->room);
break; break;
case 'level17': case 'level17':
Travel::toRoom(50,$user->room); Battles\Travel::toRoom(50,$user->room);
break; break;
case 'level2': case 'level2':
Travel::toRoom(22,$user->room); Battles\Travel::toRoom(22,$user->room);
break; break;
case 'level4': case 'level4':
Travel::toRoom(23,$user->room); Battles\Travel::toRoom(23,$user->room);
break; break;
case 'level6': case 'level6':
Travel::toRoom(27,$user->room); Battles\Travel::toRoom(27,$user->room);
break; break;
case 'level3': case 'level3':
Travel::toRoom(25,$user->room); Battles\Travel::toRoom(25,$user->room);
break; break;
} }
} elseif ($user->room == 21) { } elseif ($user->room == 21) {
@ -94,25 +94,25 @@ switch ($location[0]) {
default: default:
break; break;
case 'level4': case 'level4':
Travel::toRoom(20,$user->room); Battles\Travel::toRoom(20,$user->room);
break; break;
case 'level3': case 'level3':
Travel::toRoom(2111,$user->room); Battles\Travel::toRoom(2111,$user->room);
break; break;
case 'level13': case 'level13':
Travel::toRoom(34,$user->room); Battles\Travel::toRoom(34,$user->room);
break; break;
case 'level5': case 'level5':
Travel::toRoom(29,$user->room); Battles\Travel::toRoom(29,$user->room);
break; break;
case 'level16': case 'level16':
Travel::toRoom(31,$user->room); Battles\Travel::toRoom(31,$user->room);
break; break;
case 'level14': case 'level14':
Travel::toRoom(30,$user->room); Battles\Travel::toRoom(30,$user->room);
break; break;
case 'level650': case 'level650':
Travel::toRoom(650,$user->room); Battles\Travel::toRoom(650,$user->room);
break; break;
} }
} elseif ($user->room == 2111) { } elseif ($user->room == 2111) {
@ -120,17 +120,17 @@ switch ($location[0]) {
default: default:
break; break;
case 'level1': case 'level1':
Travel::toRoom(21,$user->room); Battles\Travel::toRoom(21,$user->room);
break; break;
case 'level203': case 'level203':
Travel::toRoom(1055,$user->room); Battles\Travel::toRoom(1055,$user->room);
break; break;
case 'level1000': case 'level1000':
Travel::toRoom(620,$user->room); Battles\Travel::toRoom(620,$user->room);
break; break;
case 'room666': case 'room666':
//Нет на карте //Нет на карте
//Travel::toRoom(666,$user->room); //Battles\Travel::toRoom(666,$user->room);
break; break;
} }
} elseif ($user->room == 2601) { } elseif ($user->room == 2601) {
@ -138,19 +138,19 @@ switch ($location[0]) {
default: default:
break; break;
case 'level4': case 'level4':
Travel::toRoom(26,$user->room); Battles\Travel::toRoom(26,$user->room);
break; break;
case 'level55': case 'level55':
Travel::toRoom(2655,$user->room); Battles\Travel::toRoom(2655,$user->room);
break; break;
case 'level1': case 'level1':
Travel::toRoom(37,$user->room); Battles\Travel::toRoom(37,$user->room);
break; break;
case 'level1051': case 'level1051':
Travel::toRoom(1051,$user->room); Battles\Travel::toRoom(1051,$user->room);
break; break;
case 'level5': case 'level5':
Travel::toRoom(404,$user->room); Battles\Travel::toRoom(404,$user->room);
break; break;
} }
} elseif ($user->room == 2701) { } elseif ($user->room == 2701) {
@ -158,10 +158,10 @@ switch ($location[0]) {
default: default:
break; break;
case 'level1': case 'level1':
Travel::toRoom(2111,$user->room); Battles\Travel::toRoom(2111,$user->room);
break; break;
case 'level2': case 'level2':
Travel::toRoom(402,$user->room); Battles\Travel::toRoom(402,$user->room);
break; break;
} }
} elseif ($user->room == 2702) { } elseif ($user->room == 2702) {
@ -169,10 +169,10 @@ switch ($location[0]) {
default: default:
break; break;
case 'level10': case 'level10':
Travel::toRoom(20,$user->room); Battles\Travel::toRoom(20,$user->room);
break; break;
case 'level6': case 'level6':
Travel::toRoom(61,$user->room); Battles\Travel::toRoom(61,$user->room);
break; break;
} }
} elseif ($user->room == 2655) { } elseif ($user->room == 2655) {
@ -180,10 +180,10 @@ switch ($location[0]) {
default: default:
break; break;
case 'level10': case 'level10':
Travel::toRoom(2601,$user->room); Battles\Travel::toRoom(2601,$user->room);
break; break;
case 'level2055': case 'level2055':
Travel::toRoom(603,$user->room); Battles\Travel::toRoom(603,$user->room);
break; break;
} }
} elseif ($user->room == 26) { } elseif ($user->room == 26) {
@ -191,25 +191,25 @@ switch ($location[0]) {
default: default:
break; break;
case 'level4': case 'level4':
Travel::toRoom(20,$user->room); Battles\Travel::toRoom(20,$user->room);
break; break;
case 'level3': case 'level3':
Travel::toRoom(2601,$user->room); Battles\Travel::toRoom(2601,$user->room);
break; break;
case 'level660': case 'level660':
Travel::toRoom(660,$user->room); Battles\Travel::toRoom(660,$user->room);
break; break;
case 'level7': case 'level7':
Travel::toRoom(777,$user->room); Battles\Travel::toRoom(777,$user->room);
break; break;
case 'level56': case 'level56':
Travel::toRoom(401,$user->room); Battles\Travel::toRoom(401,$user->room);
break; break;
} }
} }
} }
Template::header('city'); \Battles\Template::header('city');
echo sprintf('<div style="text-align: right;">Сейчас в игре: %s игроков.></div>', $online->getNumRows()); echo sprintf('<div style="text-align: right;">Сейчас в игре: %s игроков.></div>', $online->getNumRows());
if (in_array($user->room, [20, 21, 26, 2601, 2655, 2111, 2701, 2702])) { if (in_array($user->room, [20, 21, 26, 2601, 2655, 2111, 2701, 2702])) {
/* Улицы: /* Улицы:
@ -222,5 +222,5 @@ if (in_array($user->room, [20, 21, 26, 2601, 2655, 2111, 2701, 2702])) {
* 2701 С ещё одним ристалищем? * 2701 С ещё одним ристалищем?
* 2702 Торговая * 2702 Торговая
*/ */
City::showStreet($user->room); Battles\City::showStreet($user->room);
} }

View File

@ -100,7 +100,7 @@ if ($login && $action == 'edit_status') {
} }
$clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `room`, `align`, (select `id` from `online` WHERE `date` >= ?i AND `id` = users.`id`) AS `online` FROM `users` WHERE `klan` = ?i ORDER BY `online` DESC , `login` ASC', (time() - 60), $clanRow['id']); $clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `room`, `align`, (select `id` from `online` WHERE `date` >= ?i AND `id` = users.`id`) AS `online` FROM `users` WHERE `klan` = ?i ORDER BY `online` DESC , `login` ASC', (time() - 60), $clanRow['id']);
Template::header('clan'); \Battles\Template::header('clan');
?> ?>
<div> <div>
<button onclick="location.href='main.php'">Вернуться</button> <button onclick="location.href='main.php'">Вернуться</button>

View File

@ -37,7 +37,7 @@ if ($_POST['add_zay']) {
mysql_query("INSERT INTO `clan_castle` VALUES ('{$user['id']}','{$user['klan']}');"); mysql_query("INSERT INTO `clan_castle` VALUES ('{$user['id']}','{$user['klan']}');");
exit("<script>location.href='clan_castle.php';</script>"); exit("<script>location.href='clan_castle.php';</script>");
} }
Template::header('Замок Мэра'); \Battles\Template::header('Замок Мэра');
?> ?>
<script> <script>
function refreshPeriodic() { function refreshPeriodic() {

View File

@ -10,23 +10,26 @@ if ($user->room != 30) {
header("Location: main.php"); header("Location: main.php");
exit; exit;
} }
$klanName = $_POST['klanname'] ?? ''; $userClan = db::c()->query('SELECT short_name, full_name, info FROM clans where owner_id = ?i', $user->id)->fetch_object();
$klanAbbr = $_POST['klanabbr'] ?? ''; $clanFullName = $_POST['clan_full_name'] ?? '';
$klanDescr = $_POST['klandescr'] ?? ''; $clanShortName = $_POST['clan_short_name'] ?? '';
$clanInfo = $_POST['clan_info'] ?? '';
$userBank = new \Battles\Bank($user->id);
if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
if ($klanName && $klanAbbr && $klanDescr) { $eff = db::c()->query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $user->id);
$name_check = db::c()->query('SELECT owner_id FROM clans WHERE full_name = "?s" OR short_name = "?s"', $clanFullName, $clanShortName);
$eff = db::c()->query('SELECT 1 FROM `effects` WHERE `owner` = ?i AND `type` = 20', $user->id);
$name_check = db::c()->query('SELECT 1 FROM `clans` WHERE `name` = "?s" OR `short` = "?s"', 111, 333);
$errorMessage = []; $errorMessage = [];
if (Config::$clan_register_lock) {
$errorMessage[10] = 'Регистрация кланов закрыта! <BR>';
}
if ($user->align) { if ($user->align) {
$errorMessage[0] = 'Вы уже имеете направленность!. <BR>'; $errorMessage[0] = 'Вы уже имеете направленность!. <BR>';
} }
if ($user->clan) { if ($user->clan) {
$errorMessage[1] = 'Вы уже состоите в клане!. <BR>'; $errorMessage[1] = 'Вы уже состоите в клане!. <BR>';
} }
if (Config::$clan_register_cost >= $user->money) { if (Config::$clan_register_cost >= $userBank->getMoney()) {
$errorMessage[2] = 'Не хватает денег на регистрацию клана. <BR>'; $errorMessage[2] = 'Не хватает денег на регистрацию клана. <BR>';
} }
if (!$eff) { if (!$eff) {
@ -35,67 +38,62 @@ if ($klanName && $klanAbbr && $klanDescr) {
if (!$name_check) { if (!$name_check) {
$errorMessage[4] = 'Клан с такими данными уже существует.<br>'; $errorMessage[4] = 'Клан с такими данными уже существует.<br>';
} }
if (!$errorMessage || $user->admin) {
if (!$errorMessage && !Config::$clan_register_lock) { try {
// db::c()->query('INSERT INTO `reg_klan` (owner, name, abr, descr) VALUES (?i,"?s","?s","?s")', db::c()->query('INSERT INTO clans (owner_id, full_name, short_name, info) VALUES (?i,"?s","?s","?s")', $user->id, $clanFullName, $clanShortName, $clanInfo);
// $user->id, $klanName, $klanAbbr, $klanDescr); $userBank->setMoney($userBank->getMoney() - Config::$clan_register_cost);
$user->money -= Config::$clan_register_cost; Bank::setBankMoney($userBank->getMoney(), $user->id, 'clanRegister');
Bank::setBankMoney($user->money, $user->id); // Заглушка для отображения данных по только что зарегистрированному клану, когда запрос в базу в начале файла ещё не проходит.
echo 'Заявка на регистрацию клана подана.'; $userClan = new stdClass();
err('Проверки пройдены, но клан регистрировать пока нельзя!'); $userClan->full_name = $clanFullName;
$userClan->short_name = $clanShortName;
$userClan->info = $clanInfo;
unset($clanShortName, $clanFullName, $clanInfo);
echo 'Заявка на регистрацию клана подана.';
} catch (Throwable $exception) {
echo '<div style="background-color: #fae0e0;"><span class="error">Ошибка записи в базу!</span><br>' . $exception . '</div>';
}
} else { } else {
foreach ($errorMessage as $error) { foreach ($errorMessage as $error) {
echo sprintf('<span class="error">%s</span>', $error); echo sprintf('<span class="error">%s</span>', $error);
} }
} }
} }
Template::header('Регистратура кланов'); \Battles\Template::header(Rooms::$roomNames[30]);
?> \Battles\Template::buildingTop(Rooms::$roomNames[30], 'strah');
<script> if ($userClan): ?>
function leave() { <div>
top.frames['main'].location = 'city.php?strah' <fieldset style="display: inline;">
} <legend>Заявка на регистрацию</legend>
</script> <input size=30 disabled value="<?= $userClan->full_name ?>">
<h1>Регистратура кланов</h1> <input size=30 disabled value="<?= $userClan->short_name ?>"><BR>
<a href=# onclick=leave()> ← выйти из регистратуры</a> <BR>
<?php <textarea cols=80 rows=10 disabled><?= nl2br($userClan->info) ?></textarea><BR>
if ($user->admin) { <button disabled>Заявка подана и рассматривается</button>
$clanreg = []; </fieldset>
$clanPremoderationList = [] </div>
<?php else: ?>
//$clanPremoderationList = db::c()->query('SELECT * FROM clans WHERE approved = 0'); <div>
foreach ($clanPremoderationList->fetch_object() as $clan) { <form method="post">
echo sprintf('<div>%s %s <br> %s</div>', $clan->date, $clan->name, $clan->owner); <fieldset style="display: inline;">
} <legend>Заявка на регистрацию</legend>
//$clanreg = db::c()->query('SELECT `date`,`name`,`abbr`,`owner`,`descr` FROM `reg_klan`')->fetch_assoc(); <input size=30 name="clan_full_name" placeholder="Название клана" value="<?= $clanFullName ?>">
echo '<table>'; <input size=30 name="clan_short_name" maxlength="5" placeholder="Английская аббревиатура"
while ($clanreg_row = $clanreg) { value="<?= $clanShortName ?>"><BR>
echo "<TR> <BR>
<TD>", $clanreg_row['date'], "</TD> <textarea cols=80 rows=10 name="clan_info"
<TD>", $clanreg_row['name'], "</TD> placeholder="Информация о клане для энциклопедии"><?= nl2br($clanInfo) ?></textarea><BR>
<TD>", $clanreg_row['abbr'], "</TD> <input type="submit" value="Подать заявку">
<TD>", Nick::id($clanreg_row['owner'])->full(), "</TD> </fieldset>
<TD>", nl2br($clanreg_row['descr']), "</TD> </form>
</TR>"; </div>
} <div>
echo '</table>'; Для регистрации клана необходимо иметь:
} <ol>
?> <li>Проверку на чистоту. У вас её нет.
Для регистрации клана необходимо иметь: <li>10000 кредитов на банковском счёте. У вас на счету <?= $userBank->getMoney() ?>.
<ol> </ol>
<li>Проверку на чистоту. Поле информации не обазательное. Но его содержимое может серьёзно повысить шансы на регистрацию клана.<BR>
<li>10000 кредитов на банковском счёте. Заявку на регистрацию подает глава клана.
</ol> </div>
Поле информации не обазательное. Но его содержимое может серьёзно повысить шансы на регистрацию клана.<BR> <?php endif; ?>
Заявку на регистрацию подает глава клана.
<form method="post">
<fieldset style="display: inline;">
<legend>Заявка на регистрацию</legend>
<input size=30 name="klanname" placeholder="Название клана" value="<?= $klanName ?>">
<input size=30 name="klanabbr" placeholder="Английская аббревиатура" value="<?= $klanAbbr ?>"><BR>
<BR>
<textarea cols=80 rows=10 name="klandescr"
placeholder="Информация о клане для энциклопедии"><?= nl2br($klanDescr) ?></textarea><BR>
<input type="submit" value="Подать заявку">
</fieldset>
</form>

View File

@ -4,7 +4,7 @@
* Author: Igor Barkov <lopar.4ever@gmail.com> * Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game * Project name: Battles-Game
*/ */
Template::header('Список кланов'); \Battles\Template::header('Список кланов');
include_once "config.php"; include_once "config.php";
$claninf = urldecode(filter_input(INPUT_SERVER,'QUERY_STRING')); $claninf = urldecode(filter_input(INPUT_SERVER,'QUERY_STRING'));

View File

@ -1,191 +0,0 @@
<?php
/**
* Author: lopiu
* Date: 03.07.2020
* Time: 07:24
*/
class Bank
{
public $user_id;
public $money;
private $user;
const ERROR_NO_MONEY_IN_WALLET = "Ошибка! Нет денег в кошельке!";
const ERROR_NO_BANK_ACCOUNT = "Ошибка! Счёта не существует!";
const ERROR_NO_MONEY_IN_BANK_ACCOUNT = "Ошибка! Нет денег на счету!";
const ERROR_WRONG_AMOUNT = "Ошибка! Сумма должна быть положительной!";
const LOG_SEND = "Банк: Перевод средств на другой счёт.";
const LOG_RECEIVE = "Банк: Получение средств.";
const LOG_DEPOSIT = "Пополнение счёта.";
const LOG_WITHDRAW = "Снятие денег со счёта.";
public function __construct($row)
{
$bank_row = db::c()->query('SELECT user_id, money FROM bank WHERE user_id = ?i', $row)->fetch_assoc();
$this->user = db::c()->query('SELECT money FROM users WHERE id = ?i', $row)->fetch_object();
foreach ($this as $key => $value) {
if (isset($bank_row[$key])) {
$this->$key = $bank_row[$key];
}
}
// Если ВДРУГ у человека нет счёта в банке - создаём.
if (empty($this->user_id)) {
db::c()->query('INSERT INTO bank (user_id) VALUES (?i)', $row);
$this->user_id = $row;
}
}
/**
* Комиссия: self::BANK_COMISSION от переводимой суммы, но не менее 1 кр.
*
* @param $amount
*
* @return int
*/
private function bankComission($amount)
{
$bankComission = round($amount * Config::$bank_comission);
if ($bankComission < 1) {
return 1;
} else {
return (int)$bankComission;
}
}
/**
* Пишем банковское событие в лог в БД
*
* @param $receiverId - user_id получателя
* @param $amount
* @param $operationType
*
* @throws \Krugozor\Database\Mysql\Exception
*/
private function bankLogs($receiverId, $amount, $operationType)
{
$text = '';
if ($operationType === "sendMoney") {
$text = self::LOG_SEND . " Комиссия: " . $this->bankComission($amount);
} elseif ($operationType === "depositMoney") {
$receiverId = $this->user_id;
$text = self::LOG_DEPOSIT;
} elseif ($operationType === "withdrawMoney") {
$receiverId = $this->user_id;
$text = self::LOG_WITHDRAW . " Комиссия: " . $this->bankComission($amount);
}
db::c()->query('INSERT INTO `bank_logs` (sender_id, receiver_id, amount, type, text)
VALUES (?i, ?i, ?i, "?s", "?s")', $this->user_id, $receiverId, $amount, $operationType, $text);
}
/**
* Перевод денег между бансковскими счетами игроков с банковской комиссией.
*
* @param int $receiver
* @param int $amount
*
* @return void
* @throws \Krugozor\Database\Mysql\Exception
*/
public function sendMoney(int $receiver, int $amount): void
{
if ($amount <= 0) {
throw new Exception(self::ERROR_WRONG_AMOUNT);
}
if (!db::c()->query('SELECT 1 FROM bank WHERE user_id = ?i', $receiver)) {
throw new Exception(self::ERROR_NO_BANK_ACCOUNT);
}
$amountWithComission = $amount + $this->bankComission($amount);
if ($amountWithComission > $this->money) {
throw new Exception(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
}
$this->money -= $amountWithComission;
// Снимаем сумму с комиссией у отправителя
self::setBankMoney($this->money, $this->user_id);
// Отдаём сумму на счёт получателю
self::setBankMoney($amount, $receiver);
$this->bankLogs($receiver, $amount, "sendMoney");
}
/**
* Пополнение банковского счёта игрока
*
* @param int $amount - сумма
*
* @return void
* @throws \Krugozor\Database\Mysql\Exception
*/
public function depositMoney(int $amount): void
{
if ($amount <= 0) {
throw new Exception(self::ERROR_WRONG_AMOUNT);
}
$wallet = db::c()->query('SELECT money FROM users WHERE id = ?i', $this->user_id)->fetch_object();
if ($wallet->money < $amount) {
throw new Exception(self::ERROR_NO_MONEY_IN_WALLET);
}
// Забираем деньги из кошелька получателя
//todo check it!
$this->user->money -= $amount;
self::setWalletMoney($this->user->money, $this->user_id);
// Отдаём сумму на счёт получателю
$this->money += $amount;
self::setBankMoney($this->money, $this->user_id);
$this->bankLogs(0, $amount, "depositMoney");
}
/**
* Снятие денег с банковского счёта игрока с банковской комиссией.
*
* @param int $amount - сумма
*
* @return void
* @throws \Krugozor\Database\Mysql\Exception
*/
public function withdrawMoney(int $amount): void
{
if ($amount <= 0) {
throw new Exception(self::ERROR_WRONG_AMOUNT);
}
$amountWithComission = $amount + $this->bankComission($amount);
if ($this->money < $amountWithComission) {
throw new Exception(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
}
// Снимаем сумму с комиссией у отправителя
$this->money -= $amountWithComission;
self::setBankMoney($this->money, $this->user_id);
// Отдаём сумму в кошелёк получателя
//todo check it!
$this->user->money += $amount;
self::setWalletMoney($this->user->money, $this->user_id);
$this->bankLogs(0, $amount, "withdrawMoney");
}
/**
* Установить количество денег на банковском счету.
*
* @param int $amount - сумма.
* @param int $user_id - ID пользователя.
*
* @throws \Krugozor\Database\Mysql\Exception
*/
public static function setBankMoney(int $amount, int $user_id): void
{
db::c()->query('UPDATE bank SET money = ?i WHERE `id` = ?i', $amount, $user_id);
}
/**
* Установить количество денег на руках.
*
* @param int $amount - сумма.
* @param int $user_id - ID пользователя.
*
* @throws \Krugozor\Database\Mysql\Exception
*/
public static function setWalletMoney(int $amount, int $user_id): void
{
db::c()->query('UPDATE users SET money = ?i WHERE `id` = ?i', $amount, $user_id);
}
}

237
classes/Battles/Bank.php Normal file
View File

@ -0,0 +1,237 @@
<?php
/**
* Author: lopiu
* Date: 03.07.2020
* Time: 07:24
*/
namespace Battles;
class Bank
{
public $user_id;
private $money;
private $user;
const ERROR_NO_MONEY_IN_WALLET = "Ошибка! Нет денег в кошельке!";
const ERROR_NO_BANK_ACCOUNT = "Ошибка! Счёта не существует!";
const ERROR_NO_MONEY_IN_BANK_ACCOUNT = "Ошибка! Нет денег на счету!";
const ERROR_WRONG_AMOUNT = "Ошибка! Сумма должна быть положительной!";
const LOG = [
'sendMoney' => 'Банк: Перевод средств на другой счёт.',
'receiveMoney' => 'Банк: Получение средств.',
'depositMoney' => 'Пополнение счёта.',
'withdrawMoney' => 'Снятие денег со счёта.',
'clanRegister' => 'Оплата стоимости регистрации клана.',
];
public function __construct($row)
{
$bank_row = \db::c()->query('SELECT user_id, money FROM bank WHERE user_id = ?i', $row)->fetch_assoc();
$this->user = \db::c()->query('SELECT money FROM users WHERE id = ?i', $row)->fetch_object();
foreach ($this as $key => $value) {
if (isset($bank_row[$key])) {
$this->$key = $bank_row[$key];
}
}
// Если ВДРУГ у человека нет счёта в банке - создаём.
if (empty($this->user_id)) {
\db::c()->query('INSERT INTO bank (user_id) VALUES (?i)', $row);
$this->user_id = $row;
}
}
/**
* Комиссия: процент от переводимой суммы, но не менее 1 кр. Задаётся в config.php.
*
* @param int $amount сумма.
*
* @return int
*/
private function bankCommission(int $amount): int
{
$bankCommission = round($amount * \Config::$bank_commission);
if ($bankCommission < 1) {
return 1;
} else {
return (int)$bankCommission;
}
}
/**
* Пишем банковское событие в лог в БД
*
* @param int $receiverId ID получателя.
* @param int $amount сумма.
* @param string $operationType тип банковской операции.
* @param int $senderId ID отправителя (ID игрока, если не указано иное).
*
* @return void
* @throws \Krugozor\Database\Mysql\Exception
*/
private function bankLogs(int $receiverId, int $amount, string $operationType, int $senderId = 0): void
{
if (!$senderId) {
$senderId = $this->user_id;
}
$text = self::LOG[$operationType];
if ($operationType == "sendMoney") {
$text .= " Комиссия: " . $this->bankCommission($amount);
} elseif ($operationType == "depositMoney") {
$receiverId = $this->user_id;
} elseif ($operationType == "withdrawMoney") {
$receiverId = $this->user_id;
$text .= " Комиссия: " . $this->bankCommission($amount);
}
\db::c()->query('INSERT INTO `bank_logs` (sender_id, receiver_id, amount_result, type, text)
VALUES (?i, ?i, ?i, "?s", "?s")', $senderId, $receiverId, $amount, $operationType, $text);
}
/**
* Перевод денег между банковскими счетами игроков с банковской комиссией.
*
* @param int $receiver ID получателя.
* @param int $amount сумма.
*
* @return int
* @throws \Krugozor\Database\Mysql\Exception
*/
public function sendMoney(int $receiver, int $amount): int
{
$receiverWallet = \db::c()->query('SELECT money FROM bank WHERE user_id = ?i', $receiver)->fetch_object();
if ($amount <= 0) {
throw new \Exceptions\GameException(self::ERROR_WRONG_AMOUNT);
}
if (!$receiverWallet) {
throw new \Exceptions\GameException(self::ERROR_NO_BANK_ACCOUNT);
}
$amountWithComission = $amount + $this->bankCommission($amount);
if ($amountWithComission > $this->money) {
throw new \Exceptions\GameException(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
}
// Снимаем сумму с комиссией у отправителя
$this->money -= $amountWithComission;
self::setBankMoney($this->money, $this->user_id);
$this->bankLogs($receiver, $this->money, "sendMoney");
// Отдаём сумму на счёт получателю
$receiverWallet->money += $amount;
self::setBankMoney($receiverWallet->money, $receiver);
$this->bankLogs($receiver, $receiverWallet->money, "receiveMoney");
// Возвращаем изменившиеся значения
return $this->money;
}
/**
* Пополнение банковского счёта игрока
*
* @param int $amount сумма.
*
* @return array
* @throws \Krugozor\Database\Mysql\Exception
*/
public function depositMoney(int $amount): array
{
if ($amount <= 0) {
throw new \Exceptions\GameException(self::ERROR_WRONG_AMOUNT);
}
$wallet = \db::c()->query('SELECT money FROM users WHERE id = ?i', $this->user_id)->fetch_object();
if ($wallet->money < $amount) {
throw new \Exceptions\GameException(self::ERROR_NO_MONEY_IN_WALLET);
}
// Забираем деньги из кошелька получателя
$this->user->money -= $amount;
self::setWalletMoney($this->user->money, $this->user_id);
// Отдаём сумму на счёт получателю
$this->money += $amount;
self::setBankMoney($this->money, $this->user_id);
$this->bankLogs(0, $this->money, "depositMoney");
// Возвращаем изменившиеся значения
return [
'walletMoney' => $this->user->money,
'bankMoney' => $this->money
];
}
/**
* Снятие денег с банковского счёта игрока с банковской комиссией.
*
* @param int $amount сумма.
*
* @return array
* @throws \Krugozor\Database\Mysql\Exception
*/
public function withdrawMoney(int $amount):array
{
if ($amount <= 0) {
throw new \Exceptions\GameException(self::ERROR_WRONG_AMOUNT);
}
$amountWithComission = $amount + $this->bankCommission($amount);
if ($this->money < $amountWithComission) {
throw new \Exceptions\GameException(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
}
// Снимаем сумму с комиссией у отправителя
$this->money -= $amountWithComission;
self::setBankMoney($this->money, $this->user_id);
$this->bankLogs(0, $this->money, "withdrawMoney");
// Отдаём сумму в кошелёк получателя
$this->user->money += $amount;
self::setWalletMoney($this->user->money, $this->user_id);
// Возвращаем изменившиеся значения
return [
'walletMoney' => $this->user->money,
'bankMoney' => $this->money
];
}
/**
* Установить количество денег на банковском счету.
*
* @param int $amount сумма.
* @param int $user_id ID пользователя.
* @param string $operationType Тип операции. По умолчанию пусто. Если ввести, система запишет событие в банковский лог.
*
* @return void
* @throws \Krugozor\Database\Mysql\Exception
*/
public static function setBankMoney(int $amount, int $user_id, string $operationType = ''): void
{
try {
\db::c()->query('UPDATE bank SET money = ?i WHERE user_id = ?i', $amount, $user_id);
if ($operationType) {
(new Bank($user_id))->bankLogs(0, $amount, $operationType);
}
} catch (\Throwable $e) {
echo "Не отработал запрос в БД в файле {$e->getFile()}({$e->getLine()})";
}
}
/**
* Установить количество денег на руках.
*
* @param int $amount сумма.
* @param int $user_id ID пользователя.
*
* @return void
* @throws \Krugozor\Database\Mysql\Exception
*/
public static function setWalletMoney(int $amount, int $user_id): void
{
try {
\db::c()->query('UPDATE users SET money = ?i WHERE `id` = ?i', $amount, $user_id);
} catch (\Throwable $e) {
echo "Не отработал запрос в БД в файле {$e->getFile()}({$e->getLine()})";
}
}
public function getMoney()
{
return $this->money;
}
public function setMoney($amount)
{
$this->money = $amount;
}
}

View File

@ -1,5 +1,6 @@
<?php <?php
# Date: 26.10.2020 (17:56) # Date: 26.10.2020 (17:56)
namespace Battles;
// todo: #10 // todo: #10
class City class City
{ {
@ -26,7 +27,7 @@ class City
self::showBuilding(4, "cap_arr_left", 258, 21, self::$roomNames[20]) . self::showBuilding(4, "cap_arr_left", 258, 21, self::$roomNames[20]) .
self::showBuilding(5, "spring_cap_bank", 180, 485, self::$roomNames[29]) . self::showBuilding(5, "spring_cap_bank", 180, 485, self::$roomNames[29]) .
self::showBuilding(13, "spring_cap_flowershop", 220, 613, self::$roomNames[34]) . self::showBuilding(13, "spring_cap_flowershop", 220, 613, self::$roomNames[34]) .
self::showBuilding(14, "spring_cap_registratura", 170, 113, self::$roomNames[28]) . self::showBuilding(14, "spring_cap_registratura", 170, 113, self::$roomNames[30]) .
self::showBuilding(16, "spring_cap_tower", 5, 315, self::$roomNames[31]) . self::showBuilding(16, "spring_cap_tower", 5, 315, self::$roomNames[31]) .
'</div>'; '</div>';
} elseif ($id === 26) { } elseif ($id === 26) {

View File

@ -4,7 +4,7 @@
* Date: 06.07.2020 * Date: 06.07.2020
* Time: 22:41 * Time: 22:41
*/ */
namespace Battles;
class DressedItems class DressedItems
{ {
private $DB; private $DB;

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Battles;
class InventoryItem extends Item class InventoryItem extends Item
{ {
private $present; private $present;

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Battles;
abstract class Item abstract class Item
{ {
protected $item_id; protected $item_id;

View File

@ -1,8 +1,11 @@
<?php <?php
# Date: 16.09.2020 (08:23) # Date: 16.09.2020 (08:23)
// Магия лечения травм // Магия лечения травм
namespace Battles\Magic;
use Battles\UserEffects;
use Battles\User;
class CureInjury extends Magic class CureInjury extends magic
{ {
private $target; private $target;
use UserEffects; use UserEffects;
@ -17,10 +20,10 @@ class CureInjury extends Magic
{ {
$this->target = $target; $this->target = $target;
if ($target && $this->isUsable()) { if ($target && $this->isUsable()) {
$injury = db::c()->query('SELECT effect_id, type, name FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i ORDER BY type DESC LIMIT 1', $target)->fetch_object(); $injury = \db::c()->query('SELECT effect_id, type, name FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i ORDER BY type DESC LIMIT 1', $target)->fetch_object();
$targetName = $this->target->login; $targetName = $this->target->login;
if (in_array($injury->effect_id, [11, 12, 13, 14]) && $injuryType >= $injury->type) { if (in_array($injury->effect_id, [11, 12, 13, 14]) && $injuryType >= $injury->type) {
db::c()->query('DELETE FROM users_effects WHERE effect_id = ?i', $injury->effect_id); \db::c()->query('DELETE FROM users_effects WHERE effect_id = ?i', $injury->effect_id);
if (empty($injury->name) || $injury->name == 'Неизвестный эффект') { if (empty($injury->name) || $injury->name == 'Неизвестный эффект') {
$injuryName = self::$effectName[$injury->type]; $injuryName = self::$effectName[$injury->type];
} else { } else {
@ -28,7 +31,7 @@ class CureInjury extends Magic
} }
return "Вы вылечили повреждение ${injuryName} персонажу ${targetName}."; return "Вы вылечили повреждение ${injuryName} персонажу ${targetName}.";
} elseif ($injury->effect_id && $injuryType == 15) { } elseif ($injury->effect_id && $injuryType == 15) {
db::c()->query('DELETE FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i', $target); \db::c()->query('DELETE FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i', $target);
return "Вы вылечили все повреждения персонажу ${targetName}."; return "Вы вылечили все повреждения персонажу ${targetName}.";
} else { } else {
return false; return false;

View File

@ -1,6 +1,6 @@
<?php <?php
# Date: 16.09.2020 (08:45) # Date: 16.09.2020 (08:45)
namespace Battles\Magic;
class Magic class Magic
{ {
protected $status; protected $status;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace magic\attack; namespace Battles\Magic;
use db; use db;

View File

@ -4,15 +4,15 @@
* Date: 05.07.2020 * Date: 05.07.2020
* Time: 23:32 * Time: 23:32
*/ */
namespace Battles\Models;
class EffectsModel class EffectsModel
{ {
protected $DB; protected $DB;
const EFFECT_HIDEUSERINFO = 5; // Обезлик const EFFECT_HIDEUSERINFO = 5; // Обезлик
public function __construct(int $user_id) { public function __construct(int $user_id) {
try { try {
$this->DB = db::c()->query('SELECT * FROM users_effects WHERE owner_id = ?i', $user_id); $this->DB = \db::c()->query('SELECT * FROM users_effects WHERE owner_id = ?i', $user_id);
} catch (Exception $e) {echo '<div class="debug">class EffectsModel: Не могу подключиться к таблице effects!</div>';} } catch (\Throwable $e) {echo '<div class="debug">class EffectsModel: Не могу подключиться к таблице effects!</div>';}
} }
private function getEffects($user_id) private function getEffects($user_id)

View File

@ -4,6 +4,8 @@
* Date: 04.07.2020 * Date: 04.07.2020
* Time: 13:17 * Time: 13:17
*/ */
namespace Battles\Models;
use Exceptions\GameException;
class PresentsModel class PresentsModel
{ {
@ -12,12 +14,10 @@ class PresentsModel
public function __construct(int $user_id) public function __construct(int $user_id)
{ {
if (!$this->DB) { if (!$this->DB) {
try { $this->DB = \db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
$this->DB = db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id); if ($this->DB->getNumRows() == 0) {
} catch (Exception $e) { throw new GameException("<div class='debug'>class PresentsModel: Не прогрузилась база!</div>");
echo "<div class='debug'>class PresentsModel: Не прогрузилась база!</div>";
} }
} }
} }

View File

@ -4,14 +4,14 @@
* Date: 05.07.2020 * Date: 05.07.2020
* Time: 22:38 * Time: 22:38
*/ */
namespace Battles\Models;
class UserLogModel class UserLogModel
{ {
protected $DB; protected $DB;
public function __construct(int $user_id) public function __construct(int $user_id)
{ {
$this->DB = db::c()->query('SELECT * FROM users_logs WHERE user_id = ?i ORDER BY `id` ASC', $user_id); $this->DB = \db::c()->query('SELECT * FROM users_logs WHERE user_id = ?i ORDER BY `id` ASC', $user_id);
} }

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Battles;
/** /**
* Разные способы отображения строки с логином персонажа. * Разные способы отображения строки с логином персонажа.
*/ */

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Battles;
/* /*
* Список наименований игровых комнат. * Список наименований игровых комнат.
*/ */
@ -15,9 +16,8 @@ trait Rooms
25 => "Комиссионный магазин", 25 => "Комиссионный магазин",
26 => "Большая парковая улица", 26 => "Большая парковая улица",
27 => "Почта", 27 => "Почта",
28 => "Регистратура кланов",
29 => "Банк", 29 => "Банк",
30 => "Регистратура кланов (мираж)", 30 => "Регистратура кланов",
31 => "Башня смерти", 31 => "Башня смерти",
32 => "Готический замок", 32 => "Готический замок",
33 => "Лабиринт хаоса", 33 => "Лабиринт хаоса",
@ -38,6 +38,7 @@ trait Rooms
51 => "Парковая улица", 51 => "Парковая улица",
52 => "Квартал Законников", 52 => "Квартал Законников",
53 => "Библиотека", 53 => "Библиотека",
61 => "Академия",
200 => "Турнир", 200 => "Турнир",
401 => "Врата Ада", 401 => "Врата Ада",
// БС // БС
@ -185,5 +186,5 @@ trait Rooms
2655 => "Арена Богов", 2655 => "Арена Богов",
2601 => "Замковая Площадь", 2601 => "Замковая Площадь",
2702 => "Центральная площадь (мираж)", 2702 => "Центральная площадь (мираж)",
] ?? "Небытие"; ];
} }

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Battles;
class ShopItem extends Item class ShopItem extends Item
{ {
public function printInfo() public function printInfo()

View File

@ -1,6 +1,6 @@
<?php <?php
# Date: 30.09.2020 (09:42) # Date: 30.09.2020 (09:42)
namespace Battles;
class Template class Template
{ {
/** /**
@ -32,4 +32,19 @@ HTML_HEADER;
} }
return $head; return $head;
} }
/**
* @param string $buildingName название здания
* @param string $streetName служебное название улицы на которой стоит здание для кнопки возврата.
* @return string
*/
public static function buildingTop(string $buildingName, string $streetName): void
{
echo <<<HTML
<div style="float: right">
<button onclick="top.frames['gameframe'].location = 'city.php?$streetName'">Выйти из здания</button>
</div>
<h1>$buildingName</h1>
HTML;
}
} }

View File

@ -1,6 +1,6 @@
<?php <?php
# Date: 26.10.2020 (16:08) # Date: 26.10.2020 (16:08)
namespace Battles;
class Travel class Travel
{ {
/** /**
@ -48,8 +48,8 @@ class Travel
*/ */
public static function toRoom(int $roomId, int $roomIdCurrent): void public static function toRoom(int $roomId, int $roomIdCurrent): void
{ {
$itemsWeight = db::c()->query('SELECT SUM(weight) AS all_weight FROM `inventory` WHERE owner_id = ?i AND on_sale = 0', $_SESSION['uid'])->fetch_assoc(); $itemsWeight = \db::c()->query('SELECT SUM(weight) AS all_weight FROM `inventory` WHERE owner_id = ?i AND on_sale = 0', $_SESSION['uid'])->fetch_assoc();
$eff = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $_SESSION['uid'])->fetch_assoc(); $eff = \db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $_SESSION['uid'])->fetch_assoc();
$errors = []; $errors = [];
if ($itemsWeight['all_weight'] > get_meshok()) { if ($itemsWeight['all_weight'] > get_meshok()) {
$errors[0] = 'У вас переполнен рюкзак, вы не можете передвигаться...'; $errors[0] = 'У вас переполнен рюкзак, вы не можете передвигаться...';
@ -65,7 +65,7 @@ class Travel
echo sprintf('<span class="error">%s</span>', $error); echo sprintf('<span class="error">%s</span>', $error);
} }
} elseif (in_array($roomId, self::allowedRoomMoves($roomIdCurrent))) { } elseif (in_array($roomId, self::allowedRoomMoves($roomIdCurrent))) {
db::c()->query('UPDATE users, online SET users.room = ?i, online.room = ?i WHERE `online`.`user_id` = `users`.`id` AND `online`.`user_id` = ?i', $roomId, $roomId, $_SESSION['uid']); \db::c()->query('UPDATE users, online SET users.room = ?i, online.room = ?i WHERE `online`.`user_id` = `users`.`id` AND `online`.`user_id` = ?i', $roomId, $roomId, $_SESSION['uid']);
header('location: ' . self::$roomFileName[$roomId]); header('location: ' . self::$roomFileName[$roomId]);
exit; exit;
} }

View File

@ -1,4 +1,6 @@
<?php <?php
namespace Battles;
use Exceptions\GameException;
class User class User
{ {
@ -51,7 +53,7 @@ class User
public function __construct($user) public function __construct($user)
{ {
$user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc(); $user_query = \db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
foreach ($this as $key => $value) { foreach ($this as $key => $value) {
if (isset($user_query[$key])) { if (isset($user_query[$key])) {
$this->$key = $user_query[$key]; $this->$key = $user_query[$key];
@ -66,7 +68,7 @@ class User
* @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'. * @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'.
* @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку на повышение стата на 1, при условии наличия свободных очков статов. * @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку на повышение стата на 1, при условии наличия свободных очков статов.
* @return string * @return string
* @throws Exception * @throws GameException
*/ */
public function getStat($stat_name, $isMainWindow = 0) public function getStat($stat_name, $isMainWindow = 0)
{ {
@ -78,14 +80,14 @@ class User
return $this->$stat_name; return $this->$stat_name;
} }
} else { } else {
throw new Exception(self::ERROR_STAT_UNKNOWN); throw new \Exceptions\GameException(self::ERROR_STAT_UNKNOWN);
} }
} }
/** /**
* Повышает один из выбранных статов на 1, но не выше self::STAT_MAXIMUM_AMOUNT при условии наличия свободных очков статов. * Повышает один из выбранных статов на 1, но не выше self::STAT_MAXIMUM_AMOUNT при условии наличия свободных очков статов.
* @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'. * @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'.
* @throws \Krugozor\Database\Mysql\Exception * @throws GameException
*/ */
public function addOnePointToStat($stat_name) public function addOnePointToStat($stat_name)
{ {
@ -93,12 +95,12 @@ class User
if (in_array($stat_name, $allowed)) { if (in_array($stat_name, $allowed)) {
if ($this->free_stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) { if ($this->free_stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) {
$query = 'UPDATE users SET ?f = ?f + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i'; $query = 'UPDATE users SET ?f = ?f + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i';
db::c()->query($query, $stat_name, $stat_name, $this->id); \db::c()->query($query, $stat_name, $stat_name, $this->id);
} else { } else {
throw new Exception(self::ERROR_STAT_IS_MAXIMUM); throw new \Exceptions\GameException(self::ERROR_STAT_IS_MAXIMUM);
} }
} else { } else {
throw new Exception(self::ERROR_STAT_UNKNOWN); throw new \Exceptions\GameException(self::ERROR_STAT_UNKNOWN);
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
# Date: 16.09.2020 (08:28) # Date: 16.09.2020 (08:28)
# Названия эффектов, налагаемых на персонажа. # Названия эффектов, налагаемых на персонажа.
namespace Battles;
trait UserEffects trait UserEffects
{ {
public static $effectName = [ public static $effectName = [

View File

@ -1,5 +1,5 @@
<?php <?php
namespace Battles;
class UserInfo extends User class UserInfo extends User
{ {
use Rooms; use Rooms;
@ -77,7 +77,7 @@ class UserInfo extends User
$this->experience . '<br>' . $this->experience . '<br>' .
$this->free_stat_points . '<br>' . $this->free_stat_points . '<br>' .
$this->money . '<br>' . $this->money . '<br>' .
$this->Bank->money; $this->Bank->getMoney();
} }
$nameString = ''; $nameString = '';
if ($this->align) { if ($this->align) {
@ -139,9 +139,9 @@ class UserInfo extends User
if ($this->watcherIsAdmin) { if ($this->watcherIsAdmin) {
$this->Bank = new Bank($this->id); $this->Bank = new Bank($this->id);
$infoString = '<br><span>ИД Игрока: %s<br> ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> Текущая сессия: %s</span>'; $infoString = '<br><span>ИД Игрока: %s<br> ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> Текущая сессия: %s</span>';
echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->money, $this->experience, $this->free_stat_points, $this->session_id); echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->getMoney(), $this->experience, $this->free_stat_points, $this->session_id);
} }
$this->UserLogs = new UserLogModel($this->id); $this->UserLogs = new \Battles\Models\UserLogModel($this->id);
echo '<div class="secret-info-user-log"><b>Личное дело</b><br>'; echo '<div class="secret-info-user-log"><b>Личное дело</b><br>';
while ($userLogRow = $this->UserLogs->getUserLog()->fetch_object()) { while ($userLogRow = $this->UserLogs->getUserLog()->fetch_object()) {
echo sprintf('<code>%s</code><br>', date("d.m.Y H:i ", strtotime($userLogRow->date)) . $userLogRow->text); echo sprintf('<code>%s</code><br>', date("d.m.Y H:i ", strtotime($userLogRow->date)) . $userLogRow->text);
@ -153,18 +153,18 @@ class UserInfo extends User
public function showUserInfo() public function showUserInfo()
{ {
$this->effects = new EffectsModel($this->id); $this->effects = new \Battles\Models\EffectsModel($this->id);
$this->WatcherStatus(); $this->WatcherStatus();
if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) { if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
throw new Exception('<span class="error">Персонаж ' . $this->login . ' заблокирован!</span>'); throw new \Exceptions\GameException('<span class="error">Персонаж ' . $this->login . ' заблокирован!</span>');
} elseif ($this->effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) { } elseif ($this->effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
if ($this->effects->getHideUserInfoStatus() == -1) { if ($this->effects->getHideUserInfoStatus() == -1) {
$date = 'навсегда'; $date = 'навсегда';
} else { } else {
$date = 'до' . date('d.m.Y', strtotime($this->effects->getHideUserInfoStatus())); $date = 'до' . date('d.m.Y', strtotime($this->effects->getHideUserInfoStatus()));
} }
throw new Exception('<span class="error">Персонаж ' . $this->login . ' обезличен ' . $date . '.</span>'); throw new \Exceptions\GameException('<span class="error">Персонаж ' . $this->login . ' обезличен ' . $date . '.</span>');
} else { } else {
$this->Info(); $this->Info();
} }

View File

@ -0,0 +1,10 @@
<?php
# Date: 28.10.2020 (17:41)
namespace Exceptions;
class GameException extends \Exception
{
}

View File

@ -141,10 +141,10 @@ FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0
$iteminfo = []; $iteminfo = [];
while ($row = $data->fetch_assoc()) { while ($row = $data->fetch_assoc()) {
$iteminfo[] = new ShopItem($row); $iteminfo[] = new \Battles\ShopItem($row);
} }
Template::header('Рынок'); \Battles\Template::header('Рынок');
?> ?>
<script src="js/main.js"></script> <script src="js/main.js"></script>
<h1>Рынок</h1> <h1>Рынок</h1>

View File

@ -18,24 +18,21 @@ header("Pragma: no-cache");
/** /**
* Классы для работы с базой данных. * Классы для работы с базой данных.
*/ */
require_once('Database/Mysql.php');
require_once('Database/Exception.php'); require_once 'classes/Database/Mysql.php';
require_once('Database/Statement.php'); require_once 'classes/Database/Exception.php';
require_once('Database/db.php'); require_once 'classes/Database/Statement.php';
require_once 'classes/Database/db.php';
/** /**
* Автозагрузка классов. * Автозагрузка классов с учётом неймспейсов.
*/ */
spl_autoload_register(function ($class_name) {
$class_name .= '.php';
if (file_exists('classes/' . $class_name)) {
require_once 'classes/' . $class_name;
} elseif (file_exists('models/' . $class_name)) {
require_once 'models/' . $class_name;
} else {
throw new Exception(sprintf('Невозможно загрузить класс %s', $class_name));
}
spl_autoload_register(function ($className){
$fileName = __DIR__ . '/classes/' . str_replace('\\', '/', $className . '.php');
if (file_exists($fileName)) {
require_once $fileName;
}
}); });
trait Config trait Config
@ -66,7 +63,7 @@ trait Config
public static $clan_register_cost = 10000; //стоимость public static $clan_register_cost = 10000; //стоимость
public static $clan_register_lock = 1; //запрет на регистрацию public static $clan_register_lock = 1; //запрет на регистрацию
//Банк //Банк
public static $bank_comission = 0.05; //5% public static $bank_commission = 0.05; //5%
// Старая таблица опыта // Старая таблица опыта
public static $exptable = [ public static $exptable = [
0 => [0, 0, 0, 0, 0, 20], 0 => [0, 0, 0, 0, 0, 20],
@ -206,5 +203,5 @@ trait Config
1250000000 => [1, 0, 0, 450, 0, 1500000000], 1250000000 => [1, 0, 0, 450, 0, 1500000000],
1500000000 => [10, 1, 5, 8000, 1, 9999999999], # Это тринадцатый уровень 1500000000 => [10, 1, 5, 8000, 1, 9999999999], # Это тринадцатый уровень
]; ];
public static $cavedata = [621 => ['x1' => 6, 'y1' => 11, 'dir1' => 1, 'x2' => 10, 'y2' => 8, 'dir2' => 1, 'x3' => 20, 'y3' => 4, 'dir3' => 1, 'x4' => 10, 'y4' => 10, 'dir4' => 1, 'delay' => 360, 'name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']]; public static $cavedata = [621 => ['x1' => 6, 'y1' => 11, 'dir1' => 1, 'x2' => 10, 'y2' => 8, 'dir2' => 1, 'x3' => 20, 'y3' => 4, 'dir3' => 1, 'x4' => 10, 'y4' => 10, 'dir4' => 1, 'delay' => 360, 'name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']];
} }

View File

@ -52,7 +52,7 @@ if ($username && $password) {
$error = ERROR_EMPTY_CREDENTIALS; $error = ERROR_EMPTY_CREDENTIALS;
} }
Template::header('Входим...'); \Battles\Template::header('Входим...');
if ($error) { if ($error) {
echo sprintf('<a href="/"> ← на главную</a><h1>%s</h1>', $error); echo sprintf('<a href="/"> ← на главную</a><h1>%s</h1>', $error);

View File

@ -75,7 +75,7 @@ if (in_array($user->room, Config::$canalenters)) {
$cavedata = [620 => ['x1' => 3, 'y1' => 2, 'dir1' => 2]]; $cavedata = [620 => ['x1' => 3, 'y1' => 2, 'dir1' => 2]];
$podzemdata = [621 => ['name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']]; $podzemdata = [621 => ['name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']];
$warning = $_GET["warning"] ?? ''; $warning = $_GET["warning"] ?? '';
Template::header('enter_cave'); \Battles\Template::header('enter_cave');
if ($warning) { if ($warning) {
echo sprintf('<b style="color: #f80000">%s</b>', $warning); echo sprintf('<b style="color: #f80000">%s</b>', $warning);
} }

View File

@ -21,7 +21,7 @@ if (isset($user['id'])) {
include('./classes/battle_new.class.php'); include('./classes/battle_new.class.php');
$fbattle = new fbattle($user['battle']); $fbattle = new fbattle($user['battle']);
Template::header('fbattle'); \Battles\Template::header('fbattle');
?> ?>
<script type="text/javascript" src="js/sl2.js"></script> <script type="text/javascript" src="js/sl2.js"></script>
<script type="text/javascript" src="js/ch.js"></script> <script type="text/javascript" src="js/ch.js"></script>
@ -139,7 +139,7 @@ Template::header('fbattle');
<tr> <tr>
<td valign=top width=250 nowrap> <td valign=top width=250 nowrap>
<?php <?php
$myinfo = new User($_SESSION['uid']); $myinfo = new \Battles\User($_SESSION['uid']);
$myinfo->showUserDoll(1); $myinfo->showUserDoll(1);
?> ?>
</td> </td>
@ -476,7 +476,7 @@ Template::header('fbattle');
<?php <?php
if ($fbattle->return == 1) { if ($fbattle->return == 1) {
$enemyInfo = new User($fbattle->enemy); $enemyInfo = new \Battles\User($fbattle->enemy);
$enemyInfo->showUserDoll(1); $enemyInfo->showUserDoll(1);
} else { } else {
if ($fbattle->battle_data['type'] == 4 || $fbattle->battle_data['type'] == 5) { if ($fbattle->battle_data['type'] == 4 || $fbattle->battle_data['type'] == 5) {

View File

@ -4,6 +4,7 @@ if (empty($_SESSION['uid'])) {
header("Location: index.php"); header("Location: index.php");
exit; exit;
} }
require_once 'config.php'; require_once 'config.php';
$userLoginStatus = db::c()->query('SELECT enter_game FROM users WHERE id = ?i', $_SESSION['uid'])->getNumRows() ?? 0; $userLoginStatus = db::c()->query('SELECT enter_game FROM users WHERE id = ?i', $_SESSION['uid'])->getNumRows() ?? 0;
if (empty($userLoginStatus)) { if (empty($userLoginStatus)) {
@ -11,7 +12,8 @@ if (empty($userLoginStatus)) {
} else { } else {
db::c()->query('UPDATE `users` SET `enter_game` = 0 WHERE `enter_game` = 1 AND `id` = ?i', $_SESSION['uid']); db::c()->query('UPDATE `users` SET `enter_game` = 0 WHERE `enter_game` = 1 AND `id` = ?i', $_SESSION['uid']);
} }
Template::header('Окно игры');
\Battles\Template::header('Окно игры');
?> ?>
<script> <script>
if (!navigator.cookieEnabled) { if (!navigator.cookieEnabled) {

View File

@ -118,7 +118,7 @@ if ($_GET['res']) {
echo "&nbsp;<font style='font-size:12px; color:cc0000;'>Кто-то оказался быстрее!</font>"; echo "&nbsp;<font style='font-size:12px; color:cc0000;'>Кто-то оказался быстрее!</font>";
} }
} }
Template::header('Лес'); \Battles\Template::header('Лес');
?> ?>
<script src="i/forest/char1.32.js"></script> <script src="i/forest/char1.32.js"></script>
<script src="i/forest/funcs1.6.js"></script> <script src="i/forest/funcs1.6.js"></script>

View File

@ -5,7 +5,7 @@ if (empty($_SESSION['uid'])) {
header("Location: index.php"); header("Location: index.php");
exit; exit;
} }
$user = new User($_SESSION['uid']); $user = new \Battles\User($_SESSION['uid']);
$sleep = db::c()->query('SELECT `id` FROM `effects` WHERE `owner` = ?i AND `time` > ?i AND `type` = 3', $user['id'], time())->fetch_assoc(); $sleep = db::c()->query('SELECT `id` FROM `effects` WHERE `owner` = ?i AND `time` > ?i AND `type` = 3', $user['id'], time())->fetch_assoc();
$ps = $_GET['page'] ?? 0; $ps = $_GET['page'] ?? 0;
$isModerator = false; $isModerator = false;
@ -206,7 +206,7 @@ if (isset($_GET['do']) && $isModerator == true) {
exit(); exit();
} }
} }
Template::header('Форум'); \Battles\Template::header('Форум');
?> ?>
<link rel="stylesheet" href="css/wysibb/theme/default/wbbtheme.css"/> <link rel="stylesheet" href="css/wysibb/theme/default/wbbtheme.css"/>
<script type="text/javascript" language="JavaScript" src='js/forum.js'></script> <script type="text/javascript" language="JavaScript" src='js/forum.js'></script>

View File

@ -7,9 +7,9 @@
*/ */
require_once 'config.php'; require_once 'config.php';
if (empty($_SESSION['uid'])) { if (empty($_SESSION['uid'])) {
throw new Exception('Не могу проинициализировать игрока!'); throw new \Exceptions\GameException('Не могу проинициализировать игрока!');
} }
$user = new User($_SESSION['uid']); $user = new \Battles\User($_SESSION['uid']);
if ($user->id && $user->block) { if ($user->id && $user->block) {
exit('user blocked!'); exit('user blocked!');
} }

View File

@ -12,7 +12,7 @@ if (empty($_SESSION['uid'])) header("Location: index.php");
//$msg = filter_input(INPUT_POST,'msg'); //$msg = filter_input(INPUT_POST,'msg');
//$uid = $_SESSION['uid']; //$uid = $_SESSION['uid'];
//if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg); //if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
Template::header('Окно игры'); \Battles\Template::header('Окно игры');
?> ?>
<style> <style>
form { form {

View File

@ -12,7 +12,7 @@ if (empty($_SESSION['uid'])) header("Location: index.php");
//$msg = filter_input(INPUT_POST,'msg'); //$msg = filter_input(INPUT_POST,'msg');
//$uid = $_SESSION['uid']; //$uid = $_SESSION['uid'];
//if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg); //if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
Template::header('Окно игры'); \Battles\Template::header('Окно игры');
?> ?>
<style> <style>
form { form {

View File

@ -96,7 +96,7 @@ if ($user->room == 40) {
} else $status = 'Не хватает денег!'; } else $status = 'Не хватает денег!';
} }
} }
Template::header('Клановый замок'); \Battles\Template::header('Клановый замок');
?> ?>
<script src="js/main.js"></script> <script src="js/main.js"></script>
<style> <style>

View File

@ -204,7 +204,7 @@ if ($_GET['exit'] == 1) {
header('Location: city.php'); header('Location: city.php');
} }
Template::header('group_arena'); \Battles\Template::header('group_arena');
?> ?>
<script> <script>
function growl(title, color, message, stycky) { function growl(title, color, message, stycky) {

View File

@ -42,7 +42,7 @@ $hr = new hellround;
$mytrip = $hr->is_in_trip($user['id']); $mytrip = $hr->is_in_trip($user['id']);
$tr = $hr->get_par($mytrip); $tr = $hr->get_par($mytrip);
Template::header('hell'); \Battles\Template::header('hell');
if ($mytrip > 0) { if ($mytrip > 0) {
?> ?>

View File

@ -5,7 +5,7 @@ if (empty($_SESSION['uid'])) {
exit; exit;
} }
include('config.php'); include('config.php');
$user = new User($_SESSION['uid']); $user = new \Battles\User($_SESSION['uid']);
$hostel = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `type`, `time` FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1')); $hostel = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `type`, `time` FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
#include('functions.php'); #include('functions.php');
$error = ''; $error = '';
@ -154,7 +154,7 @@ if ($_GET['unsleep'] && $user['sleep'] > 0) {
} }
header('Location: hostel.php'); header('Location: hostel.php');
} }
Template::header('Хостел'); \Battles\Template::header('Хостел');
?> ?>
<script src="js/ajaxLoad.js"></script> <script src="js/ajaxLoad.js"></script>
<? if (isset($hostel['id'])) { ?> <? if (isset($hostel['id'])) { ?>

View File

@ -334,7 +334,7 @@ if ($_GET['go_back'] == 1) {
header('Location: hostel.php'); header('Location: hostel.php');
} }
Template::header('hostel_room'); \Battles\Template::header('hostel_room');
?> ?>
<script src="js/ajaxLoad.js"></script> <script src="js/ajaxLoad.js"></script>
<link rel="stylesheet" type="text/css" href="css/hostel.css"/> <link rel="stylesheet" type="text/css" href="css/hostel.css"/>

View File

@ -4,8 +4,8 @@ if ($_SESSION['uid']) {
header('Location: fight.php'); header('Location: fight.php');
exit; exit;
} }
require_once './classes/Template.php'; require_once './classes/Battles/Template.php';
Template::header('Вход'); \Battles\Template::header('Вход');
?> ?>
<h1>Демонстрационная версия</h1> <h1>Демонстрационная версия</h1>
<div> <div>

View File

@ -2,11 +2,11 @@
session_start(); session_start();
include_once 'config.php'; include_once 'config.php';
$login = urldecode($_SERVER['QUERY_STRING']) ?? ''; $login = urldecode($_SERVER['QUERY_STRING']) ?? '';
$userInfo = new UserInfo($login); $userInfo = new \Battles\UserInfo($login);
$presentsModel = new PresentsModel($userInfo->id); $presentsModel = new \Battles\Models\PresentsModel($userInfo->id);
$presentsList = $presentsModel->getAllPresents(); $presentsList = $presentsModel->getAllPresents();
$userInfo->watcher_id = $_SESSION['uid'] ?? null; $userInfo->watcher_id = $_SESSION['uid'] ?? null;
Template::header('Информация о ' . $userInfo->login); \Battles\Template::header('Информация о ' . $userInfo->login);
if (!$userInfo->id) { if (!$userInfo->id) {
echo sprintf('Ошибка: персонаж <em>%s</em> не найден...<p><a style="color: #99f;" href="javascript:window.history.go(-1);">←назад</a></p>', $login); echo sprintf('Ошибка: персонаж <em>%s</em> не найден...<p><a style="color: #99f;" href="javascript:window.history.go(-1);">←назад</a></p>', $login);
exit; exit;

View File

@ -371,7 +371,7 @@ if ((time() - $_SESSION['time']) > 3) {
} else { } else {
$tt = (time() - $_SESSION['time']); $tt = (time() - $_SESSION['time']);
} }
Template::header('lab'); \Battles\Template::header('lab');
echo Nick::id($user)->battle(); echo Nick::id($user)->battle();
echo " <a href=\"#\" onclick=\"javascript:if (confirm('Желаете выбраться из квестового лабиринта? Теряете все, что здесь нашли.')){ location.href='lab.php?eexit=1';}\">Выйти?</a>"; echo " <a href=\"#\" onclick=\"javascript:if (confirm('Желаете выбраться из квестового лабиринта? Теряете все, что здесь нашли.')){ location.href='lab.php?eexit=1';}\">Выйти?</a>";

View File

@ -369,7 +369,7 @@ if ((time() - $_SESSION['time']) > 3) {
} else { } else {
$tt = (time() - $_SESSION['time']); $tt = (time() - $_SESSION['time']);
} }
Template::header('lab2'); \Battles\Template::header('lab2');
echo Nick::id($user)->battle(); echo Nick::id($user)->battle();
echo " <a href=\"#\" onclick=\"javascript:if (confirm('Желаете выбраться из лабиринта? Теряете все что здесь нашли.')){ location.href='lab.php?eexit=1';}\">Выйти?</a>"; echo " <a href=\"#\" onclick=\"javascript:if (confirm('Желаете выбраться из лабиринта? Теряете все что здесь нашли.')){ location.href='lab.php?eexit=1';}\">Выйти?</a>";

View File

@ -299,7 +299,7 @@ if ($user->room == 1051) {
header('Location: labirint.php'); header('Location: labirint.php');
} }
} }
Template::header('Вход в Лабиринты'); \Battles\Template::header('Вход в Лабиринты');
?> ?>
<div style="float: right;"> <div style="float: right;">
<input type="button" onclick="location.href='lab_enter.php';" value="Обновить"> <input type="button" onclick="location.href='lab_enter.php';" value="Обновить">

View File

@ -469,7 +469,7 @@ if ($user->room == 1052) {
$effed .= '<div><img width="40" height="25" src="/i/sh/event_timer_trap.gif" /> - Время перехода +3 секунды (Осталось : ' . timeOut($varos['trap1']['time'] - time()) . ')</div>'; $effed .= '<div><img width="40" height="25" src="/i/sh/event_timer_trap.gif" /> - Время перехода +3 секунды (Осталось : ' . timeOut($varos['trap1']['time'] - time()) . ')</div>';
} }
unset($varos); unset($varos);
Template::header('labirint'); \Battles\Template::header('labirint');
?> ?>
<script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.js"></script>
<script> <script>

View File

@ -14,7 +14,7 @@ if ($user->battle) {
header('location: fbattle.php'); header('location: fbattle.php');
exit; exit;
} }
Template::header('Библиотека Просвещения'); \Battles\Template::header('Библиотека Просвещения');
?> ?>
<TABLE border=0 width=600 cellspacing="0" cellpadding="0" align=left> <TABLE border=0 width=600 cellspacing="0" cellpadding="0" align=left>

View File

@ -4,7 +4,7 @@ $_REQUEST['log'] = $_REQUEST['log'] ?? 0;
require_once "functions.php"; require_once "functions.php";
$data = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id` = '" . $_REQUEST['log'] . "'")); $data = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id` = '" . $_REQUEST['log'] . "'"));
$log = file("backup/logs/battle" . $_REQUEST['log'] . ".txt"); $log = file("backup/logs/battle" . $_REQUEST['log'] . ".txt");
Template::header('Лог поединка'); \Battles\Template::header('Лог поединка');
?> ?>
<H3>Лог поединка</H3> <H3>Лог поединка</H3>
<FORM> <FORM>

View File

@ -1,7 +1,7 @@
<?php <?php
// Магия восстагновления здоровья // Магия восстагновления здоровья
use Battles\User;
class Healing extends Magic class Healing extends magic
{ {
private $target; private $target;
private $magicPower; private $magicPower;

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
echo "Это боевая магия..."; echo "Это боевая магия...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) { if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3; $int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
echo "Это боевая магия..."; echo "Это боевая магия...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) { if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3; $int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
echo "Это боевая магия..."; echo "Это боевая магия...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) { if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3; $int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
echo "Это боевая магия..."; echo "Это боевая магия...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) { if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3; $int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
echo "Это боевая магия..."; echo "Это боевая магия...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) { if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3; $int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
echo "Это боевая магия..."; echo "Это боевая магия...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) { if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3; $int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) { if ($user['battle'] == 0) {
echo "Это боевая магия..."; echo "Это боевая магия...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) { if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3; $int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -1,6 +1,6 @@
<?php <?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '76' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '76' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '205' LIMIT 1;")); $effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '205' LIMIT 1;"));
if ($user['intel'] >= 0) { if ($user['intel'] >= 0) {

View File

@ -1,7 +1,7 @@
<?php <?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '77' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '77' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '204' LIMIT 1;")); $effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '204' LIMIT 1;"));
if ($user['intel'] >= 0) { if ($user['intel'] >= 0) {

View File

@ -4,7 +4,7 @@ if ($user['battle'] > 0) {
echo "Не в бою..."; echo "Не в бою...";
} else { } else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '3' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '3' ;"));
if ($user['intel'] >= 2) { if ($user['intel'] >= 2) {
$int=$magic['chanse'] + ($user['intel'] - 2)*3; $int=$magic['chanse'] + ($user['intel'] - 2)*3;
if ($int>98){$int=99;} if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ $forbidden=array("1","2","3","7","6","8","18","19","20","21","22","43","46","47"
"91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106",
"107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121",
"122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138","139",); "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138","139",);
// magic // magic
// встраивание магии // встраивание магии
if ($user['battle'] > 0) { if ($user['battle'] > 0) {
echo "Не в бою..."; echo "Не в бою...";
@ -47,7 +47,7 @@ if ($user['battle'] > 0) {
".($dress['ngray']<$svitok['ngray']?"`ngray`='".$svitok['ngray']."',":"")." ".($dress['ngray']<$svitok['ngray']?"`ngray`='".$svitok['ngray']."',":"")."
".($dress['ndark']<$svitok['ndark']?"`ndark`='".$svitok['ndark']."',":"")." ".($dress['ndark']<$svitok['ndark']?"`ndark`='".$svitok['ndark']."',":"")."
".($dress['nlight']<$svitok['nlight']?"`nlevel`='".$svitok['nlight']."',":"")." ".($dress['nlight']<$svitok['nlight']?"`nlevel`='".$svitok['nlight']."',":"")."
`massa`=`massa`+1,`cost`=`cost`+'".$svitok['cost']."', `includemagic` = '".$svitok['magic']."', `includemagicdex` = '".$svitok['maxdur']."', `includemagicmax` = '".$svitok['maxdur']."', `includemagicname` = '".$svitok['name']."', `includemagicuses` = '100+".$user['intel']."', `includemagiccost` = '".($svitok['cost']/2)."' WHERE `id` = '{$dress['id']}' LIMIT 1;"); `massa`=`massa`+1,`cost`=`cost`+'".$svitok['cost']."', `includemagic` = '".$svitok['magic']."', `includemagicdex` = '".$svitok['maxdur']."', `includemagicmax` = '".$svitok['maxdur']."', `includemagicname` = '".$svitok['name']."', `includemagicuses` = '100+".$user['intel']."', `includemagiccost` = '".($svitok['cost']/2)."' WHERE `id` = '{$dress['id']}' LIMIT 1;");
$bet=1; $bet=1;
} }
} }

View File

@ -19,7 +19,7 @@ $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `
<?php*/ <?php*/
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '22' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '22' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '203' LIMIT 1;")); $effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '203' LIMIT 1;"));
if($user['invis'] == 1) { $user['login'] = '<b><i>невидимка</i></b>'; } if($user['invis'] == 1) { $user['login'] = '<b><i>невидимка</i></b>'; }

View File

@ -1,7 +1,7 @@
<?php <?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '14' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '14' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '2' LIMIT 1;")); $effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '2' LIMIT 1;"));
if ($user['intel'] >= 1) { if ($user['intel'] >= 1) {

View File

@ -1,7 +1,7 @@
<?php <?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '15' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '15' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '2' LIMIT 1;")); $effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '2' LIMIT 1;"));
if ($user['intel'] >= 1) { if ($user['intel'] >= 1) {

View File

@ -28,7 +28,7 @@ if (($user->room > 2000) && ($user->room < 2100)) {echo "Не в Проходе.
$messch="Персонаж &quot;{$user['login']}&quot; $action путы на &quot;$target&quot;"; $messch="Персонаж &quot;{$user['login']}&quot; $action путы на &quot;$target&quot;";
addch("<img src=i/magic/chains.gif> $messch"); addch("<img src=i/magic/chains.gif> $messch");
echo "<font color=red><b>Вы наложили путы на персонажа \"$target\"</b></font>"; echo "<font color=red><b>Вы наложили путы на персонажа \"$target\"</b></font>";
$bet=1; $bet=1;
} }

View File

@ -28,7 +28,7 @@ if (($user->room > 2000) && ($user->room < 2100)) {echo "Не в Проходе.
$messch="Персонаж &quot;{$user['login']}&quot; $action &quot;$target&quot;"; $messch="Персонаж &quot;{$user['login']}&quot; $action &quot;$target&quot;";
addch("<img src=i/magic/chains.gif> $messch"); addch("<img src=i/magic/chains.gif> $messch");
echo "<font color=red><b>Вы парализовали персонажа \"$target\"</b></font>"; echo "<font color=red><b>Вы парализовали персонажа \"$target\"</b></font>";
$bet=1; $bet=1;
} }

View File

@ -10,7 +10,7 @@ $book=866;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$mag_def="`type` = '215'"; $mag_def="`type` = '215'";
$md_arr=array("216","217","218","219","220","221","222","223","224","225","226"); $md_arr=array("216","217","218","219","220","221","222","223","224","225","226");

View File

@ -10,7 +10,7 @@ $book=908;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$mag_def="`type` = '215'"; $mag_def="`type` = '215'";
$md_arr=array("216","217","218","219","220","221","222","223","224","225","226"); $md_arr=array("216","217","218","219","220","221","222","223","224","225","226");

View File

@ -10,7 +10,7 @@ $book=909;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$mag_def="`type` = '215'"; $mag_def="`type` = '215'";
$md_arr=array("216","217","218","219","220","221","222","223","224","225","226"); $md_arr=array("216","217","218","219","220","221","222","223","224","225","226");

View File

@ -17,7 +17,7 @@ if (empty($_SESSION['uid'])) {
exit; exit;
} }
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';")); $bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
//mana needed //mana needed
$t1 = explode(";",$bat['t1']); $t1 = explode(";",$bat['t1']);

View File

@ -15,7 +15,7 @@ if (empty($_SESSION['uid'])) {
} }
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';")); $bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;")); if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;"));
//mana needed //mana needed

View File

@ -15,7 +15,7 @@ if (empty($_SESSION['uid'])) {
} }
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';")); $bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;")); if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;"));
//mana needed //mana needed

View File

@ -15,7 +15,7 @@ if (empty($_SESSION['uid'])) {
} }
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';")); $bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;")); if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;"));
//mana needed //mana needed

View File

@ -11,7 +11,7 @@ $book=866;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';")); $bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
$mag_def="`type` = '203'"; $mag_def="`type` = '203'";
$md_arr=array("204","205","206","207","208","209","210","211","212","213","214"); $md_arr=array("204","205","206","207","208","209","210","211","212","213","214");

View File

@ -12,7 +12,7 @@ $book=908;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';")); $bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
$mag_def="`type` = '203'"; $mag_def="`type` = '203'";
$md_arr=array("204","205","206","207","208","209","210","211","212","213","214"); $md_arr=array("204","205","206","207","208","209","210","211","212","213","214");

View File

@ -12,7 +12,7 @@ $book=909;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;")); $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';")); $bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
$mag_def="`type` = '203'"; $mag_def="`type` = '203'";
$md_arr=array("204","205","206","207","208","209","210","211","212","213","214"); $md_arr=array("204","205","206","207","208","209","210","211","212","213","214");

Some files were not shown because too many files have changed in this diff Show More