Новый класс Chat; session_start() уехал централизованно в конфиг с проверкой на существование ессии перед открытием. Уборка deprecated-артефактов. Работа по внедрению #42.

This commit is contained in:
Igor Barkov (iwork) 2021-08-25 18:24:12 +03:00
parent 1f38e6bd61
commit 6fa217b93b
63 changed files with 2253 additions and 2322 deletions

View File

@ -4,7 +4,6 @@
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
session_start();
require_once '../functions.php';
use Battles\Bank;
@ -35,11 +34,10 @@ if (isset($_POST['syschatmsg'])) {
//clans to reg
$unregisteredClans = new class {
public DBPDO $db;
public function getList()
{
$row = $this->db->ofetchAll('SELECT * FROM clans WHERE status = 0');
$row = DBPDO::$db->ofetchAll('SELECT * FROM clans WHERE status = 0');
$i = 0;
while ($i < count($row)) {
$id = $row[$i]->owner_id;
@ -66,17 +64,16 @@ UNREGCLANLIST;
public function allowRegister($id)
{
$this->db->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
DBPDO::$db->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
}
public function disallowRegister($id)
{
$bank = new Bank($id);
$this->db->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
DBPDO::$db->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
$bank::setBankMoney($bank->getMoney() + GameConfigs::CLAN['clan_register_cost'], $id);
}
};
$unregisteredClans->db = DBPDO::$db;
$unregisteredClans->getList();
if (isset($_GET['regclan'])) {

View File

@ -5,7 +5,10 @@
* Project name: Battles-Game
*/
session_start();
use Battles\Database\DBPDO;
use Battles\DressedItems;
use Battles\Template;
require_once "../functions.php";
if (!$user->getAdmin()) {
header("HTTP/1.0 404 Not Found");
@ -18,13 +21,13 @@ $end = $_POST['end'] ?? null;
$del = $_POST['del'] ?? null;
if ($player) {
$row = db::c()->query('SELECT id, login FROM users WHERE id = "?s" OR login = "?s"', $player, $player)->fetch_assoc();
$_SESSION['player_id'] = $row['id'];
$_SESSION['player_name'] = $row['login'];
$row = DBPDO::$db->ofetch('select id, login from users where id = ? or login = ?', [$player, $player]);
$_SESSION['player_id'] = $row->id;
$_SESSION['player_name'] = $row->login;
unset($row);
}
if ($undress_char) {
\Battles\DressedItems::undressAllItems($_SESSION['player_id']);
DressedItems::undressAllItems($_SESSION['player_id']);
}
if ($end) {
unset($_SESSION['player_id']);
@ -36,16 +39,16 @@ if (isset($_SESSION['player_id'])) {
if ($del) {
$itemdel = db::c()->query('SELECT item_type, dressed_slot FROM inventory WHERE id=?i', $del)->fetch_assoc();
if ($itemdel['dressed_slot'] == 1) {
$item = new \Battles\DressedItems($del);
$item = new DressedItems($del);
$item->undressItem($itemdel['item_type']);
if ($itemdel['item_type'] == 5) {
$item->undressItem(6);
$item->undressItem(7);
}
}
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del);
DBPDO::$db->execute('delete from inventory where id = ?', $del);
}
\Battles\Template::header('ᐰdminка инвентаря');
Template::header('ᐰdminка инвентаря');
?>
<h1>Администрирование инвентаря <?php if (isset($_SESSION['player_name'])) echo $_SESSION['player_name']; ?></h1>
<table class='adm'>

View File

@ -1,6 +1,5 @@
<?php
session_start();
include "config.php";
//$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '2106' LIMIT 1;"));
//include "functions.php";

View File

@ -4,7 +4,6 @@ use Battles\Bank;
use Battles\GameLogs;
use Battles\Template;
session_start();
require_once 'functions.php';
const SMITH = 'оружейник';
const MERCENARY = 'наёмник';

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
$start = db::c()->query('SELECT `value` FROM `variables` WHERE `var` = "arena_of_gods"')->fetch_assoc();

View File

@ -6,7 +6,6 @@ use Battles\Rooms;
use Battles\Template;
use Exceptions\GameException;
session_start();
require_once "functions.php";
const SUCCESS = "Успешная операция!";

View File

@ -1,5 +1,7 @@
<?php
session_start();
use Battles\Template;
require_once "functions.php";
$header = $_GET['header'] ?? null;
$ch = $_GET['ch'] ?? null;
@ -7,7 +9,7 @@ $ch = $_GET['ch'] ?? null;
if ($header) {
exit;
} elseif ($ch != null) {
\Battles\Template::header('buttons');
Template::header('buttons');
?>
<script language="JavaScript" src="js/ch.js"></script>
<script language="JavaScript" src="js/sl2.js"></script>
@ -231,7 +233,7 @@ if ($header) {
<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>
<? } else { \Battles\Template::header('buttons'); ?>
<? } else { Template::header('buttons'); ?>
<script language="JavaScript" src="js/chat.js"></script>
<script language="JavaScript">

View File

@ -1,6 +1,5 @@
<?php
//Покупка абилок? Тут?!
session_start();
if (empty($_SESSION['uid'])) {
header('Location: Index.php');
exit;

View File

@ -1,8 +1,4 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
exit;
}
require_once "functions.php";
if (empty($user->getClan())) {

View File

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

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
$in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}';"));
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = " . $user['id'] . " AND (type=13 OR type=12 OR type=14) limit 1;"));

View File

@ -1,5 +1,7 @@
<?php
session_start();
use Battles\Template;
require_once "functions.php";
$in_park = mysql_fetch_array(mysql_query("SELECT * FROM `cit_park` WHERE `id` = '{$user['id']}' LIMIT 1;"));
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = " . $user['id'] . " AND (type=13 OR type=12 OR type=14) limit 1;"));
@ -106,7 +108,7 @@ if ($_POST['attack']) {
//старт боя - конец
\Battles\Template::header('Городской Парк');
Template::header('Городской Парк');
?>
<script>
function refreshPeriodic() {

View File

@ -2,7 +2,6 @@
use Battles\Template;
session_start();
require_once "functions.php";
if ($user->getRoom() == 403) {
include "startpodzemel.php";

View File

@ -2,7 +2,6 @@
use Battles\Template;
session_start();
require_once 'functions.php';
//require_once 'cave/cave_bots.php';
$userslots = ['sergi', 'kulon', 'perchi', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'shit', 'boots', 'rybax', 'plaw', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10'];

5
ch.php
View File

@ -1,10 +1,11 @@
<?php
use Battles\Database\DBPDO;
use Battles\Template;
use Battles\User;
session_start();
require_once 'functions.php';
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `id` = ?i', time(), $u->i()['id']);
DBPDO::$db->execute('update online set real_time = ? where user_id = ?', [time(), User::$current->getId()]);
if (isset($_GET['online']) && $_GET['online'] != null) {
if ($_GET['room'] && (int)$_GET['room'] < 500) {

View File

@ -5,52 +5,18 @@
* Project name: Battles-Game
*/
use Battles\Chat;
use Battles\Database\DBPDO;
use Battles\Template;
session_start();
require_once "config.php";
$msg = $_POST['msg'] ?? null;
$uid = $_SESSION['uid'] ?? null;
if ($msg) {
$db = new DBPDO();
$db->execute('INSERT INTO chat (user_id,msg) VALUES (?,?)', [$uid, $msg]);
$chat = new Chat(new DBPDO());
if (!empty($_POST['msg'])) {
$chat->addMessage($_POST['msg']);
}
function show_messages()
{
$db = new DBPDO();
$chat = $db->ofetchALL('SELECT msg,msgdate,type,s.login AS sender, r.login AS receiver, s.id AS sid, r.id AS rid FROM chat
LEFT JOIN users s on s.id = chat.user_id
LEFT JOIN users r on r.id = chat.receiver_id
WHERE r.id = ? OR r.id IS NULL OR s.id = ? ORDER BY chat.id', [$_SESSION['uid'], $_SESSION['uid']]);
$i = 0;
while ($i < count($chat)) {
$d = new DateTime($chat[$i]->msgdate);
$m = htmlspecialchars($chat[$i]->msg);
if ($chat[$i]->type == 'sys') { /* Системка */
echo sprintf('<span style="color:maroon;background:#faa;">%s %s</span><br>', $d->format('H:i'), $m);
} elseif ($chat[$i]->rid == $_SESSION['uid']) { /* С указанным получателем */
if ($chat[$i]->type == 'sms') { /* Телеграмма */
echo sprintf('<span style="color:darkgreen;background:#afa;">%s Телеграмма от [%s]: %s</span><br>', $d->format('d.m.Y H:i'), $chat[$i]->sender, $m);
} elseif ($chat[$i]->type == 'private') { /* Приват */
echo sprintf('<span style="background:#efe;">%s [%s] → [%s]: %s</span><br>', $d->format('H:i'), $chat[$i]->sender, $chat[$i]->receiver, $m);
} else { /* Общак */
echo sprintf('%s [%s] → [%s]: %s<br>', $d->format('H:i'), $chat[$i]->sender, $chat[$i]->receiver, $m);
}
} else { /* Без указанного получателя */
echo sprintf('%s [%s]: %s<br>', $d->format('H:i'), $chat[$i]->sender, $m);
}
$i++;
}
unset($i, $chat, $db);
}
Template::header('chat');
show_messages();
echo $chat->getMessages();
?>
<style>
form {
@ -72,6 +38,18 @@ show_messages();
border: none;
padding: 10px;
}
span.chatsys {
color:maroon;
background:#faa;
}
span.chatsms {
color:darkgreen;
background:#afa;
}
span.chatprivate {
background:#efe;
}
</style>
<div>
<?php ?>

View File

@ -2,7 +2,9 @@
/**
* Центральная площадь
*/
session_start();
use Battles\Template;
require_once "functions.php";
if ($user->getZayavka()) {
@ -195,7 +197,7 @@ switch ($location[0]) {
}
}
\Battles\Template::header('city');
Template::header('city');
echo sprintf('<div style="text-align: right;">Сейчас в игре: %s игроков.></div>', $online->getNumRows());
if (in_array($user->getRoom(), [20, 21, 26, 2601, 2655, 2111, 2701, 2702])) {
/* Улицы:

View File

@ -7,7 +7,6 @@ use Battles\Rooms;
use Battles\Template;
use Battles\User;
session_start();
require_once 'functions.php';
if (!User::$current->getClan()) {
exit('Ошибка! Вы не состоите в клане!');

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = " . $user['id'] . " AND (type=13 OR type=12 OR type=14) limit 1;"));
$klan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '{$user['klan']}' LIMIT 1;"));

View File

@ -5,7 +5,6 @@ use Battles\GameConfigs;
use Battles\Rooms;
use Battles\Template;
session_start();
require_once 'functions.php';
$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'] ?? '';

68
classes/Battles/Chat.php Normal file
View File

@ -0,0 +1,68 @@
<?php
namespace Battles;
use Battles\Database\DBPDO;
use DateTime;
use Exception;
class Chat
{
private DateTime $d;
private DBPDO $db;
public function __construct(DBPDO $db)
{
$this->db = $db;
}
public function getMessages(): ?string
{
$query = 'select
msg,
msgdate,
type,
s.login as sender,
r.login as receiver,
s.id as sid,
r.id as rid
from chat
left join users s on s.id = chat.user_id
left join users r on r.id = chat.receiver_id
where
r.id = ?
or r.id is null
or s.id = ?
order by chat.id';
$chatrows = $this->db->ofetchALL($query, [User::$current->getId(), User::$current->getId()]);
$wrappedMessage = null;
foreach ($chatrows as $row) {
try {
$this->d = new DateTime($row->msgdate);
} catch (Exception $e) {
echo 'Chat Datetime Whoops!';
}
$m = htmlspecialchars($row->msg);
if ($row->type === 'sys') {
$wrappedMessage .= sprintf('<span class="chatsys">%s %s</span><br>', $this->d->format('H:i'), $m);
} elseif ($row->rid == User::$current->getId()) {
if ($row->type == 'sms') {
$wrappedMessage .= sprintf('<span class="chatsms">%s Телеграмма от [%s]: %s</span><br>', $this->d->format('d.m.Y H:i'), $row->sender, $m);
} elseif ($row->type == 'private') {
$wrappedMessage .= sprintf('<span class="chatprivate">%s [%s] → [%s]: %s</span><br>', $this->d->format('H:i'), $row->sender, $row->receiver, $m);
} else {
$wrappedMessage .= sprintf('%s [%s] → [%s]: %s<br>', $this->d->format('H:i'), $row->sender, $row->receiver, $m);
}
} else {
$wrappedMessage .= sprintf('%s [%s]: %s<br>', $this->d->format('H:i'), $row->sender, $m);
}
}
return $wrappedMessage;
}
public function addMessage($msg)
{
$this->db->execute('insert into chat (user_id, msg) values (?,?)', [User::$current->getId(), $msg]);
}
}

View File

@ -4,7 +4,6 @@ use Battles\GameLogs;
use Battles\ShopItem;
use Battles\Template;
session_start();
require_once 'functions.php';
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
$putItemCost = (int)filter_input(INPUT_POST, 'cost', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);

View File

@ -9,6 +9,11 @@
ini_set('display_errors', 'On');
error_reporting(E_ALL);
const GAMEDOMAIN = "battles.lan";
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
/*
* Запрещаем кэшировать
*/
@ -36,6 +41,16 @@ spl_autoload_register(function ($className) {
}
});
/**
* Глобальные переменные. Промежуточное решение для совместимости.
*/
if (empty(\Battles\Database\DBPDO::$db)) {
\Battles\Database\DBPDO::$db = new \Battles\Database\DBPDO();
}
if (empty(\Battles\User::$current) && $_SESSION['uid']) {
\Battles\User::$current = new \Battles\User($_SESSION['uid']);
}
// Для нападалок. Сперва комнаты в которых нельзя напасть, потом персонажи на которых нельзя напасть.
const UNKILABLE = [
'rooms' => [620, 621, 1051, 1052],

View File

@ -4,15 +4,13 @@ use Battles\Database\DBPDO;
use Battles\GameLogs;
use Battles\Template;
session_start();
require_once "config.php";
const ERROR_NO_SUCH_USER = 'Такого пользователя не существует!';
const ERROR_USER_IS_BLOCKED = 'Пользователь заблокирован!';
const ERROR_WRONG_PASSWORD = 'Неверный пароль!';
const ERROR_EMPTY_CREDENTIALS = 'Вы не ввели логин или пароль!';
$db = new DBPDO();
foreach ($_POST as $key => $val) { //Проверка всех значений массива POST одним махом.
$_POST[$key] = iconv(mb_detect_encoding($_POST[$key], 'auto'), 'utf-8', $val);
$_POST[$key] = iconv(mb_detect_encoding($val, 'auto'), 'utf-8', $val);
}
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS);
@ -21,7 +19,7 @@ $battle = $_COOKIE['battle'] ?? '';
$error = "";
if ($username && $password) {
$user_query = $db->ofetch('SELECT id, login, pass, room, block FROM users WHERE login = ?', $username);
$user_query = DBPDO::$db->ofetch('SELECT id, login, pass, room, block FROM users WHERE login = ?', $username);
if (!$user_query->id) {
$error = ERROR_NO_SUCH_USER;
@ -41,14 +39,14 @@ if ($username && $password) {
setcookie("hashcode", md5($user_query->id . $user_query->pass . $username), time() + 43200, "/", GAMEDOMAIN);
$_SESSION['sid'] = session_id();
$onl = $db->ofetch('SELECT user_id FROM online WHERE user_id = ?', $user_query->id);
$onl = DBPDO::$db->ofetch('SELECT user_id FROM online WHERE user_id = ?', $user_query->id);
if (isset($onl->user_id)) {
$db->execute('UPDATE online SET date = ? WHERE user_id = ?', [time(), $user_query->id]);
DBPDO::$db->execute('UPDATE online SET date = ? WHERE user_id = ?', [time(), $user_query->id]);
} else {
$db->execute('INSERT INTO online (user_id, date, room, real_time) VALUES (?,?,?,?)', [$user_query->id, time(), $user_query->room, time()]);
DBPDO::$db->execute('INSERT INTO online (user_id, date, room, real_time) VALUES (?,?,?,?)', [$user_query->id, time(), $user_query->room, time()]);
}
$db->execute('UPDATE users SET session_id = ?, enter_game = 1 WHERE id = ?', [session_id(), $user_query->id]);
DBPDO::$db->execute('UPDATE users SET session_id = ?, enter_game = 1 WHERE id = ?', [session_id(), $user_query->id]);
header("Location: fight.php");
}
} else {

View File

@ -2,7 +2,6 @@
use Battles\Template;
session_start();
require_once "functions.php";
function secs2hrs($s, $short = 0)

View File

@ -1,5 +1,4 @@
<?php
session_start();
if (isset($_POST['end'])) {
header("Location: main.php");
exit;

View File

@ -1,14 +1,19 @@
<?php
session_start();
use Battles\Database\DBPDO;
use Battles\Template;
use Battles\User;
require_once 'config.php';
$userLoginStatus = db::c()->query('SELECT enter_game FROM users WHERE id = ?i', $_SESSION['uid'])->getNumRows() ?? 0;
if (empty($userLoginStatus)) {
$userLoginStatus = DBPDO::$db->ofetch('select enter_game from users where id = ?', User::$current->getId());
if (empty($userLoginStatus->enter_game)) {
header("Location: index.php");
exit();
} else {
db::c()->query('UPDATE `users` SET `enter_game` = 0 WHERE `enter_game` = 1 AND `id` = ?i', $_SESSION['uid']);
DBPDO::$db->execute('update users set enter_game = 0 where enter_game = 1 and id = ?', User::$current->getId());
}
\Battles\Template::header('Окно игры');
Template::header('Окно игры');
?>
<script>
if (!navigator.cookieEnabled) {

View File

@ -2,10 +2,6 @@
use Battles\Template;
session_start();
if (empty($_SESSION['uid'])) {
exit;
}
require_once "functions.php";
if ($user->getRoom() == 51) {
header('location: city.php');

View File

@ -1,7 +1,6 @@
<?php
session_start();
require_once 'config.php';
$user = new \Battles\User($_SESSION['uid']);
$user = \Battles\User::$current;
$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;
$isModerator = false;

View File

@ -12,7 +12,6 @@ use Battles\Travel;
use Battles\User;
require_once 'config.php';
DBPDO::$db = new DBPDO();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;

View File

@ -1,7 +1,6 @@
<?php
/* Разрушенный замок на замковой улице. */
session_start();
define("CASTLE_MAX_LEVEL", 10);
const CASTLE_MAX_LEVEL = 10;
require_once 'functions.php';
$castleOwners = db::c()->query('SELECT * FROM `clans` WHERE `short` = (SELECT * FROM `variables` WHERE `var` = "?s")', 'gotzamok');

View File

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

View File

@ -2,7 +2,6 @@
use Battles\Template;
session_start();
require_once "functions.php";
class hellround

View File

@ -1,9 +1,11 @@
<?php
session_start();
use Battles\Template;
use Battles\User;
require_once 'config.php';
$user = new \Battles\User($_SESSION['uid']);
$user = User::$current;
$hostel = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `type`, `time` FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
#include('functions.php');
$error = '';
$rs = '';
$base = [1 => ['type' => 'Сумка'], 2 => ['type' => 'Сундук'], 3 => ['type' => 'Комната'], 4 => ['type' => 'Амбар']];
@ -150,7 +152,7 @@ if ($_GET['unsleep'] && $user['sleep'] > 0) {
}
header('Location: hostel.php');
}
\Battles\Template::header('Хостел');
Template::header('Хостел');
?>
<script src="js/ajaxLoad.js"></script>
<? if (isset($hostel['id'])) { ?>

View File

@ -1,7 +1,6 @@
<?php
session_start();
require_once "functions.php";
$hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
$hostel = \Battles\Database\DBPDO::$db->fetch('select * from hostel where uid = ?', \Battles\User::$current->getId());
$base = [1 => [8, 16, 24, 32], 2 => [15, 30, 45, 60], 3 => [25, 50, 75, 100], 4 => [40, 80, 120, 160]];
if (isset($_POST['act']) && $_POST['act'] == 'pay' && isset($user['id']) && isset($hostel['id'])) {

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
$d = mysql_fetch_array(mysql_query("SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `setsale` = 0"));

View File

@ -4,7 +4,6 @@ use Battles\Models\PresentsModel;
use Battles\Template;
use Battles\UserInfo;
session_start();
include_once 'config.php';
$userInfo = new UserInfo(urldecode($_SERVER['QUERY_STRING']));
$presentsModel = new PresentsModel($userInfo->getId());

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
if ($user['lab'] == 0) {
header("Location: index.php");

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
if ($user['lab'] == 0) {
header("Location: index.php");
@ -393,7 +392,7 @@ echo "<tr><td><td><button style='width:50px; height:50px;' class='INPUT' disable
$u_lab = mysql_query("select `login` from `users` where `lab`='1' and `bot`!='1'");
$u_lab_kol = mysql_num_rows($u_lab);
$heal_all = (($u_lab_kol / 2) + 1);
echo "Всего в Лабиринте: <b>" . $u_lab_kol . "</b> чел. <small><a href=\"#\" onclick=\"javascript:if (confirm('Излечить всех за $heal_all кр?')){ location.href='lab.php?healall=1&cost=$heal_all';}\">[излечить]</a></small><br>";
echo "Всего в Лабиринте: <b>" . $u_lab_kol . "</b> чел. <small><a href=\\";
echo "<b>В этой комнате:</b>";
echo "<br><li><u>Игроки:</u>";
while ($items = mysql_fetch_array($data3)) {

View File

@ -2,7 +2,6 @@
use Battles\Template;
session_start();
require_once "functions.php";
$errkom = '';
mysql_query('DELETE FROM `laba_zv` WHERE `time` < "' . (time() - 1 * 60 * 60) . '"');

View File

@ -1,5 +1,8 @@
<?php
session_start();
use Battles\DressedItems;
use Battles\Template;
require_once "functions.php";
$q2 = mysql_fetch_array(mysql_query('SELECT * FROM `qst_user` WHERE `uid` = "' . $user['id'] . '" AND `cancel` = "0" AND `finish` = "0" LIMIT 1'));
@ -141,7 +144,7 @@ if (isset($_POST['exit'])) {
}
$dresed = mysql_query('SELECT `id`, `type` FROM `inventory` WHERE `dressed` = 1 AND `laba` = 2 AND `owner` = "' . $user['id'] . '"');
while ($pl = mysql_fetch_array($dresed)) {
$item = new \Battles\DressedItems($user['id']);
$item = new DressedItems($user['id']);
$item->undressItem($pl['type']);
}
mysql_query('DELETE FROM `inventory` WHERE `laba` > 0 AND `owner` = "' . $user['id'] . '"');
@ -291,7 +294,7 @@ if ($user['y'] >= count($map_d) - 2) {
}
$dresed = mysql_query('SELECT `id`, `type` FROM `inventory` WHERE `dressed` = 1 AND `laba` = 2 AND `owner` = "' . $user['id'] . '"');
while ($pl = mysql_fetch_array($dresed)) {
$item = new \Battles\DressedItems($user['id']);
$item = new DressedItems($user['id']);
$item->undressItem($pl['type']);
}
mysql_query('UPDATE `inventory` SET `laba` = 0 WHERE `laba` = 1 AND `owner` = "' . $user['id'] . '"');
@ -461,7 +464,7 @@ if (isset($varos['trap1']['vals']) && $varos['trap1']['vals'] > 0) {
$effed .= '<div><img width="40" height="25" src="/i/sh/event_timer_trap.gif" /> - Время перехода +3 секунды (Осталось : ' . timeOut($varos['trap1']['time'] - time()) . ')</div>';
}
unset($varos);
\Battles\Template::header('labirint');
Template::header('labirint');
?>
<script type="text/javascript" src="js/jquery.js"></script>
<script>

View File

@ -3,7 +3,6 @@
use Battles\Template;
use Battles\UserInfo;
session_start();
require_once "functions.php";
Template::header('Библиотека Просвещения');
?>

View File

@ -10,7 +10,6 @@ use Battles\UserInfo;
use Battles\UserStats;
use Battles\User;
session_start();
$get = filter_input(INPUT_SERVER, 'QUERY_STRING');
if ($get == 'exit') {
session_destroy();

View File

@ -2,12 +2,6 @@
use Battles\Template;
session_start();
if (empty($_SESSION['uid'])) {
header('Location: /index.php');
exit();
}
require_once 'functions.php';
require_once 'classes/quests_class.php';

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
if ($_GET['act'] == "atk") {
$ass = mysql_query("SELECT glav_id,glava,name FROM labirint WHERE user_id=" . $user['id'] . "");

View File

@ -1,51 +1,62 @@
<?php
session_start();
// Что ты такое?
use Battles\Database\DBPDO;
use Battles\User;
require_once "../config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
if ($user['admin']) {
?>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top">
<table width="700" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="300" align="left" valign="top">
<?
$nec = mysql_query("SELECT * FROM podzem2");
while ($sc = mysql_fetch_array($nec)) {
print"<a href='edit_podzem.php?name=" . $sc['name'] . "'>" . $sc['name'] . "</a><br />";
}
?>
</td>
<td width="400" align="left" valign="top">
<form action="" method="get">
<? if (!$_GET['new']) { ?>
<input name="new" type="submit" value="Создать новую"/>
<?
if ($_GET['new']) {
print "<script>location.href='main.php?act=none'</script>";
exit;
}
if ($_GET['news']) {
$SQL2 = mysql_query("INSERT INTO podzem2(name) VALUES('" . $_GET['name'] . "')");
print "<script>location.href='edit.php'</script>";
exit;
}
} else { ?>
<input style="font-size:12px;" name="name" type="text" size="10" value="Название"/>
<input name="news" type="submit" value="Создать"/>
<?
} ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
$user = User::$current;
if (!User::$current->getAdmin()) {
exit('Access denied!');
}
$nec = DBPDO::$db->fetchAll('select * from podzem2');
?>
<style>
.row {
cursor: default;
border: 1px solid black;
}
.column {
padding: 10px;
float: left;
}
.left {
width: 300px;
}
.right {
width: 400px;
}
.row:after {
content: "";
display: table;
clear: both;
}
</style>
<div class="row">
<div class="column left">
<?php
foreach ($nec as $row) {
echo sprintf('<a href="edit_podzem.php?name=%s">%s</a><br>', $row['name'], $row['name']);
}
?>
</div>
<div class="column right">
<form action="" method="get">
<?php if (empty($_GET['new'])): ?>
<input name="new" type="submit" value="Создать новую">
<?php
if (!empty($_GET['news'] && !empty($_GET['name']))) {
$SQL2 = DBPDO::$db->execute('insert into podzem2 (name) value ?', $_GET['name']);
exit("<script>location.href='edit.php'</script>");
} ?>
<?php else: ?>
<input style="font-size:12px;" name="name" type="text" size="10" value="Название">
<input name="news" type="submit" value="Создать">
<?php endif; ?>
</form>
</div>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ use Battles\InventoryItem;
use Battles\Nick;
use Battles\Template;
session_start();
require_once 'functions.php';
if ($_GET['change'] ?? 0) {
unset($_SESSION['receiverName']);

View File

@ -16,7 +16,7 @@
use Battles\Template;
use Battles\User;
session_start();
if ($_SESSION['uid'] != 2) {
header("Location: index.php");
exit;

View File

@ -2,10 +2,6 @@
use Battles\Template;
session_start();
if (empty($_SESSION['uid'])) {
header('Location: /index.php');
}
require_once 'functions.php';
include('classes/quests_class.php');
$status = '';

View File

@ -2,7 +2,6 @@
use Battles\Template, Battles\Database\DBPDO;
session_start();
require_once "config.php";
if ($_COOKIE[GAMEDOMAIN] ?? null) {

View File

@ -4,7 +4,6 @@ use Battles\Bank;
use Battles\GameLogs;
use Battles\Template;
session_start();
require_once("functions.php");
const GRAV_LIMIT = 32;
const GRAV_COST = 30;

View File

@ -6,7 +6,6 @@ use Battles\Item;
use Battles\ShopItem;
use Battles\Template;
session_start();
require_once 'functions.php';
$saleItems = false;
$shopCategoryType = $_POST['sale'] ?? '';

View File

@ -1,8 +1,12 @@
<?php
session_start();
use Battles\Database\DBPDO;
use Battles\Template;
use Battles\User;
require_once "functions.php";
$Tournament = new Tournament();
\Battles\Template::header('Турниры');
Template::header('Турниры');
?>
<META HTTP-EQUIV="REFRESH" CONTENT="10">
<div style='color:#8F0000; font-weight:bold; font-size:16px; text-align:center; float:left;'>Турнирная</div>
@ -29,20 +33,20 @@ if (!empty($_POST)) {
}
}
$dateD = mysql_fetch_row(mysql_query("select datetime from turnament where old=0 limit 1"));
$dateD = DBPDO::$db->fetch('select datetime from turnament where old = 0 limit 1');
if (mktime() >= ($dateD[0] + 10)) {
if (mktime() >= ($dateD['dt'] + 10)) {
$Tournament->UpdateTournir();
}
$Tournament->showAllTurnament();
if (mktime() >= ($dateD[0] + 10)) {
if (mktime() >= ($dateD['dt'] + 10)) {
$Tournament->StartTournir();
}
$Tournament->ShowTournirFinaliats();
?>
<form method="post">
<?php if ($user->getAdmin()) { ?>
<?php if (User::$current->getAdmin()) { ?>
<div>
<input type="submit" name="newtournament" value="Добавить новый турнир">
<input type="submit" name="preptournament" value="Приготовить турнир и запустить">

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
class predbannik_bs
{

View File

@ -1,7 +1,9 @@
<?php
session_start();
use Battles\User;
require_once "functions.php";
if ($user['in_tower'] != 1) {
if (User::$current->getInTower() != 1) {
header('Location: main.php');
exit;
}

View File

@ -1,5 +1,4 @@
<?php
session_start();
require_once "functions.php";
$effect = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = '{$user['id']}' LIMIT 1"));
if ($user->getRoom() != 31) {

View File

@ -1,23 +1,26 @@
<?php
session_start();
use Battles\Database\DBPDO;
use Battles\Template;
use Battles\User;
require_once "config.php";
$user = new \Battles\User($_SESSION['uid']);
if ($_GET['id'] && $user->getAdmin()) {
if (!empty($_GET['id']) && User::$current->getAdmin()) {
echo "Пробуем перейти на выбранную замковую улицу...";
$_SESSION["klan"] = $_GET['klan'];
$a = $_GET['klan'];
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 651, `online`.`room` = 651 WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_SESSION['uid']);
DBPDO::$db->execute('update users, online set users.room = 651, online.room = 651 where user_id = id and user_id = ?', User::$current->getId());
header("location: city.php");
exit;
}
\Battles\Template::header('Клановый перекрёсток');
Template::header('Клановый перекрёсток');
?>
<a href="/city.php?strah=1"> назад</a>
<h1>Переход к клановым улицам</h1>
На данный момент свои замки имеют такие кланы:
<?php
$query = db::c()->query('SELECT `id`,`short`,`align`,`name` FROM `clans` WHERE `zamok` = 2');
while ($row = $query->fetch_assoc()) {
$frm = "<img src='i/align_%s.png'> <img src='i/clan/%s.png'> %s<br><form><input name='klan' type='hidden' value='%s'><input type='submit' value='Вход'></form>";
echo sprintf($frm, $row['align'], $row['short'], $row['name'], $row['id']);
$rows = DBPDO::$db->fetchAll('select short_name, full_name, owner_id from clans where zamok = 2');
foreach ($rows as $row) {
$frm = "<img src='i/clan/%s.png'> %s<br><form><input name='klan' type='hidden' value='%s'><input type='submit' value='Вход'></form>";
echo sprintf($frm, $row['short_name'], $row['full_name'], $row['owner_id']);
}

View File

@ -8,7 +8,6 @@
use Battles\Template;
session_start();
require_once 'functions.php';
if (!empty($_GET['teleport']) && $user->getAdmin() == 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']);

View File

@ -3,7 +3,6 @@
use Battles\Template;
use Battles\User;
session_start();
require_once 'functions.php';
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$oldpsw = filter_input(INPUT_POST, 'oldpsw', FILTER_SANITIZE_SPECIAL_CHARS);

View File

@ -2,7 +2,6 @@
use Battles\Template;
session_start();
require_once "functions.php";
if ($user->getLevel() < 4 && $user->getLevel() > 10) {
header('location: main.php?act=none');

View File

@ -1,9 +1,9 @@
<?php
use Battles\DressedItems;
use Battles\Nick;
use Battles\Template;
session_start();
require_once "functions.php";
try {
db::c()->query('LOCK TABLES `bots` WRITE, `battle` WRITE, `logs` WRITE, `users` WRITE, `inventory` WRITE, `zayavka` WRITE, `effects` WRITE, `online` WRITE, `clans` WRITE');
@ -419,11 +419,11 @@ class Zayavka
if ($z['type'] == 4 || $z['type'] == 5) {
foreach ($z['team1'] as $k => $v) {
\Battles\DressedItems::undressAllItems($v);
DressedItems::undressAllItems($v);
}
foreach ($z['team2'] as $k => $v) {
\Battles\DressedItems::undressAllItems($v);
DressedItems::undressAllItems($v);
}
}