dev #38

Merged
lopar merged 22 commits from dev into master 2021-02-03 08:56:49 +00:00
23 changed files with 867 additions and 236 deletions
Showing only changes of commit 7dd6368b84 - Show all commits

View File

@ -11,6 +11,7 @@ use Battles\Bank;
use Battles\Database\DBPDO;
use Battles\Moderation;
use Battles\Nick;
use Battles\Template;
use Battles\User;
$user = $user ?? new User($_SESSION['uid']);
@ -20,11 +21,11 @@ if (!$user->admin) {
}
if (isset($_GET['sleep'])) {
Moderation::muteChat($user->id, strtotime('15min'));
Moderation::muteChat($user->getId(), strtotime('15min'));
}
if (isset($_POST['ldnick']) && isset($_POST['ldtext'])) {
Moderation::addToUserLog($_POST['ldnick'], $_POST['ldtext'], $user->id);
Moderation::addToUserLog($_POST['ldnick'], $_POST['ldtext'], $user->getId());
}
if (isset($_POST['syschatmsg'])) {
@ -105,7 +106,7 @@ while ($i < count($row)) {
unset($i);
\Battles\Template::header('ᐰdminка');
Template::header('ᐰdminка');
?>
<link rel=stylesheet href="/css/admin.css">
<button onclick="location.href='?sleep'"><img src="../i/magic/sleep.gif" alt="sleep"> Молчать 15 мин</button>

View File

@ -45,9 +45,9 @@ function setProfession($name, $type, $needMoney, $needLevel)
$profId = 22;
}
if (!empty($profId)) {
$user->money -= $needMoney;
Bank::setWalletMoney($user->money, $user->id);
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->id);
$user->setMoney($user->getMoney() - $needMoney);
Bank::setWalletMoney($user->getMoney(), $user->getId());
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->getId());
$deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр.";
GameLogs::addUserLog($_SESSION['uid'], $deloText);
$user['prof' . $type] = true;
@ -69,7 +69,7 @@ if ($get == 'medic') {
}
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->getId(), $user->getId());
header('Location: city.php');
}
Template::header('Академия');
@ -82,8 +82,8 @@ Template::header('Академия');
<div><?= $status ?></div>
<div class="appblock appblock-main">
<span class="legend">Информация</span>
<span class="wrap">Кредиты<span class="num"><?= $user->money ?></span></span>
<span class="wrap">Уровень персонажа<span class="num"><?= $user->level ?></span></span>
<span class="wrap">Кредиты<span class="num"><?= $user->getMoney() ?></span></span>
<span class="wrap">Уровень персонажа<span class="num"><?= $user->getLevel() ?></span></span>
</div>
<div class="appblock">
<span class="legend">Наёмник</span>

View File

@ -1,11 +1,18 @@
<?php
use Battles\Bank;
use Battles\Rooms;
use Battles\Template;
use Battles\User;
use Exceptions\GameException;
ob_start("ob_gzhandler");
session_start();
require_once "functions.php";
$user = $user ?? new \Battles\User($_SESSION['uid']);
$user = $user ?? new User($_SESSION['uid']);
const SUCCESS = "Успешная операция!";
$bank = new \Battles\Bank($user->id);
$bank = new Bank($user->getId());
$status = '';
$toid = $_POST['to_id'] ?? 0;
@ -15,37 +22,37 @@ try {
// Зачисление кредитов на счёт.
if ($submit === 'depositMoney' && $summa) {
$operation = $bank->depositMoney($summa);
$user->money = $operation['walletMoney'];
$user->setMoney($operation['walletMoney']);
$bank->setMoney($operation['bankMoney']);
$status = SUCCESS;
}
// Снятие кредитов со счёта.
if ($submit === 'withdrawMoney' && $summa) {
$operation = $bank->withdrawMoney($summa);
$user->money = $operation['walletMoney'];
$user->setMoney($operation['walletMoney']);
$bank->setMoney($operation['bankMoney']);
$status = SUCCESS;
}
// Перевод кредитов на другой счёт.
if ($submit === 'sendMoney' && $summa && $toid) {
$user->money = $bank->sendMoney($toid, $summa);
$user->setMoney($bank->sendMoney($toid, $summa));
$status = SUCCESS;
}
} catch (\Exceptions\GameException $e) {
} catch (GameException $e) {
echo 'Банковская ошибка!';
} finally {
unset($submit, $summa, $toid);
}
\Battles\Template::header('Банк');
Template::header('Банк');
?>
<link href="css/secondary.css" rel="stylesheet"/>
<script src="js/main.js"></script>
<?php \Battles\Template::buildingTop(\Battles\Rooms::$roomNames[29], 'strah') ?>
<?php Template::buildingTop(Rooms::$roomNames[29], 'strah') ?>
<div><?= $status ?></div>
<div class="appblock appblock-main">
<span class="wrap">На счету: <span class="num"><?= $bank->getMoney() ?></span></span>
<hr>
<span class="wrap">На руках: <span class="num"><?= $user->money ?></span></span>
<span class="wrap">На руках: <span class="num"><?= $user->getMoney() ?></span></span>
</div>
<div class="appblock">
<span class="legend">Работа со счётом</span>

View File

@ -5,7 +5,7 @@ if (empty($_SESSION['uid'])) {
}
require_once "functions.php";
if (empty($user->clan)) {
if (empty($user->getClan())) {
exit;
}
$is_now = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc();

View File

@ -1,7 +1,11 @@
<?php
use Battles\Template;
use Battles\User;
session_start();
require_once "functions.php";
$user = $user ?? new \Battles\User($_SESSION['uid']);
$user = $user ?? new User($_SESSION['uid']);
if ($user->room == 403) {
include "startpodzemel.php";
if ($_GET['act'] == "cexit") {
@ -37,7 +41,7 @@ if ($user->room == 403) {
'Ключик №9',
'Ключик №10'
];
db::c()->query('DELETE FROM inventory WHERE name IN ("?s") AND owner_id = ?i', implode(",", $items_to_delete), $user->id);
db::c()->query('DELETE FROM inventory WHERE name IN ("?s") AND owner_id = ?i', implode(",", $items_to_delete), $user->getId());
}
}
$e = mysql_query("DELETE FROM labirint WHERE user_id='" . $user['id'] . "'");
@ -50,11 +54,11 @@ if ($user->room == 403) {
{
$frt = mysql_query("select user_id from `labirint` where glava='" . $glava . "'");
while ($rbb = mysql_fetch_array($frt)) {
addchp('<b>' . $user->login . '</b> поднял предмет "' . $mis . '". ', '{[]}' . Nick::id($rbb["user_id"])->short() . '{[]}');
addchp('<b>' . $user->getLogin() . '</b> поднял предмет "' . $mis . '". ', '{[]}' . Nick::id($rbb["user_id"])->short() . '{[]}');
}
}
}
\Battles\Template::header('canalizaciya');
Template::header('canalizaciya');
$ros = mysql_query("SELECT * FROM `labirint` WHERE `user_id`='{$_SESSION['uid']}'");
$mir = mysql_fetch_array($ros);

2
ch.php
View File

@ -414,7 +414,7 @@ if (isset($_GET['online']) && $_GET['online'] != null) {
$_GET['text'] = preg_replace('/private \[klan-([a-zA-Z]*)\]/', '', $_GET['text']);
if (empty($user->clan)) {
if (empty($user->getClan())) {
$_GET['text'] = str_replace('private [klan]', '', $_GET['text']);
$_GET['text'] = str_replace('private [klan]', 'private [klan-' . $user['klan'] . ']', $_GET['text']);
} else {

View File

@ -13,11 +13,11 @@ require_once 'functions.php';
$user = $user ?? new User($_SESSION['uid']);
$db = new DBPDO();
$clanRow = [];
if (!$user->clan) {
if (!$user->getClan()) {
exit(err('Вы не состоите в клане!'));
}
try {
$clanRow = $db->fetch('SELECT * FROM `clans` WHERE short_name = ?', $user->clan);
$clanRow = $db->fetch('SELECT * FROM `clans` WHERE short_name = ?', $user->getClan());
} catch (Exception $e) {
echo "<div>MYSQL_ERROR: Таблица clans сломана!</div>";
}
@ -37,14 +37,14 @@ $tus = $_POST['tus'] ?? null;
$lock = true; // блокировка функций
if ($zamok && !$lock) {
$db->execute('UPDATE `clans` SET `zamok` = 1 WHERE `glava` = ?', $user->id);
$db->execute('UPDATE `clans` SET `zamok` = 1 WHERE `glava` = ?', $user->getId());
$status = "Начат сбор средств на строительство Кланового Замка.";
header("Location: clan.php");
}
if ($kr && $kolv > 0 && !$lock) {
if ($user->money >= $kolv) {
$db->execute('UPDATE clans SET zbor = zbor + ? WHERE id = ?', [$kolv, $user->clan]);
Bank::setWalletMoney($user->money -= $kolv, $user->id);
if ($user->getMoney() >= $kolv) {
$db->execute('UPDATE clans SET zbor = zbor + ? WHERE id = ?', [$kolv, $user->getClan()]);
Bank::setWalletMoney($user->setMoney($user->getMoney() - $kolv), $user->getId());
header("Location: clan.php");
} else {
$status = 'Не хватает денег!';
@ -57,8 +57,8 @@ if ($login && $action == 'add_member') {
echo "Нет проверки!";
} elseif ($sok['clan']) {
echo 'Персонаж уже состоит в клане!';
} elseif ($sok['level'] > 0 && $user->money >= COST_ADD_MEMBER) {
Bank::setWalletMoney($user->money - COST_ADD_MEMBER, $user->id);
} elseif ($sok['level'] > 0 && $user->getMoney() >= COST_ADD_MEMBER) {
Bank::setWalletMoney($user->setMoney($user->getMoney() - COST_ADD_MEMBER), $user->getId());
$db->execute('UPDATE users SET clan = ?, align = ? WHERE id = ?', [$clanRow['id'], $clanRow['align'], $sok['id']]);
$status = "Персонаж «{$login}» успешно принят в клан.";
} else {
@ -68,12 +68,12 @@ if ($login && $action == 'add_member') {
if ($login) {
$sok = $db->fetch('SELECT id FROM users WHERE clan = ? AND login = ?', [$clanRow['id'], $login]);
if ($action == 'remove_member' && $sok['id'] != $clanRow['owner_id'] && $user->money >= COST_REMOVE_MEMBER) {
Bank::setWalletMoney($user->money - COST_REMOVE_MEMBER, $user->id);
if ($action == 'remove_member' && $sok['id'] != $clanRow['owner_id'] && $user->getMoney() >= COST_REMOVE_MEMBER) {
Bank::setWalletMoney($user->setMoney($user->getMoney() - COST_REMOVE_MEMBER), $user->getId());
$db->execute('UPDATE users SET clan = null, align = 0 WHERE id = ?', $sok['id']);
$status = "Персонаж «{$login}» покинул клан.";
}
if ($action == 'change_owner' && $clanRow['owner_id'] == $user->id) {
if ($action == 'change_owner' && $clanRow['owner_id'] == $user->getId()) {
$db->execute('UPDATE clans SET owner_id = ? WHERE id = ?', [$sok['id'], $clanRow['id']]);
$clanRow['owner_id'] = $sok['id'];
}
@ -108,7 +108,7 @@ $clanRow['zbor'] = null; // И копилки.
<p style="width: 50%; vertical-align: top;" rowspan=2>
<h3><img src="./i/clan/<?= $clanRow['short_name'] ?>.png"><?= $clanRow['full_name'] ?></h3>
<?php if ($clanRow['owner_id'] == $user->id): ?>
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
<div>
<span id="add_member">
<input type="submit" onclick="use('add_member')" value="Принять в клан">
@ -123,18 +123,18 @@ $clanRow['zbor'] = null; // И копилки.
</div>
<?php endif; ?>
<?php if ($clanRow['owner_id'] == $user->id): ?>
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
<?php if ($login && $action == 'edit_status' && $sok['id'] != $clanRow['owner_id']): ?>
<form method='post'>
<input placeholder='Статус' name='new_status'>
<input type="hidden" name="login" value="<?= $login ?>">
<?php if ($clanRow['glava'] == $user->id): ?>
<?php if ($clanRow['owner_id'] == $user->id): ?>
<?php if ($clanRow['glava'] == $user->getId()): ?>
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
<br><input type=checkbox name=vin checked> Может принимать/выгонять членов клана
<?php else: ?>
<br><input type=checkbox name=vin> Может принимать/выгонять членов клана
<?php endif; ?>
<?php if ($clanRow['owner_id'] == $user->id): ?>
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
<br><input type=checkbox name=tus checked> Может менять статус членов клана
<?php else: ?>
<br><input type=checkbox name=tus> Может менять статус членов клана
@ -152,7 +152,7 @@ $clanRow['zbor'] = null; // И копилки.
<?php endif; ?>
<?php endif; ?>
<?php if ($clanRow['owner_id'] == $user->id): ?>
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
<div>
<span id="change_owner">
<input type="submit" onclick="use('change_owner')" value="Сменить главу клана">

View File

@ -1,24 +1,30 @@
<?php
use Battles\Bank;
use Battles\Rooms;
use Battles\Template;
use Battles\User;
session_start();
require_once 'functions.php';
$user = $user ?? new \Battles\User($_SESSION['uid']);
$userClan = db::c()->query('SELECT short_name, full_name, info FROM clans where owner_id = ?i', $user->id)->fetch_object();
$user = $user ?? new User($_SESSION['uid']);
$userClan = db::c()->query('SELECT short_name, full_name, info FROM clans where owner_id = ?i', $user->getId())->fetch_object();
$clanFullName = $_POST['clan_full_name'] ?? '';
$clanShortName = $_POST['clan_short_name'] ?? '';
$clanInfo = $_POST['clan_info'] ?? '';
$userBank = new \Battles\Bank($user->id);
$userBank = new Bank($user->getId());
if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
$eff = db::c()->query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $user->id);
$eff = db::c()->query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $user->getId());
$name_check = db::c()->query('SELECT owner_id FROM clans WHERE full_name = "?s" OR short_name = "?s"', $clanFullName, $clanShortName);
$errorMessage = [];
if (Config::$clan_register_lock) {
$errorMessage[10] = 'Регистрация кланов закрыта! <BR>';
}
if ($user->align) {
if ($user->getAlign()) {
$errorMessage[0] = 'Вы уже имеете направленность!. <BR>';
}
if ($user->clan) {
if ($user->getClan()) {
$errorMessage[1] = 'Вы уже состоите в клане!. <BR>';
}
if (Config::$clan_register_cost >= $userBank->getMoney()) {
@ -32,9 +38,9 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
}
if (!$errorMessage || $user->admin) {
try {
db::c()->query('INSERT INTO clans (owner_id, full_name, short_name, info) VALUES (?i,"?s","?s","?s")', $user->id, $clanFullName, $clanShortName, $clanInfo);
db::c()->query('INSERT INTO clans (owner_id, full_name, short_name, info) VALUES (?i,"?s","?s","?s")', $user->getId(), $clanFullName, $clanShortName, $clanInfo);
$userBank->setMoney($userBank->getMoney() - Config::$clan_register_cost);
Battles\Bank::setBankMoney($userBank->getMoney(), $user->id, 'clanRegister');
Battles\Bank::setBankMoney($userBank->getMoney(), $user->getId(), 'clanRegister');
// Заглушка для отображения данных по только что зарегистрированному клану, когда запрос в базу в начале файла ещё не проходит.
$userClan = new stdClass();
$userClan->full_name = $clanFullName;
@ -51,8 +57,8 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
}
}
}
\Battles\Template::header(\Battles\Rooms::$roomNames[30]);
\Battles\Template::buildingTop(\Battles\Rooms::$roomNames[30], 'strah');
Template::header(Rooms::$roomNames[30]);
Template::buildingTop(Rooms::$roomNames[30], 'strah');
if ($userClan): ?>
<div>
<fieldset style="display: inline;">

View File

@ -15,9 +15,9 @@ class Nick extends User
* Отображение иконки склонности.
* @return string
*/
private function getAlign():?string
private function getAlignToNickname():?string
{
if (isset($this->align)) {
if ($this->align) {
return sprintf('<img src="i/align_%s.gif">', $this->align);
} else {
return null;
@ -28,9 +28,9 @@ class Nick extends User
* Отображение иконки клана.
* @return string
*/
private function getClan():?string
private function getClanToNickname():?string
{
if (isset($this->clan)) {
if ($this->clan) {
return sprintf('<img src="i/clan/%s.png">', $this->clan);
} else {
return null;
@ -60,7 +60,7 @@ class Nick extends User
if ($showInvisibility && $this->getInvisibilityStatus()) {
return INVIS;
}
return $this->getAlign().$this->getClan().sprintf('<b>%s</b> [%s] <a href="inf.php?%s" target="_blank"><img src="i/inf.gif" style="width:12px;height:11px"></a>', $this->login, $this->level, $this->login);
return $this->getAlignToNickname().$this->getClanToNickname().sprintf('<b>%s</b> [%s] <a href="inf.php?%s" target="_blank"><img src="i/inf.gif" style="width:12px;height:11px"></a>', $this->login, $this->level, $this->login);
}
/**

View File

@ -7,17 +7,17 @@ use Exceptions\GameException;
class User
{
public $id = 0;
public $login = '<em>Некто</em>';
public $pass;
public $email = '<em>неизвестно</em>';
public $realname;
public $borndate;
public $info;
public $level = 0;
public $align = 0;
public $clan = 0;
public $money = 0;
protected $id = 0;
protected $login = '<em>Некто</em>';
protected $pass;
protected $email = '<em>неизвестно</em>';
protected $realname;
protected $borndate;
protected $info;
protected $level = 0;
protected $align = 0;
protected $clan = 0;
protected $money = 0;
public $strength = 0;
public $dexterity = 0;
public $intuition = 0;
@ -176,4 +176,598 @@ class User
}
return false;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return string
*/
public function getLogin(): string
{
return $this->login;
}
/**
* @param string $login
*/
public function setLogin(string $login): void
{
$this->login = $login;
}
/**
* @return mixed
*/
public function getPass()
{
return $this->pass;
}
/**
* @param mixed $pass
*/
public function setPass($pass): void
{
$this->pass = $pass;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email): void
{
$this->email = $email;
}
/**
* @return mixed
*/
public function getRealname()
{
return $this->realname;
}
/**
* @param mixed $realname
*/
public function setRealname($realname): void
{
$this->realname = $realname;
}
/**
* @return mixed
*/
public function getBorndate()
{
return $this->borndate;
}
/**
* @param mixed $borndate
*/
public function setBorndate($borndate): void
{
$this->borndate = $borndate;
}
/**
* @return mixed
*/
public function getInfo()
{
return $this->info;
}
/**
* @param mixed $info
*/
public function setInfo($info): void
{
$this->info = $info;
}
/**
* @return int
*/
public function getLevel(): int
{
return $this->level;
}
/**
* @param int $level
*/
public function setLevel(int $level): void
{
$this->level = $level;
}
/**
* @return int
*/
public function getAlign(): int
{
return $this->align;
}
/**
* @param int $align
*/
public function setAlign(int $align): void
{
$this->align = $align;
}
/**
* @return int
*/
public function getClan(): int
{
return $this->clan;
}
/**
* @param int $clan
*/
public function setClan(int $clan): void
{
$this->clan = $clan;
}
/**
* @return int
*/
public function getMoney(): int
{
return $this->money;
}
/**
* @param int $money
*/
public function setMoney(int $money): void
{
$this->money = $money;
}
/**
* @return int
*/
public function getStrength(): int
{
return $this->strength;
}
/**
* @param int $strength
*/
public function setStrength(int $strength): void
{
$this->strength = $strength;
}
/**
* @return int
*/
public function getDexterity(): int
{
return $this->dexterity;
}
/**
* @param int $dexterity
*/
public function setDexterity(int $dexterity): void
{
$this->dexterity = $dexterity;
}
/**
* @return int
*/
public function getIntuition(): int
{
return $this->intuition;
}
/**
* @param int $intuition
*/
public function setIntuition(int $intuition): void
{
$this->intuition = $intuition;
}
/**
* @return int
*/
public function getEndurance(): int
{
return $this->endurance;
}
/**
* @param int $endurance
*/
public function setEndurance(int $endurance): void
{
$this->endurance = $endurance;
}
/**
* @return int
*/
public function getIntelligence(): int
{
return $this->intelligence;
}
/**
* @param int $intelligence
*/
public function setIntelligence(int $intelligence): void
{
$this->intelligence = $intelligence;
}
/**
* @return int
*/
public function getWisdom(): int
{
return $this->wisdom;
}
/**
* @param int $wisdom
*/
public function setWisdom(int $wisdom): void
{
$this->wisdom = $wisdom;
}
/**
* @return mixed
*/
public function getIp()
{
return $this->ip;
}
/**
* @param mixed $ip
*/
public function setIp($ip): void
{
$this->ip = $ip;
}
/**
* @return mixed
*/
public function getSessionId()
{
return $this->session_id;
}
/**
* @param mixed $session_id
*/
public function setSessionId($session_id): void
{
$this->session_id = $session_id;
}
/**
* @return int
*/
public function getAdmin(): int
{
return $this->admin;
}
/**
* @param int $admin
*/
public function setAdmin(int $admin): void
{
$this->admin = $admin;
}
/**
* @return mixed
*/
public function getEnterGame()
{
return $this->enter_game;
}
/**
* @param mixed $enter_game
*/
public function setEnterGame($enter_game): void
{
$this->enter_game = $enter_game;
}
/**
* @return mixed
*/
public function getRoom()
{
return $this->room;
}
/**
* @param mixed $room
*/
public function setRoom($room): void
{
$this->room = $room;
}
/**
* @return mixed
*/
public function getBlock()
{
return $this->block;
}
/**
* @param mixed $block
*/
public function setBlock($block): void
{
$this->block = $block;
}
/**
* @return mixed
*/
public function getShadow()
{
return $this->shadow;
}
/**
* @param mixed $shadow
*/
public function setShadow($shadow): void
{
$this->shadow = $shadow;
}
/**
* @return int
*/
public function getMinDamage(): int
{
return $this->minDamage;
}
/**
* @param int $minDamage
*/
public function setMinDamage(int $minDamage): void
{
$this->minDamage = $minDamage;
}
/**
* @return int
*/
public function getMaxDamage(): int
{
return $this->maxDamage;
}
/**
* @param int $maxDamage
*/
public function setMaxDamage(int $maxDamage): void
{
$this->maxDamage = $maxDamage;
}
/**
* @return int
*/
public function getHeadArmor(): int
{
return $this->headArmor;
}
/**
* @param int $headArmor
*/
public function setHeadArmor(int $headArmor): void
{
$this->headArmor = $headArmor;
}
/**
* @return int
*/
public function getChestArmor(): int
{
return $this->chestArmor;
}
/**
* @param int $chestArmor
*/
public function setChestArmor(int $chestArmor): void
{
$this->chestArmor = $chestArmor;
}
/**
* @return int
*/
public function getLegArmor(): int
{
return $this->legArmor;
}
/**
* @param int $legArmor
*/
public function setLegArmor(int $legArmor): void
{
$this->legArmor = $legArmor;
}
/**
* @return int
*/
public function getFreeStatPoints(): int
{
return $this->free_stat_points;
}
/**
* @param int $free_stat_points
*/
public function setFreeStatPoints(int $free_stat_points): void
{
$this->free_stat_points = $free_stat_points;
}
/**
* @return string
*/
public function getMarried(): string
{
return $this->married;
}
/**
* @param string $married
*/
public function setMarried(string $married): void
{
$this->married = $married;
}
/**
* @return int
*/
public function getExperience(): int
{
return $this->experience;
}
/**
* @param int $experience
*/
public function setExperience(int $experience): void
{
$this->experience = $experience;
}
/**
* @return int
*/
public function getBattle(): int
{
return $this->battle;
}
/**
* @param int $battle
*/
public function setBattle(int $battle): void
{
$this->battle = $battle;
}
/**
* @return int
*/
public function getInTower(): int
{
return $this->in_tower;
}
/**
* @param int $in_tower
*/
public function setInTower(int $in_tower): void
{
$this->in_tower = $in_tower;
}
/**
* @return int
*/
public function getZayavka(): int
{
return $this->zayavka;
}
/**
* @param int $zayavka
*/
public function setZayavka(int $zayavka): void
{
$this->zayavka = $zayavka;
}
/**
* @return float|int
*/
public function getMaxHealth()
{
return $this->maxHealth;
}
/**
* @param float|int $maxHealth
*/
public function setMaxHealth($maxHealth): void
{
$this->maxHealth = $maxHealth;
}
/**
* @return float|int
*/
public function getMaxMana()
{
return $this->maxMana;
}
/**
* @param float|int $maxMana
*/
public function setMaxMana($maxMana): void
{
$this->maxMana = $maxMana;
}
}

View File

@ -20,11 +20,11 @@ if ($putItemId) {
$putItemCost = $dress['cost'];
}
$commission = ceil($putItemCost / 10); # 10% от суммы с округлением вверх.
if ($user->money > $commission) {
if ($user->getMoney() > $commission) {
if (db::c()->getAffectedRows()) {
$deloText = "{$user->login} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. ";
GameLogs::addUserLog($user->id, $deloText);
$deloText = "{$user->getLogin()} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. ";
GameLogs::addUserLog($user->getId(), $deloText);
db::c()->query('UPDATE `inventory` SET `setsale` = ?i WHERE `id` = ?i', $putItemCost, $putItemId);
db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', $commission, $_SESSION['uid']);
$status = "Вы сдали в магазин «{$dress['name']}» за {$putItemCost} кр. Вычтено за услуги магазина: {$commission} кр.";
@ -32,15 +32,15 @@ if ($putItemId) {
$status = "Предмет не найден в инвентаре!";
}
} else {
$status = "У вас не хватает " . $commission - $user->money . " кр. чтобы оплатить комиссию!";
$status = "У вас не хватает " . $commission - $user->getMoney() . " кр. чтобы оплатить комиссию!";
}
}
if ($returningItemId) {
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i AND `owner` = ?i', $returningItemId, $_SESSION['uid'])->fetch_assoc();
if (db::c()->getAffectedRows()) {
$deloText = "{$user->login} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки.";
GameLogs::addUserLog($user->id, $deloText);
$deloText = "{$user->getLogin()} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки.";
GameLogs::addUserLog($user->getId(), $deloText);
db::c()->query('UPDATE `inventory` SET `setsale` = 0 WHERE `id` = ?i', $returningItemId);
$status = "Вы забрали из магазина ваш «{$dress['name']}».";
} else {
@ -53,16 +53,16 @@ if ($byingItemId) {
$seller = db::c()->query('SELECT `login` FROM `users` WHERE `id` =?i', $dress['owner'])->fetch_assoc();
if ($dress['setsale']) {
if ($user->money >= $dress['setsale']) {
db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $user->id, $byingItemId);
db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $user->id);
if ($user->getMoney() >= $dress['setsale']) {
db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $user->getId(), $byingItemId);
db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $user->getId());
db::c()->query('UPDATE `users` set `money` = `money` + ?i WHERE `id` = ?i', $dress['setsale'], $dress['owner']);
$status = "Вы купили «{$dress['name']}» за {$dress['setsale']} кр.";
$deloText = "{$user->login} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр.";
GameLogs::addUserLog($user->id, $deloText);
$deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user->login} за {$dress['setsale']} кр.";
$deloText = "{$user->getLogin()} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр.";
GameLogs::addUserLog($user->getId(), $deloText);
$deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user->getLogin()} за {$dress['setsale']} кр.";
GameLogs::addUserLog($dress['owner'], $deloText);
$user->money -= $dress['setsale'];
$user->setMoney($user->getMoney() - $dress['setsale']);
telegraph($dress['owner'], "Предмет «{$dress['name']}» продан на рынке за {$dress['setsale']} кр.");
} else {
$status = "Недостаточно средств!";

View File

@ -17,7 +17,7 @@ if (empty($_SESSION['uid'])) {
$user = new User($_SESSION['uid']);
}
if ($user->id && $user->block) {
if ($user->getId() && $user->block) {
exit('user blocked!');
}
@ -140,7 +140,7 @@ function takeshopitem($item, $table = "shop", $present = '', $onlyonetrip = '',
$flds = [];
$goden = '';
if (!$uid) {
$uid = $user->id;
$uid = $user->getId();
}
$r = db::c()->query('SHOW FIELDS FROM ?f', $table);
@ -300,7 +300,7 @@ function echoscroll($slot)
$dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user->$slot)->fetch_assoc();
$need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
if (($user->$slot > 0) && ($all_magic[$user->id] < 1 || empty($need_charge['needcharge']))) {
if (($user->$slot > 0) && ($all_magic[$user->getId()] < 1 || empty($need_charge['needcharge']))) {
$row['id'] = $user->$slot;
if ($dress['magic']) {
$magic = db::c()->query('SELECT targeted FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
@ -318,7 +318,7 @@ function echoscroll($slot)
echo <<<ACTIVE_SCROLL
<img class='tooltip' src="i/sh/{$dress['img']}" width='40' title="<b>{$dress['name']}</b><br> Прочность {$dress['duration']} / {$dress['maxdur']} " height='25' alt="Свиток"></a>
ACTIVE_SCROLL;
} elseif (($user->$slot > 0) && ($all_magic[$user->id] >= 1) && $need_charge['needcharge'] > 0) {
} elseif (($user->$slot > 0) && ($all_magic[$user->getId()] >= 1) && $need_charge['needcharge'] > 0) {
echo <<<INACTIVE_SCROLL
<img src="i/sh/magicclock.gif" width="40" height="25" title='Произведите размен ударами и магия снова станет доступна' alt="Свиток">
INACTIVE_SCROLL;
@ -650,11 +650,11 @@ function dropitem($slot)
`u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`,
`u`.`uminu` = `u`.`uminu` - `i`.`minu`,
`u`.`umaxu` = `u`.`umaxu` - `i`.`maxu`
WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user->id, $user->id)) {
db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user->id);
WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user->getId(), $user->getId())) {
db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user->getId());
}
$wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user->id);
$wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user->getId());
while ($wear_list = $wear_raw->fetch_assoc()) {
$wear_arr[] = $wear_list['prototype'];
}
@ -714,7 +714,7 @@ function dropitem($slot)
`u`.`mlight = `u`.`mlight - `s`.`glight`,
`u`.`mgray = `u`.`mgray - `s`.`ggray`
WHERE
`u`.`id` = ?i AND `s`.`set_id`= ?i', $user->id, $set_id);
`u`.`id` = ?i AND `s`.`set_id`= ?i', $user->getId(), $set_id);
}
}
return true;
@ -781,7 +781,7 @@ function ref_drop()
function destructitem($id)
{
global $user;
$item = db::c()->query('SELECT 1 FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->id, $id);
$item = db::c()->query('SELECT 1 FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $id);
if ($item->getNumRows()) {
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id);
}
@ -791,7 +791,7 @@ function destructitem($id)
function usemagic($id, $target)
{
global $user;
$row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user->id, $id)->fetch_assoc_array();
$row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user->getId(), $id)->fetch_assoc_array();
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user->battle)->fetch_assoc_array();
$all_magic = unserialize($bat['magic']);
$charge = 0;
@ -806,7 +806,7 @@ function usemagic($id, $target)
$charge = $incmagic['needcharge'];
}
//Переделать под новую базу
if (($all_magic[$user->id] < 1 || $charge == 0) &&
if (($all_magic[$user->getId()] < 1 || $charge == 0) &&
($user['sila'] >= $row['nsila'] &&
$user['lovk'] >= $row['nlovk'] &&
$user['inta'] >= $row['ninta'] &&
@ -867,7 +867,7 @@ function usemagic($id, $target)
} else {
$all_magic = unserialize($bat['magic']);
}
$all_magic[$user->id] += $charge;
$all_magic[$user->getId()] += $charge;
db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user->battle);
}
}

View File

@ -17,7 +17,7 @@ if ($get == 'exit') {
require_once 'functions.php';
try {
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->id);
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->getId());
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div class='debug' '>Ошибка: " . $e->getMessage() . "<br> Стек: " . $e->getTraceAsString() . "</div>";
}
@ -34,7 +34,7 @@ $ids = $_GET['ids'] ?? null;
$setShadow = $_POST['setshadow'] ?? null;
$edit = $_GET['edit'] ?? null;
// Подготавливаем отображение инфы и предметов.
$userInfo = new UserInfo($user->id);
$userInfo = new UserInfo($user->getId());
$getItemsBonuses = new DressedItems($_SESSION['uid']);
$data_query = 'SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot = 0 AND on_sale = 0';
$data = db::c()->query($data_query, $_SESSION['uid']);
@ -170,8 +170,8 @@ function dressitem($id)
// Входим и выходим если можем.
if ($goto) {
$imove = true;
$d = db::c()->query('SELECT SUM(weight) AS sum_weight FROM inventory WHERE owner_id = ?i AND on_sale = 0', $user->id)->fetch_assoc();
$eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', $user->id);
$d = db::c()->query('SELECT SUM(weight) AS sum_weight FROM inventory WHERE owner_id = ?i AND on_sale = 0', $user->getId())->fetch_assoc();
$eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', $user->getId());
//(масса: <?= $getItemsBonuses->getItemsWeight() . '/' . $user->strength * 4
if ($d['sum_weight'] > $user->strength * 4 && $goto) {
@ -210,7 +210,7 @@ function setShadow($image)
];
if (in_array($image, $shadows)) {
$i = $image . '.png';
db::c()->query('UPDATE `users` SET `shadow` = "?s" WHERE `id` = ?i', $i, $user->id);
db::c()->query('UPDATE `users` SET `shadow` = "?s" WHERE `id` = ?i', $i, $user->getId());
} else {
err('Ошибка!');
}
@ -221,7 +221,7 @@ if ($obraz && ($user->shadow == 'g0.gif' || $user->shadow == 'man0.gif')) {
}
if ($del == 1 && $effectId > 0) {
$pl = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $user->id, $effectId)->fetch_assoc();
$pl = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $user->getId(), $effectId)->fetch_assoc();
if (isset($pl['type'])) {
echo del_efs($effectId, $pl['type']);
} else {
@ -231,26 +231,26 @@ if ($del == 1 && $effectId > 0) {
if ($brons && $ids) {
try {
$cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user->id, $ids)->fetch_assoc();
$cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user->getId(), $ids)->fetch_assoc();
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
}
if ($cur['free_bron'] > 0 && $cur[$brons] > 0) {
db::c()->query('UPDATE inventory SET free_bron = free_bron - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $brons, $brons, $user->id, $ids);
db::c()->query('UPDATE inventory SET free_bron = free_bron - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $brons, $brons, $user->getId(), $ids);
echo "<span class='success'>Параметр брони увеличен!</span>";
}
}
if ($stats && $ids) {
$cur = db::c()->query('SELECT free_stat, gsila, glovk, ginta, gintel FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->id, $ids);
$cur = db::c()->query('SELECT free_stat, gsila, glovk, ginta, gintel FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $ids);
if ($cur['free_stat'] > 0 && $cur[$stats] > 0) {
db::c()->query('UPDATE inventory SET free_stat = free_stat - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $stats, $stats, $user->id, $ids);
db::c()->query('UPDATE inventory SET free_stat = free_stat - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $stats, $stats, $user->getId(), $ids);
echo "<span class='success'>Параметр увеличен!</span>";
}
}
if ($mfs && $ids) {
$cur = db::c()->query('SELECT free_mf, mfkrit, mfuvorot, mfakrit, mfauvorot FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->id, $ids);
$cur = db::c()->query('SELECT free_mf, mfkrit, mfuvorot, mfakrit, mfauvorot FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $ids);
if (isset($cur['id']) && $cur['free_mf'] > 0 && $cur[$mfs] > 0) {
db::c()->query('UPDATE inventory SET free_mf = free_mf - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $mfs, $mfs, $user->id, $ids);
db::c()->query('UPDATE inventory SET free_mf = free_mf - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $mfs, $mfs, $user->getId(), $ids);
echo "<span class='success'>Параметр увеличен!</span>";
}
}
@ -319,7 +319,7 @@ if ($edit) {
$q = $q->fetch_assoc();
if (empty($q['dressed'])) {
destructitem($q['id']);
GameLogs::addUserLog($user->id, $user->login . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")");
GameLogs::addUserLog($user->getId(), $user->getLogin() . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")");
err('Предмет ' . $q['name'] . ' выброшен.');
} else {
err('Ошибка: нельзя выбросить одетый предмет!');
@ -371,19 +371,19 @@ Template::header('Игра');
<div align="center">
<a href='main.php?edit=1&undress=all' class="button">Снять все</a><BR>
<div class="effectList" style="padding-top: 15px; max-height: 150px; width: 220px;">
<?= show_eff_inf($user->id) ?>
<?= show_eff_inf($user->getId()) ?>
</div>
</div>
<br>
</td>
<td style="vertical-align: top; width: 250px"> <!-- Второй столбец -->
<div>
<br>Уровень: <strong><?= $user->level ?></strong>
<br>Уровень: <strong><?= $user->getLevel() ?></strong>
<br>Опыт: <strong><?= $user->experience ?></strong>
<br>Побед: <strong>??</strong>
<br>Поражений: <strong>??</strong>
<br>Ничьих: <strong>??</strong>
<br>Деньги: <strong><?= $user->money ?></strong> кр.
<br>Деньги: <strong><?= $user->getMoney() ?></strong> кр.
<HR>
</div>
<!--Параметры-->

View File

@ -1,4 +1,7 @@
<?php
use Battles\Template;
session_start();
if (empty($_SESSION['uid'])) {
header('Location: /index.php');
@ -23,15 +26,15 @@ $qsee = '';
$qx = 0;
$error = '';
\Battles\Template::header('module_quest');
Template::header('module_quest');
?>
<link rel="stylesheet" href="css/hostel.css"/>
<?php
$sp = db::c()->query('SELECT `vars` FROM `actions` WHERE `vars` LIKE "?S" AND `vals` = "?s" AND `uid` = ?i LIMIT 100', "%start_quest%", "go", $user->id);
$sp = db::c()->query('SELECT `vars` FROM `actions` WHERE `vars` LIKE "?S" AND `vals` = "?s" AND `uid` = ?i LIMIT 100', "%start_quest%", "go", $user->getId());
while ($pl = $sp->fetch_assoc()) {
$questId = str_replace('start_quest', '', $pl['vars']);
$pq = db::c()->query('SELECT `id`,`name`,`info` FROM `quests` WHERE `id` = ?i', $questId)->fetch_assoc();
$qsee .= sprintf('<a href="?end_qst_now=%s"><img src="/i/clear.gif" title="Отказаться от задания"></a> <b>%s</b><span style="float: right;"><a href="?end_qst=%s">Выполнить</a></span><div style="padding-left: 15px; padding-bottom: 5px; border-bottom: 1px solid grey;"><small>%s<br>$s</small></div><br>', $pq['id'], $pq['name'], $pq['id'], $pq['info'], $q->info($pq, $user->id));
$qsee .= sprintf('<a href="?end_qst_now=%s"><img src="/i/clear.gif" title="Отказаться от задания"></a> <b>%s</b><span style="float: right;"><a href="?end_qst=%s">Выполнить</a></span><div style="padding-left: 15px; padding-bottom: 5px; border-bottom: 1px solid grey;"><small>%s<br>$s</small></div><br>', $pq['id'], $pq['name'], $pq['id'], $pq['info'], $q->info($pq, $user->getId()));
$qx++;
}

View File

@ -29,11 +29,11 @@ if ($_SESSION['receiverName']) {
$sendItemId = $_POST['item_id'] ?? 0;
$telegraphText = $_POST['message'] ?? 0;
if ($submit == 'sendMessage' && $telegraphText && $user->money) {
if ($submit == 'sendMessage' && $telegraphText && $user->getMoney()) {
if ($telegraphText) {
$user->money -= 1;
Bank::setWalletMoney($user->money, $user->id);
$user->setMoney($user->getMoney() - 1);
Bank::setWalletMoney($user->getMoney(), $user->getId());
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, $telegraphText);
$statusMessage = 'Сообщение отправлено.';
} else {
@ -41,13 +41,13 @@ if ($_SESSION['receiverName']) {
}
}
if ($submit == 'sendItem' && $sendItemId && $user->money) {
$res = db::c()->query('SELECT name FROM inventory WHERE owner_id = ?i AND item_id = ?i AND dressed_slot = 0 AND on_sale = 0', $user->id, $sendItemId)->fetch_assoc();
if ($submit == 'sendItem' && $sendItemId && $user->getMoney()) {
$res = db::c()->query('SELECT name FROM inventory WHERE owner_id = ?i AND item_id = ?i AND dressed_slot = 0 AND on_sale = 0', $user->getId(), $sendItemId)->fetch_assoc();
if (!$res) {
$statusMessage = "Предмет не найден в рюкзаке.";
} else {
$user->money -= 1;
Bank::setWalletMoney($user->money, $user->id);
$user->setMoney($user->getMoney() - 1);
Bank::setWalletMoney($user->getMoney(), $user->getId());
db::c()->query('UPDATE `inventory` SET owner_id = ?i WHERE item_id= ?i AND owner_id = ?i', $receiverId, $sendItemId, $_SESSION['uid']);
$statusMessage = 'Предмет "' . $res['name'] . '" передан персонажу ' . Nick::id($receiverId)->short(1);
$receiverLogMessage = 'Получен предмет "' . $res['name'] . '" от персонажа ' . Nick::id($_SESSION['uid'])->short(1);
@ -59,7 +59,7 @@ if ($_SESSION['receiverName']) {
}
}
$queryItems = db::c()->query('SELECT * FROM inventory WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ?i', $user->id);
$queryItems = db::c()->query('SELECT * FROM inventory WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ?i', $user->getId());
while ($row = $queryItems->fetch_assoc()) {
$iteminfo[] = new InventoryItem($row);
}

View File

@ -13,6 +13,9 @@
*
*/
use Battles\Template;
use Battles\User;
session_start();
if ($_SESSION['uid'] != 2) {
header("Location: index.php");
@ -20,7 +23,7 @@ if ($_SESSION['uid'] != 2) {
}
require_once 'config.php';
$user = new \Battles\User($_SESSION['uid']);
$user = new User($_SESSION['uid']);
$status = '';
$dirname = "i/presents/";
$images = glob($dirname . "*.png");
@ -44,28 +47,28 @@ if (!empty($_POST['sendAction'])) {
$_POST['days'] = 1;
}
$cost = $_POST['days'] * 5;
if ($user->money < $cost) {
if ($user->getMoney() < $cost) {
$status = "Не хватает кредитов на оплату подарка!";
return;
}
if ($_POST['sender'] == 1) {
$sender = "Анонимный подарок";
} elseif ($_POST['sender'] == 2 && $user->clan) {
$sender = "Подарок от клана {$user->clan}";
} elseif ($_POST['sender'] == 2 && $user->getClan()) {
$sender = "Подарок от клана {$user->getClan()}";
} else {
$sender = "Подарок от {$user->login}";
$sender = "Подарок от {$user->getLogin()}";
}
$user->money -= $cost;
Bank::setWalletMoney($user->money, $user->id);
$user->setMoney($user->getMoney() - $cost);
Bank::setWalletMoney($user->getMoney(), $user->getId());
db::c()->query('INSERT INTO users_presents (owner, img, text, sender, expiration_date) VALUES (?i,"?s","?s","?s",DATE_ADD(CURDATE(),INTERVAL ?i DAY))', $receiver['id'], $_POST['present'], $_POST['text'], $sender, $_POST['days']);
$telegraphText = "Вам пришёл подарок от {$sender}!";
db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText);
$status = "Подарок удачно доставлен к {$_POST['receiver']}! Вы потратили <b>{$cost}</b> кр.";
}
\Battles\Template::header('Дарильня');
Template::header('Дарильня');
?>
<script src="js/main.js"></script>
<style>
@ -102,10 +105,10 @@ if (!empty($_POST['sendAction'])) {
rows=6 cols=80
placeholder="Текст сопроводительной записки (в информации о персонаже не отображается). Заполнять не обязательно."></textarea><br>
<br>Выберите, от чьего имени подарок:<br>
<label><input type=radio name=sender value=0 checked> <?= $user->login ?></label><br>
<label><input type=radio name=sender value=0 checked> <?= $user->getLogin() ?></label><br>
<label><input type=radio name=sender value=1> анонимно</label><br>
<?php if (!empty($user['ClanName'])): ?>
<label><input type=radio name=sender value=2> от имени клана <b><?= $user->clan ?></b></label><br>
<label><input type=radio name=sender value=2> от имени клана <b><?= $user->getClan() ?></b></label><br>
<?php endif; ?>
<br>Долговечность подарка (5кр в день):<br>
<input name="days" placeholder="Количество дней"><br>

View File

@ -1,4 +1,7 @@
<?php
use Battles\Template;
session_start();
if (empty($_SESSION['uid'])) {
header('Location: /index.php');
@ -54,10 +57,10 @@ function info_quest($id)
if (!empty($q->error)) {
$status = $q->error;
}
\Battles\Template::header('Памятник');
Template::header('Памятник');
?>
<div style="float: right;">
<?php if (($user->level < 5 || $user->admin) && $user->health < $user->maxHealth): ?>
<?php if (($user->getLevel() < 5 || $user->admin) && $user->health < $user->maxHealth): ?>
<button onclick="location.href='?hps'">Восстановить здоровье</button>
<? endif ?>
<button onclick="location.href='?'">Обновить</button>

View File

@ -29,11 +29,11 @@ $gravirovka_query = null;
// Гравировка 30 кред. Максимум 32 символа.
if ($gravirovkaText && $itemId) {
if ($user->money >= GRAV_COST) {
if ($user->getMoney() >= GRAV_COST) {
if (iconv_strlen($gravirovkaText) <= GRAV_LIMIT) {
$db->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, $user->id, $itemId]);
$user->money -= GRAV_COST;
Bank::setWalletMoney($user->money, $user->id);
$db->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, $user->getId(), $itemId]);
$user->setMoney($user->getMoney() - GRAV_COST);
Bank::setWalletMoney($user->getMoney(), $user->getId());
$status = REPAIR_STATUS['OK_GRAV_ADDED'];
} else {
$status = REPAIR_STATUS['ERROR_SIZE_LIMIT'];
@ -44,10 +44,10 @@ if ($gravirovkaText && $itemId) {
}
// Снять гравировку.
if ($gravirovkaRemove) {
if ($user->money >= GRAV_COST) {
$db->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->id, $itemId]);
$user->money -= GRAV_COST;
Bank::setWalletMoney($user->money, $user->id);
if ($user->getMoney() >= GRAV_COST) {
$db->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]);
$user->setMoney($user->getMoney() - GRAV_COST);
Bank::setWalletMoney($user->getMoney(), $user->getId());
$status = REPAIR_STATUS['OK_GRAV_REMOVED'];
} else {
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
@ -57,21 +57,21 @@ if ($gravirovkaRemove) {
// Пока что лимит ремонта поставлен на 25. Дальше можно обыграть.
if ($action == 'repair' && $itemId) {
$q = $db->ofetch('SELECT name, durability FROM inventory WHERE item_id = ?', $itemId);
if ($user->money > ceil($q->duration / 2)) {
$db->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->id, $itemId]);
$user->money -= ceil($q->duration / 2);
Bank::setWalletMoney($user->money, $user->id);
GameLogs::addUserLog($user->id, 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->duration / 2) . ' кр.');
if ($user->getMoney() > ceil($q->duration / 2)) {
$db->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]);
$user->setMoney($user->getMoney() - ceil($q->duration / 2));
Bank::setWalletMoney($user->getMoney(), $user->getId());
GameLogs::addUserLog($user->getId(), 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->duration / 2) . ' кр.');
$status = REPAIR_STATUS['OK_REPAIRED'];
} else {
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
}
}
if ($goto == 'remont') {
$remont_query = $db->ofetchAll('SELECT item_id, name, image, durability FROM inventory WHERE item_type < 12 AND dressed_slot = 0 AND on_sale = 0 AND durability < 25 AND owner_id = ? ORDER BY name', $user->id);
$remont_query = $db->ofetchAll('SELECT item_id, name, image, durability FROM inventory WHERE item_type < 12 AND dressed_slot = 0 AND on_sale = 0 AND durability < 25 AND owner_id = ? ORDER BY name', $user->getId());
}
if ($goto == 'gravirovka') {
$gravirovka_query = $db->ofetchAll('SELECT item_id, name, image, text FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND item_type = 3 AND name NOT LIKE "%Букет%" AND on_sale = 0 OR text IS NOT NULL AND owner_id = ? AND dressed_slot = 0 AND on_sale = 0 ORDER BY name', [$user->id, $user->id]);
$gravirovka_query = $db->ofetchAll('SELECT item_id, name, image, text FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND item_type = 3 AND name NOT LIKE "%Букет%" AND on_sale = 0 OR text IS NOT NULL AND owner_id = ? AND dressed_slot = 0 AND on_sale = 0 ORDER BY name', [$user->getId(), $user->getId()]);
}
Template::header('Кузня');
?>

View File

@ -140,8 +140,8 @@ if ($sellItemId) {
$status = "Вы продали «{$dress['name']}» $kols за " . $allcost . " кр.";
}
$deloText = "{$user->login} продал товар «{$dress['name']}» {$kols}id:({$dress['id']}) в магазине за {$allcost} кр.";
GameLogs::addUserLog($user->id, $deloText);
$deloText = "{$user->getLogin()} продал товар «{$dress['name']}» {$kols}id:({$dress['id']}) в магазине за {$allcost} кр.";
GameLogs::addUserLog($user->getId(), $deloText);
// Для обновления данных о деньгах на странице
$user['money'] += $allcost;
}
@ -229,8 +229,8 @@ if (!empty($_GET['buy'])) {
}
$status = "Вы купили «{$dress['name']}» за {$dress['cost']} кр.";
db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['cost'], $_SESSION['uid']);
$deloText = "{$user->login} купил товар «{$dress['name']}» id:({$inventoryItemId}) в магазине за {$dress['cost']} кр.";
GameLogs::addUserLog($user->id, $deloText);
$deloText = "{$user->getLogin()} купил товар «{$dress['name']}» id:({$inventoryItemId}) в магазине за {$dress['cost']} кр.";
GameLogs::addUserLog($user->getId(), $deloText);
// Для обновления данных о деньгах на странице
$user['money'] -= $dress['cost'];

View File

@ -6,9 +6,12 @@
* One file to rule 'em all!
*/
use Battles\Template;
use Battles\User;
session_start();
require_once 'functions.php';
$user = $user ?? new \Battles\User($_SESSION['uid']);
$user = $user ?? new User($_SESSION['uid']);
if (!empty($_GET['teleport']) && $user->admin == 1) {
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 20,`online`.`room` = 20 WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_SESSION['uid']);
}
@ -16,47 +19,47 @@ if (!empty($_GET['teleport']) && $user->admin == 1) {
# ORDEN PHP
if ($user->admin) {
$abil = db::c()->query('SELECT abil FROM users WHERE id = ?i', $user->id)->fetch_assoc();
$abil = db::c()->query('SELECT abil FROM users WHERE id = ?i', $user->getId())->fetch_assoc();
$abil = unserialize($abil['abil']);
switch ($_POST['use']) {
case "healing":
include("./magic/Healing.php");
break;
case "ct1":
if ($abil[0] > 0 && $user->align == 6) {
if ($abil[0] > 0 && $user->getAlign() == 6) {
//Заменён на CureInjury.php class. Придумать вызов.
//include("./magic/ct1.php");
if ($outok == 1) {
$abil[0] -= 1;
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->getId());
}
} elseif ($user->align != 6) {
} elseif ($user->getAlign() != 6) {
//Заменён на CureInjury.php class. Придумать вызов.
//include("./magic/ct1.php");
}
break;
case "ct2":
if ($abil[1] > 0 && $user->align == 6) {
if ($abil[1] > 0 && $user->getAlign() == 6) {
//Заменён на CureInjury.php class. Придумать вызов.
//include("./magic/ct2.php");
if ($outok == 1) {
$abil[1] -= 1;
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->getId());
}
} elseif ($user->align != 6) {
} elseif ($user->getAlign() != 6) {
//Заменён на CureInjury.php class. Придумать вызов.
//include("./magic/ct2.php");
}
break;
case "ct3":
if ($abil[2] > 0 && $user->align == 6) {
if ($abil[2] > 0 && $user->getAlign() == 6) {
//Заменён на CureInjury.php class. Придумать вызов.
//include("./magic/ct3.php");
if ($outok == 1) {
$abil[2] -= 1;
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->getId());
}
} elseif ($user->align != 6) {
} elseif ($user->getAlign() != 6) {
//Заменён на CureInjury.php class. Придумать вызов.
//include("./magic/ct3.php");
}
@ -84,11 +87,11 @@ if ($user->admin) {
break;
case "attackk_close":
if ($abil[1] > 0 && $user->align == 2) {
if ($abil[1] > 0 && $user->getAlign() == 2) {
include("./magic/attackk_close.php");
if ($outok == 1) {
$abil[1] -= 1;
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->getId());
header("Location:fbattle.php");
exit();
}
@ -100,11 +103,11 @@ if ($user->admin) {
break;
case "attackk_open":
if ($abil[1] > 0 && $user->align == 2) {
if ($abil[1] > 0 && $user->getAlign() == 2) {
include("./magic/attackk_open.php");
if ($outok == 1) {
$abil[2] -= 1;
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->id);
db::c()->query('UPDATE users SET abil = "?s" WHERE id = ?i', serialize($abil), $user->getId());
header("Location:fbattle.php");
exit();
}
@ -145,8 +148,8 @@ function klan_relicts()
{
global $user;
$r = '';
if ($user->clan > 0) {
$abils = db::c()->query('SELECT `id`, `klan`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_klan` WHERE `klan` = ?i', $user->clan)->fetch_assoc();
if ($user->getClan() > 0) {
$abils = db::c()->query('SELECT `id`, `klan`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_klan` WHERE `klan` = ?i', $user->getClan())->fetch_assoc();
if ($abils['sleep15'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?useds=1", "target")\'><img src=\'i/sh/silence15.gif\' title=\'Заклятие молчания 15 минут\' /></a><div class="amount">' . $abils['sleep15'] . '</div></div>';
} else {
@ -232,7 +235,7 @@ function user_relicts()
{
global $user;
$r = '';
$abils = db::c()->query('SELECT `id`, `uid`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_user` WHERE `uid` = ?i', $user->id)->fetch_assoc();
$abils = db::c()->query('SELECT `id`, `uid`, `sleep15`, `sleep30`, `closebattle`, `heal20`, `heal35`, `heal50`, `travmoff`, `attack`, `bloodattack`, `death`, `comment`, `openbattle`, `reamdeath`, `clone`, `unclone` FROM `abils_user` WHERE `uid` = ?i', $user->getId())->fetch_assoc();
if ($abils['sleep15'] > 0) {
$r .= '<div class="item"><a href=\'javascript: void(0);\' onclick=\'runmagic1("Введите имя персонажа", "?used=1", "target")\'><img src=\'i/sh/silence15.gif\' title=\'Заклятие молчания 15 минут\' /></a><div class="amount">' . $abils['sleep15'] . '</div></div>';
} else {
@ -407,9 +410,9 @@ function show_byu($type)
34 => 'mirror',
35 => 'antimirror',
];
if ($user->clan) {
$clan = db::c()->query('SELECT `id`, `glava` FROM `clans` WHERE `id` = ?i', $user->clan)->fetch_assoc();
if ($clan['glava'] == $user->id) {
if ($user->getClan()) {
$clan = db::c()->query('SELECT `id`, `glava` FROM `clans` WHERE `id` = ?i', $user->getClan())->fetch_assoc();
if ($clan['glava'] == $user->getId()) {
$r = '<div style="text-align: center;"><a href="javascript:void(0);" class="byu_klan" id="' . $type . '">купить 1 шт.</a></div>';
} else {
$r = '<div style="text-align: center;"><a href="javascript:void(0);">Вы не глава</a></div>';
@ -428,22 +431,22 @@ function show_byu($type)
FFFF;
}
$is_ = db::c()->query('SELECT `id` FROM `abils_user` WHERE `uid` = ?i', $user->id)->fetch_assoc();
$is_ = db::c()->query('SELECT `id` FROM `abils_user` WHERE `uid` = ?i', $user->getId())->fetch_assoc();
if (empty($is_['id'])) {
db::c()->query('INSERT INTO `abils_user` (`uid`) VALUES (?i)', $user->id);
db::c()->query('INSERT INTO `abils_user` (`uid`) VALUES (?i)', $user->getId());
}
if (empty($user->clan)) {
$is_ = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user->clan)->fetch_assoc();
if (empty($user->getClan())) {
$is_ = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user->getClan())->fetch_assoc();
if (empty($is_['id'])) {
db::c()->query('INSERT INTO `abils_klan` (`klan`) VALUES (?i)', $user->clan);
db::c()->query('INSERT INTO `abils_klan` (`klan`) VALUES (?i)', $user->getClan());
}
}
$bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['uid'])->fetch_assoc();
\Battles\Template::header('user_abilities');
Template::header('user_abilities');
?>
<div style="float: right;">
<?php if ($user->admin == 1): ?>
@ -640,7 +643,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
$abil = db::c()->query('SELECT `abil` FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
$abil = unserialize($abil['abil']);
if ($user->align == 2) {
if ($user->getAlign() == 2) {
if ($k == 'al_neut_power' && $abil[0] < 1) {
$action_ok = 0;
}
@ -651,7 +654,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
$action_ok = 0;
}
}
if ($user->align == 6) {
if ($user->getAlign() == 6) {
if ($k == 'ct1' && $abil[0] < 1) {
$action_ok = 0;
}
@ -667,7 +670,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
print "<a onclick=\"javascript:$script_name('$magic_name','$k','target','target1') \" href='#'><img src='i/magic/" . $k . ".gif' title='" . $magic_name . "'></a>&nbsp;";
}
}
if ($user->align == 2) // Нейтралы
if ($user->getAlign() == 2) // Нейтралы
{
$abil = db::c()->query('SELECT `abil` FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
@ -683,7 +686,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
echo("<img src='i/magic/attackk_open.gif' title='Кулачное закрытое нападение'> Кулачное закрытое нападение - " . $abil[2] . "<br />");
}
if ($user->align == 6) // Свет
if ($user->getAlign() == 6) // Свет
{
$abil = db::c()->query('SELECT `abil` FROM `users` WHERE `id`= ?i', $_SESSION['uid'])->fetch_assoc();
@ -887,7 +890,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
$.ajax({
type: 'POST',
url: 'fancy/buy.php',
data: "type=" + type + "&user=" + <?= $user->id ?> + "",
data: "type=" + type + "&user=" + <?= $user->getId() ?> + "",
success: function (data) {
if (data === 'success') {
$(".child").html('<b style="color: Red;">' + types_user[type - 1] + ' успешно куплено</b>');
@ -907,7 +910,7 @@ $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['u
$.ajax({
type: 'POST',
url: 'fancy/buy_klan.php',
data: "type=" + type + "&user=" + <?= $user->id ?> + "",
data: "type=" + type + "&user=" + <?= $user->getId() ?> + "",
success: function (data) {
if (data === 'success') {
$(".child").html('<b style="color: Red;">' + types_klan[type - 21] + ' успешно куплено</b>');

View File

@ -1,4 +1,7 @@
<?php
use Battles\Template;
session_start();
require_once 'functions.php';
define('INFO_CHAR_LIMIT', 1500);
@ -28,29 +31,29 @@ if ($name || $color || $hobbie) {
err('Максимальная длинна поля Хобби: ' . INFO_CHAR_LIMIT . ' символов!');
} else {
$values = ['realname' => $name, 'color' => $color, 'info' => $hobbie];
db::c()->query('UPDATE users SET ?As WHERE id = ?i', $values, $user->id);
db::c()->query('UPDATE users SET ?As WHERE id = ?i', $values, $user->getId());
}
}
if ($oldpsw && $newpsw) {
if (password_verify($oldpsw, $user->pass)) {
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw, PASSWORD_DEFAULT), $user->id);
if (password_verify($oldpsw, $user->getPass())) {
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw, PASSWORD_DEFAULT), $user->getId());
} else {
err('Неверный текущий пароль!');
}
}
\Battles\Template::header('Анкета');
Template::header('Анкета');
?>
<a href="main.php"> на главную</a>
<h1>Анкета персонажа <?= $user->login ?></h1>
<h1>Анкета персонажа <?= $user->getLogin() ?></h1>
<form method="post">
<input name="name" placeholder="Реальное имя" value="<?= $user->realname ?>"><br>
<input name="name" placeholder="Реальное имя" value="<?= $user->getRealname() ?>"><br>
<select name="color" id="color">
<option value="0" selected>Чёрный</option>
<option value="1">Синий</option>
<option value="2">Зелёный</option>
</select><label for="color"></label><br>
<textarea name="hobbie" placeholder="Хобби"><?= $user->info ?></textarea><br>
<textarea name="hobbie" placeholder="Хобби"><?= $user->getInfo() ?></textarea><br>
<input name="submit" type="submit">
</form>
<h1>Безопасность</h1>

View File

@ -6,7 +6,7 @@ use Battles\User;
session_start();
require_once "functions.php";
$user = $user ?? new User($_SESSION['uid']);
if ($user->level < 4 && $user->level > 10) {
if ($user->getLevel() < 4 && $user->getLevel() > 10) {
header('location: main.php?act=none');
exit;
}

View File

@ -1,7 +1,11 @@
<?php
use Battles\Template;
use Battles\User;
session_start();
require_once "functions.php";
$user = $user ?? new \Battles\User($_SESSION['uid']);
$user = $user ?? new User($_SESSION['uid']);
try {
db::c()->query('LOCK TABLES `bots` WRITE, `battle` WRITE, `logs` WRITE, `users` WRITE, `inventory` WRITE, `zayavka` WRITE, `effects` WRITE, `online` WRITE, `clans` WRITE');
} catch (Exception $e) {
@ -589,11 +593,11 @@ VALUES ("?s","?s",?i,?i,?i,"?s","?s",?i,?i,?i,?i)',
$zay = new Zayavka;
if (!empty($_POST['open'])) {
$f = fopen("/tmp/zayavka/" . $user->id . ".txt", "w+");
$f = fopen("/tmp/zayavka/" . $user->getId() . ".txt", "w+");
fputs($f, time());
fclose($f);
}
\Battles\Template::header('zayavka');
Template::header('zayavka');
?>
<style>
.m {
@ -646,38 +650,38 @@ if (!empty($_POST['open'])) {
} else {
$blood = 0;
}
echo $zay->addzayavka(0, $_POST['timeout'], 1, 1, $_POST['k'], $user->level, 1, $user->level, 21, '', 2, $blood);
echo $zay->addzayavka(0, $_POST['timeout'], 1, 1, $_POST['k'], $user->getLevel(), 1, $user->getLevel(), 21, '', 2, $blood);
exit("<script>document.location='zayavka.php?fiz';</script>");
}
if (!empty($_POST['back'])) {
unlink("/tmp/zayavka/" . $user->id . ".txt");
echo $zay->delzayavka($user->id, $user->zayavka, 2, 0);
unlink("/tmp/zayavka/" . $user->getId() . ".txt");
echo $zay->delzayavka($user->getId(), $user->zayavka, 2, 0);
}
if (!empty($_POST['back2'])) {
$z = $zay->getlist(2, null, $user->zayavka);
AddChatSystem('Внимание!' . Nick::id($user->id)->short() . ' отозвал заявку.');
echo $zay->delteam($user->id, $user->zayavka, 2);
AddChatSystem('Внимание!' . Nick::id($user->getId())->short() . ' отозвал заявку.');
echo $zay->delteam($user->getId(), $user->zayavka, 2);
}
if (!empty($_POST['cansel'])) {
$z = $zay->getlist(2, null, $user->zayavka);
echo $zay->delteam($z[$user->zayavka]['team2'][0], $user->zayavka, 2);
AddChatSystem('Внимание!' . Nick::id($user->id)->short() . ' отказался от поединка.');
AddChatSystem('Внимание!' . Nick::id($user->getId())->short() . ' отказался от поединка.');
}
if (!empty($_POST['confirm2']) && empty($user->zayavka)) {
$z = $zay->getlist(2, null, $_REQUEST['gocombat']);
$toper = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $z[$_REQUEST['gocombat']]['team1'][0])->fetch_assoc();
if ($user->clan != $toper['klan'] || !$user->clan) {
AddChatSystem('Внимание!' . Nick::id($user->id)->short() . ' принял заявку, нужно принять вызов или отказать.');
if ($user->getClan() != $toper['klan'] || !$user->getClan()) {
AddChatSystem('Внимание!' . Nick::id($user->getId())->short() . ' принял заявку, нужно принять вызов или отказать.');
}
echo $zay->addteam(2, 2);
echo "</b></font><BR>Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'>";
}
if (!empty($_POST['gofi'])) {
$zay->battlestart($user->id, $user->zayavka, 2);
$zay->battlestart($user->getId(), $user->zayavka, 2);
}
echo "</b>";
echo '<table cellspacing=0 cellpadding=0><tr><td>';
if ($zay->user_status($user->id) == 0) { ?>
if ($zay->user_status($user->getId()) == 0) { ?>
<FIELDSET>
<LEGEND><B>Подать заявку на бой</B></LEGEND>
Таймаут
@ -697,22 +701,22 @@ if (!empty($_POST['open'])) {
</FIELDSET>
<?php }
$z = $zay->getlist(2, null, $user->zayavka);
if ($zay->user_status($user->id) == 1) {
if ($zay->user_status($user->getId()) == 1) {
if (count($z[$user->zayavka]['team2']) > 0) {
echo "<B><font color=red>Внимание! " . Nick::id($z[$user->zayavka]['team2'][0])->full(1) . " принял заявку на бой, нужно отказать или принять вызов.</font></b> <input type=submit value='Битва!' name=gofi> <input type=submit value='Отказать' name=cansel>";
} else {
if ($z[$user->zayavka]['level'] == 2) {
echo "Заявка на бой подана, ожидаем противника. <input type=submit name=back value='Отозвать заявку'>";
$Path = "/tmp/zayavka/" . $user->id . ".txt";
$Path = "/tmp/zayavka/" . $user->getId() . ".txt";
$f = fopen($Path, "r");
$timeFigth = fread($f, filesize($Path));
fclose($f);
if ($timeFigth < time() && ($user->level <= 14)) {
if ($get == 'trainstart' && $user->health > $user->maxHealth * 0.33 && ($user->level <= 7 || $user->admin == 1)) {
if ($timeFigth < time() && ($user->getLevel() <= 14)) {
if ($get == 'trainstart' && $user->health > $user->maxHealth * 0.33 && ($user->getLevel() <= 7 || $user->admin == 1)) {
unlink("/tmp/zayavka/" . $user->id . ".txt");
$zay->delzayavka($user->id, $user->zayavka, 2, 0);
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) values ('" . $user->login . " (Клон 1)','" . $user->id . "','','" . $user->maxHealth . "');");
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) values ('" . $user->getLogin() . " (Клон 1)','" . $user->id . "','','" . $user->maxHealth . "');");
$bot = mysql_insert_id();
$teams = [];
@ -749,7 +753,7 @@ if (!empty($_POST['open'])) {
if ($zay->user_status($user->id) == 2 && $z[$user->zayavka]['level'] == 2) {
echo "Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'>";
}
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user->level . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user->getLevel() . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '<tr><td><INPUT TYPE=hidden name=level value=fiz><INPUT TYPE=submit value="Принять вызов" NAME=confirm2><BR>';
if ($z = $zay->getlist(2, $_SESSION['view'])) {
foreach ($z as $k => $v) {
@ -892,27 +896,27 @@ if (!empty($_POST['open']) && empty($user->zayavka)) {
break;
case 1 : //только моего и ниже
$min1 = 0;
$max1 = $user->level;
$max1 = $user->getLevel();
break;
case 2 : //только ниже моего уровня
$min1 = 0;
$max1 = $user->level - 1;
$max1 = $user->getLevel() - 1;
break;
case 3 : //только моего уровня
$min1 = $user->level;
$max1 = $user->level;
$min1 = $user->getLevel();
$max1 = $user->getLevel();
break;
case 4 : //не старше меня более чем на уровень
$min1 = $user->level;
$max1 = $user->level + 1;
$min1 = $user->getLevel();
$max1 = $user->getLevel() + 1;
break;
case 5 : //не младше меня более чем на уровень
$min1 = $user->level - 1;
$max1 = $user->level;
$min1 = $user->getLevel() - 1;
$max1 = $user->getLevel();
break;
case 6 : //мой уровень +/- 1
$min1 = (int)$user->level - 1;
$max1 = (int)$user->level + 1;
$min1 = (int)$user->getLevel() - 1;
$max1 = (int)$user->getLevel() + 1;
break;
case 99 : // кланы
$min1 = 99;
@ -927,27 +931,27 @@ if (!empty($_POST['open']) && empty($user->zayavka)) {
break;
case 1 : //только моего и ниже
$min1 = 0;
$max1 = $user->level;
$max1 = $user->getLevel();
break;
case 2 : //только ниже моего уровня
$min1 = 0;
$max1 = $user->level - 1;
$max1 = $user->getLevel() - 1;
break;
case 3 : //только моего уровня
$min1 = $user->level;
$max1 = $user->level;
$min1 = $user->getLevel();
$max1 = $user->getLevel();
break;
case 4 : //не старше меня более чем на уровень
$min1 = $user->level;
$max1 = $user->level + 1;
$min1 = $user->getLevel();
$max1 = $user->getLevel() + 1;
break;
case 5 : //не младше меня более чем на уровень
$min1 = $user->level - 1;
$max1 = $user->level;
$min1 = $user->getLevel() - 1;
$max1 = $user->getLevel();
break;
case 6 : //мой уровень +/- 1
$min1 = (int)$user->level - 1;
$max1 = (int)$user->level + 1;
$min1 = (int)$user->getLevel() - 1;
$max1 = (int)$user->getLevel() + 1;
break;
case 99 : // кланы
$min1 = 99;
@ -977,7 +981,7 @@ if (!empty($_POST['open']) && empty($user->zayavka)) {
echo "</b><INPUT TYPE=hidden name=level value=group>";
echo '</TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user->level . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '</TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user->getLevel() . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '<tr><td width=85%>';
echo '<BR><INPUT TYPE=submit value="Принять участие" NAME=goconfirm><BR>';
@ -1002,12 +1006,12 @@ if ($get == 'haos') {
$max1 = 21;
break;
case 3 :
$min1 = $user->level;
$max1 = $user->level;
$min1 = $user->getLevel();
$max1 = $user->getLevel();
break;
case 6 :
$min1 = (int)$user->level - 1;
$max1 = (int)$user->level + 1;
$min1 = (int)$user->getLevel() - 1;
$max1 = (int)$user->getLevel() + 1;
break;
}
@ -1031,7 +1035,7 @@ if ($get == 'haos') {
echo "<B>Ожидаем начала группового боя...</B><BR>Бой начнется через: " . round(($z[$user->zayavka]['start'] - time()) / 60, 1) . " мин.";
}
}
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user->level . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user->getLevel() . '" ' . (($_SESSION['view'] != null) ? "checked" : "") . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (($_SESSION['view'] == null) ? "checked" : "") . '></td><td>все</td></tr></table></FIELDSET>';
echo '<tr><td width=85%><INPUT TYPE=hidden name=level value=haos><INPUT TYPE=submit value="Принять участие" NAME=confirm2><BR>';
if ($z = $zay->getlist(5, $_SESSION['view'])) {
foreach ($z as $k => $v) {