Новый класс 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

View File

@ -1,41 +1,51 @@
<?php
session_start();
use Battles\Database\DBPDO;
use Battles\Item;
use Battles\Template;
use Battles\User;
use Battles\UserInfo;
require_once "functions.php";
require_once "startpodzemel.php";
$df = mysql_query("select `location`,`name`,`glava` from `labirint` where `user_id`='" . $_SESSION['uid'] . "'");
$fd = mysql_fetch_array($df);
$cd = mysql_query("select `n18` from `podzem3` where `glava`='" . $fd['glava'] . "' and `name`='Канализация 1 этаж'");
$vb = mysql_fetch_array($cd);
if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 этаж' and $vb['n18'] == '8') {
\Battles\Template::header('Подземелье Луки');
?>
<div id=hint3 class=ahint></div>
<TABLE width=100% cellspacing=0 cellpadding=0 border=0>
const QUEST_ITEM_NAME = [
'g' => 'Гайка',
'v' => 'Вентиль',
'b' => 'Болт',
'z' => 'Жетон',
'k' => 'Ключиик',
];
$fd = DBPDO::$db->fetch('select location, name, glava from labirint where user_id = ?', User::$current->getId());
$vb = DBPDO::$db->fetch('select n18 from podzem3 where glava = ? and name = ?', [$fd['glava'], 'Канализация 1 этаж']);
if ($fd['location'] != '28' || $fd['name'] != 'Канализация 1 этаж' || $vb['n18'] != '8') {
return;
}
$userInfo = new UserInfo(User::$current->getId());
Template::header('Подземелье Луки');
?>
<div id=hint3 class=ahint></div>
<TABLE width=100% cellspacing=0 cellpadding=0 border=0>
<TR>
<TD valign=top>
<div style="width: 250px; text-align: center;">
<?php
$userInfo = new \Battles\User($_SESSION['uid']);
$userInfo->showUserDoll();
?>
<?php $userInfo->showUserDoll(); ?>
</div>
</TD>
<TD>
<i>
<?php
$gag = mysql_query("SELECT * FROM qwest WHERE login='" . $user['login'] . "'");
while ($qw = mysql_fetch_array($gag)) {
$name_qwest = $qw["name_items"];
if ($name_qwest == "Ключиик") {
$qwest = "1";
$name_qw = "kluchiik";
$gag = DBPDO::$db->fetchAll('select * from qwest where login = ?', User::$current->getLogin());
foreach ($gag as $qw) {
$name_qwest = $qw['name_items'];
if ($name_qwest === QUEST_ITEM_NAME['k']) {
$qwest = 1;
$name_qw = 'kluchiik';
}
}
$sasd = mysql_query("SELECT * FROM `qwest` WHERE `login`='" . $user['login'] . "' and `name_qwest`='$name_qw'");
$qwus = mysql_fetch_array($sasd);
$qwus = DBPDO::$db->fetch('select * from qwest where login = ? and name_qwest = ?', [User::$current->getLogin(), $name_qw]);
$qwest_status = $qwus["status"];
$qwes = mysql_query("SELECT * FROM `inventory` WHERE type='200' and name='Ключиик' and owner=" . $user["id"] . "");
$qwesta = mysql_fetch_array($qwes);
$qwesta = DBPDO::$db->fetch('select * from inventory where item_type = 200 and name = ? and owner_id = ?', [QUEST_ITEM_NAME['k'], User::$current->getId()]);
if ($qwesta) {
$ok_qwest = "1";
}
@ -56,24 +66,20 @@ if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 эта
}
if ($ok_qwest == '1' && $_GET['d'] == '1.3') {
$sql = "INSERT INTO `inventory`(name,duration,maxdur,cost,nlevel,nsila,nlovk,ninta,nvinos,nintel,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,img,owner,bron1,bron2,bron3,bron4,type,massa,isrep,otdel,podzem) VALUES ('Гайка силы','0','30','90','4','15','8','10','10','','3','','','','60','50','30','','','g_sila.gif','" . $user['id'] . "','5','5','5','5','2','2','1','41','1')";
$res = mysql_query($sql);
mysql_query("DELETE FROM `inventory` WHERE owner='" . $user['id'] . "' and `type`='200' and `name`='Ключиик'");
mysql_query("UPDATE `qwest` SET `status`='ok' WHERE `name_qwest`='kluchiik' and `login`='" . $user['login'] . "'");
if (!$res) {
echo mysql_error();
}
print"<span style='font-size:11px; color:red;'>Вы получили 'Гайку силы'.</span><br><br> Лука говарит спасибо...";
$query = 'insert into inventory (owner_id, name, add_strength, add_criticals, item_type, durability) values (?,?,?,?,?,?)';
$item_name = 'Гайка силы';
}
if ($ok_qwest == '1' && $_GET['d'] == '1.4') {
$sql = "INSERT INTO `inventory`(name,duration,maxdur,cost,nlevel,nsila,nlovk,ninta,nvinos,nintel,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,img,owner,bron1,bron2,bron3,bron4,type,massa,isrep,otdel,podzem) VALUES ('Гайка силы','0','30','90','4','5','4','4','10','15','','','','3','80','','50','50','','g_mudr.gif','" . $user['id'] . "','5','5','5','5','2','2','1','41','1')";
$res = mysql_query($sql);
mysql_query("DELETE FROM `inventory` WHERE owner='" . $user['id'] . "' and `type`='200' and `name`='Ключиик'");
mysql_query("UPDATE `qwest` SET `status`='ok' WHERE `name_qwest`='kluchiik' and `login`='" . $user['login'] . "'");
if (!$res) {
echo mysql_error();
$query = 'insert into inventory (owner_id, name, add_dexterity, add_evasion, item_type, durability) values (?,?,?,?,?,?)';
$item_name = 'Гайка ловкости';
}
print"<span style='font-size:11px; color:red;'>Вы получили 'Гайку мудрости'.</span><br><br>Лука говарит спасибо...";
if ($ok_qwest == 1 && ($_GET['d'] == 1.3 || $_GET['d'] == 1.4)) {
DBPDO::$db->execute($query, [User::$current->getId(), $item_name, 3, 30, Item::ITEM_TYPE_AMULET, 20]);
$query = 'delete from inventory where owner_id = ? and item_type = 200 and name = ?';
DBPDO::$db->execute($query, [User::$current->getId(), QUEST_ITEM_NAME['k']]);
$query = 'update qwest set status = ? where name_qwest = ? and login = ?';
DBPDO::$db->execute($query, ['ok', 'kluchiik', User::$current->getLogin()]);
echo sprintf('<span style="font-size: 11px; color: #f00">Вы получили предмет %s.</span><br><br>Лука говорит спасибо...', $item_name);
}
}
@ -86,598 +92,104 @@ if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 эта
/////////////////////
if ($_GET['d'] == '3') {
$sear = mysql_query("SELECT maxdur,id FROM `inventory` WHERE `type`='200' and `name`='Гайка' and owner='" . $user["id"] . "'");
while ($alls = mysql_fetch_array($sear)) {
$total_mass += $alls['maxdur'];
$alls_id = $alls['id'];
}
$vear = mysql_query("SELECT maxdur,id FROM `inventory` WHERE `type`='200' and `name`='Вентиль' and owner='" . $user["id"] . "'");
while ($vls = mysql_fetch_array($vear)) {
$total_mass_v += $vls['maxdur'];
$vls_id = $vls['id'];
}
$vearb = mysql_query("SELECT maxdur,id FROM `inventory` WHERE `type`='200' and `name`='Болт' and owner='" . $user["id"] . "'");
while ($bls = mysql_fetch_array($vearb)) {
$total_mass_b += $bls['maxdur'];
$bls_id = $bls['id'];
}
$query = 'select item_id, durability, name from inventory where item_type = 200 and name in (?,?,?) and owner_id = ?';
$a = DBPDO::$db->fetchAll($query, [QUEST_ITEM_NAME['g'], QUEST_ITEM_NAME['v'], QUEST_ITEM_NAME['b'], User::$current->getId()]);
unset($query);
if (($user['level'] >= 4) && ($user['level'] < 7)) {
if ($total_mass < 3) {
$vsego = "0";
$ziton = "0";
foreach ($a as $row) {
if ($row['name'] == QUEST_ITEM_NAME['g']) {
$total_mass += $row['maxdur'];
$alls_id = $row['id'];
}
if ($total_mass >= 3) {
$vsego = "3";
$ziton = "1";
if ($row['name'] == QUEST_ITEM_NAME['b']) {
$total_mass_b += $row['maxdur'];
$vls_id = $row['id'];
}
if ($total_mass >= 6) {
$vsego = "6";
$ziton = "2";
}
if ($total_mass >= 9) {
$vsego = "9";
$ziton = "3";
}
if ($total_mass >= 12) {
$vsego = "12";
$ziton = "4";
}
if ($total_mass >= 15) {
$vsego = "15";
$ziton = "5";
}
if ($total_mass >= 18) {
$vsego = "18";
$ziton = "6";
}
if ($total_mass >= 21) {
$vsego = "21";
$ziton = "7";
}
if ($total_mass >= 24) {
$vsego = "24";
$ziton = "8";
}
if ($total_mass >= 27) {
$vsego = "27";
$ziton = "9";
}
if ($total_mass >= 30) {
$vsego = "30";
$ziton = "10";
}
if ($total_mass >= 33) {
$vsego = "33";
$ziton = "11";
}
if ($total_mass >= 36) {
$vsego = "36";
$ziton = "12";
}
if ($total_mass >= 39) {
$vsego = "39";
$ziton = "13";
}
if ($total_mass >= 42) {
$vsego = "42";
$ziton = "14";
}
if ($total_mass >= 45) {
$vsego = "45";
$ziton = "15";
}
if ($total_mass >= 48) {
$vsego = "48";
$ziton = "16";
}
if ($total_mass >= 51) {
$vsego = "51";
$ziton = "17";
}
if ($total_mass >= 54) {
$vsego = "54";
$ziton = "18";
}
if ($total_mass >= 57) {
$vsego = "57";
$ziton = "19";
}
if ($total_mass >= 60) {
$vsego = "60";
$ziton = "20";
}
} elseif (($user['level'] >= 7) && ($user['level'] <= 8)) {
if ($total_mass < 9) {
$vsego = "0";
$ziton = "0";
}
if ($total_mass >= 9) {
$vsego = "9";
$ziton = "1";
}
if ($total_mass >= 18) {
$vsego = "18";
$ziton = "2";
}
if ($total_mass >= 27) {
$vsego = "27";
$ziton = "3";
}
if ($total_mass >= 36) {
$vsego = "36";
$ziton = "4";
}
if ($total_mass >= 45) {
$vsego = "45";
$ziton = "5";
}
if ($total_mass >= 54) {
$vsego = "54";
$ziton = "6";
}
if ($total_mass >= 63) {
$vsego = "63";
$ziton = "7";
}
if ($total_mass >= 72) {
$vsego = "72";
$ziton = "8";
}
if ($total_mass >= 81) {
$vsego = "81";
$ziton = "9";
}
if ($total_mass >= 100) {
$vsego = "100";
$ziton = "10";
}
if ($total_mass >= 109) {
$vsego = "109";
$ziton = "11";
}
if ($total_mass >= 118) {
$vsego = "118";
$ziton = "12";
}
if ($total_mass >= 127) {
$vsego = "127";
$ziton = "13";
}
if ($total_mass >= 136) {
$vsego = "136";
$ziton = "14";
}
if ($total_mass >= 145) {
$vsego = "145";
$ziton = "15";
}
if ($total_mass >= 154) {
$vsego = "154";
$ziton = "16";
}
if ($total_mass >= 163) {
$vsego = "163";
$ziton = "17";
}
if ($total_mass >= 172) {
$vsego = "172";
$ziton = "18";
}
if ($total_mass >= 181) {
$vsego = "181";
$ziton = "19";
}
if ($total_mass >= 200) {
$vsego = "200";
$ziton = "20";
if ($row['name'] == QUEST_ITEM_NAME['v']) {
$total_mass_v = +$row['maxdur'];
$bls_id = $row['id'];
}
}
$ostalos = $total_mass - $vsego;
if ($ostalos == '0') {
mysql_query("DELETE FROM `inventory` WHERE `name`='Гайка' and owner='" . $user["id"] . "'");
if (in_array(User::$current->getLevel(), [4, 5, 6])) {
$lim = 3;
$max = 60;
$vsego_v = $total_mass_v;
$ziton_v = $total_mass_v * 3;
$vsego_b = $total_mass_b;
$ziton_b = $total_mass_b;
} elseif (in_array(User::$current->getLevel(), [7, 8])) {
$lim = 9;
$max = 200;
$vsego_v = $total_mass_v;
$ziton_v = $total_mass_v;
$lim_b = 9;
$max_b = 200;
}
$ziton = intval($total_mass / $lim);
if ($ziton > $max) {
$ziton = $max;
}
$vsego = $ziton * $lim;
$ziton_b = intval($total_mass_b / $lim_b);
if ($ziton_b > $max_b) {
$ziton_b = $max_b;
}
$vsego_b = $ziton_b * $lim_b;
$query1 = 'delete from inventory where name = ? and owner_id = ?';
$query2 = 'update inventory set durability = ?, weight = ? where item_id = ?';
$ostalos = intval($total_mass - $vsego);
$ostalos_v = intval($total_mass_v - $vsego_v);
$ostalos_b = intval($total_mass_b - $vsego_b);
if ($ostalos == 0) {
DBPDO::$db->execute($query1, [QUEST_ITEM_NAME['g'], User::$current->getId()]);
} else {
$ze_m = $ostalos * 0.1;
mysql_query("UPDATE `inventory` SET `maxdur`='$ostalos', `massa`='$ze_m' WHERE `id`='$alls_id'");
}
if (($user['level'] >= 4) && ($user['level'] < 7)) {
if ($total_mass_v <= 0) {
$vsego_v = "0";
$ziton_v = "0";
}
if ($total_mass_v >= 1) {
$vsego_v = "1";
$ziton_v = "3";
}
if ($total_mass_v >= 2) {
$vsego_v = "2";
$ziton_v = "6";
}
if ($total_mass_v >= 3) {
$vsego_v = "3";
$ziton_v = "9";
}
if ($total_mass_v >= 4) {
$vsego_v = "4";
$ziton_v = "12";
}
if ($total_mass_v >= 5) {
$vsego_v = "5";
$ziton_v = "15";
}
if ($total_mass_v >= 6) {
$vsego_v = "6";
$ziton_v = "18";
}
if ($total_mass_v >= 7) {
$vsego_v = "7";
$ziton_v = "21";
}
if ($total_mass_v >= 8) {
$vsego_v = "8";
$ziton_v = "24";
}
if ($total_mass_v >= 9) {
$vsego_v = "9";
$ziton_v = "27";
}
if ($total_mass_v >= 10) {
$vsego_v = "10";
$ziton_v = "30";
}
if ($total_mass_v >= 11) {
$vsego_v = "11";
$ziton_v = "33";
}
if ($total_mass_v >= 12) {
$vsego_v = "12";
$ziton_v = "36";
}
if ($total_mass_v >= 13) {
$vsego_v = "13";
$ziton_v = "39";
}
if ($total_mass_v >= 14) {
$vsego_v = "14";
$ziton_v = "42";
}
if ($total_mass_v >= 15) {
$vsego_v = "15";
$ziton_v = "45";
}
if ($total_mass_v >= 16) {
$vsego_v = "16";
$ziton_v = "48";
}
if ($total_mass_v >= 17) {
$vsego_v = "17";
$ziton_v = "51";
}
if ($total_mass_v >= 18) {
$vsego_v = "18";
$ziton_v = "54";
}
if ($total_mass_v >= 19) {
$vsego_v = "19";
$ziton_v = "57";
}
if ($total_mass_v >= 20) {
$vsego_v = "20";
$ziton_v = "60";
}
} elseif (($user['level'] >= 7) && ($user['level'] <= 8)) {
if ($total_mass_v <= 0) {
$vsego_v = "0";
$ziton_v = "0";
}
if ($total_mass_v >= 1) {
$vsego_v = "1";
$ziton_v = "1";
}
if ($total_mass_v >= 2) {
$vsego_v = "2";
$ziton_v = "2";
}
if ($total_mass_v >= 3) {
$vsego_v = "3";
$ziton_v = "3";
}
if ($total_mass_v >= 4) {
$vsego_v = "4";
$ziton_v = "4";
}
if ($total_mass_v >= 5) {
$vsego_v = "5";
$ziton_v = "5";
}
if ($total_mass_v >= 6) {
$vsego_v = "6";
$ziton_v = "6";
}
if ($total_mass_v >= 7) {
$vsego_v = "7";
$ziton_v = "7";
}
if ($total_mass_v >= 8) {
$vsego_v = "8";
$ziton_v = "8";
}
if ($total_mass_v >= 9) {
$vsego_v = "9";
$ziton_v = "9";
}
if ($total_mass_v >= 10) {
$vsego_v = "10";
$ziton_v = "10";
}
if ($total_mass_v >= 11) {
$vsego_v = "11";
$ziton_v = "11";
}
if ($total_mass_v >= 12) {
$vsego_v = "12";
$ziton_v = "12";
}
if ($total_mass_v >= 13) {
$vsego_v = "13";
$ziton_v = "13";
}
if ($total_mass_v >= 14) {
$vsego_v = "14";
$ziton_v = "14";
}
if ($total_mass_v >= 15) {
$vsego_v = "15";
$ziton_v = "15";
}
if ($total_mass_v >= 16) {
$vsego_v = "16";
$ziton_v = "16";
}
if ($total_mass_v >= 17) {
$vsego_v = "17";
$ziton_v = "17";
}
if ($total_mass_v >= 18) {
$vsego_v = "18";
$ziton_v = "18";
}
if ($total_mass_v >= 19) {
$vsego_v = "19";
$ziton_v = "19";
}
if ($total_mass_v >= 20) {
$vsego_v = "20";
$ziton_v = "20";
}
DBPDO::$db->execute($query2, [$ostalos, $ostalos * 0.1, $alls_id]);
}
$ostalos_v = $total_mass_v - $vsego_v;
if ($ostalos_v == '0') {
mysql_query("DELETE FROM `inventory` WHERE `name`='Вентиль' and owner='" . $user["id"] . "'");
if ($ostalos_v == 0) {
DBPDO::$db->execute($query1, [QUEST_ITEM_NAME['v'], User::$current->getId()]);
} else {
$ze_v = $ostalos_v * 0.2;
mysql_query("UPDATE `inventory` SET `maxdur`='$ostalos_v',`massa`='$ze_v' WHERE `id`='$vls_id'");
}
if (($user['level'] >= 4) && ($user['level'] < 7)) {
if ($total_mass_b <= 0) {
$vsego_b = "0";
$ziton_b = "0";
}
if ($total_mass_b >= 1) {
$vsego_b = "1";
$ziton_b = "1";
}
if ($total_mass_b >= 2) {
$vsego_b = "2";
$ziton_b = "2";
}
if ($total_mass_b >= 3) {
$vsego_b = "3";
$ziton_b = "3";
}
if ($total_mass_b >= 4) {
$vsego_b = "4";
$ziton_b = "4";
}
if ($total_mass_b >= 5) {
$vsego_b = "5";
$ziton_b = "5";
}
if ($total_mass_b >= 6) {
$vsego_b = "6";
$ziton_b = "6";
}
if ($total_mass_b >= 7) {
$vsego_b = "7";
$ziton_b = "7";
}
if ($total_mass_b >= 8) {
$vsego_b = "8";
$ziton_b = "8";
}
if ($total_mass_b >= 9) {
$vsego_b = "9";
$ziton_b = "9";
}
if ($total_mass_b >= 10) {
$vsego_b = "10";
$ziton_b = "10";
}
if ($total_mass_b >= 11) {
$vsego_b = "11";
$ziton_b = "11";
}
if ($total_mass_b >= 12) {
$vsego_b = "12";
$ziton_b = "12";
}
if ($total_mass_b >= 13) {
$vsego_b = "13";
$ziton_b = "13";
}
if ($total_mass_b >= 14) {
$vsego_b = "14";
$ziton_b = "14";
}
if ($total_mass_b >= 15) {
$vsego_b = "15";
$ziton_b = "15";
}
if ($total_mass_b >= 16) {
$vsego_b = "16";
$ziton_b = "16";
}
if ($total_mass_b >= 17) {
$vsego_b = "17";
$ziton_b = "17";
}
if ($total_mass_b >= 18) {
$vsego_b = "18";
$ziton_b = "18";
}
if ($total_mass_b >= 19) {
$vsego_b = "19";
$ziton_b = "19";
}
if ($total_mass_b >= 20) {
$vsego_b = "20";
$ziton_b = "20";
}
} elseif (($user['level'] >= 7) && ($user['level'] <= 8)) {
if ($total_mass_b < 9) {
$vsego_b = "0";
$ziton_b = "0";
}
if ($total_mass_b >= 9) {
$vsego_b = "9";
$ziton_b = "1";
}
if ($total_mass_b >= 18) {
$vsego_b = "18";
$ziton_b = "2";
}
if ($total_mass_b >= 27) {
$vsego_b = "27";
$ziton_b = "3";
}
if ($total_mass_b >= 36) {
$vsego_b = "36";
$ziton_b = "4";
}
if ($total_mass_b >= 45) {
$vsego_b = "45";
$ziton_b = "5";
}
if ($total_mass_b >= 54) {
$vsego_b = "54";
$ziton_b = "6";
}
if ($total_mass_b >= 63) {
$vsego_b = "63";
$ziton_b = "7";
}
if ($total_mass_b >= 72) {
$vsego_b = "72";
$ziton_b = "8";
}
if ($total_mass_b >= 81) {
$vsego_b = "81";
$ziton_b = "9";
}
if ($total_mass_b >= 100) {
$vsego_b = "100";
$ziton_b = "10";
}
if ($total_mass_b >= 109) {
$vsego_b = "109";
$ziton_b = "11";
}
if ($total_mass_b >= 118) {
$vsego_b = "118";
$ziton_b = "12";
}
if ($total_mass_b >= 127) {
$vsego_b = "127";
$ziton_b = "13";
}
if ($total_mass_b >= 136) {
$vsego_b = "136";
$ziton_b = "14";
}
if ($total_mass_b >= 145) {
$vsego_b = "145";
$ziton_b = "15";
}
if ($total_mass_b >= 154) {
$vsego_b = "154";
$ziton_b = "16";
}
if ($total_mass_b >= 163) {
$vsego_b = "163";
$ziton_b = "17";
}
if ($total_mass_b >= 172) {
$vsego_b = "172";
$ziton_b = "18";
}
if ($total_mass_b >= 181) {
$vsego_b = "181";
$ziton_b = "19";
}
if ($total_mass_b >= 200) {
$vsego_b = "200";
$ziton_b = "20";
}
}
$ostalos_b = $total_mass_b - $vsego_b;
if ($ostalos_b == '0') {
mysql_query("DELETE FROM `inventory` WHERE `name`='Болт' and owner='" . $user["id"] . "'");
} else {
$ze_b = $ostalos_b * 0.1;
mysql_query("UPDATE `inventory` SET `maxdur`='$ostalos_b',`massa`='$ze_b' WHERE `id`='$bls_id'");
DBPDO::$db->execute($query2, [$ostalos_v, $ostalos_v * 0.2, $vls_id]);
}
if (!empty($ziton) {
$g = mysql_fetch_array(mysql_query("SELECT `maxdur` FROM `inventory` WHERE `owner`='" . $user['id'] . "' and `type`='200' and `name`='Жетон'"));
$koll = $g["maxdur"];
$mas = $ziton * 0.1;
if ($koll > '0') {
mysql_query("UPDATE `inventory` SET maxdur=maxdur+$ziton, massa=massa+$mas,`present`='Лука' WHERE owner='" . $user['id'] . "' and `type`='200' and `name`='Жетон'");
if ($ostalos_b == 0) {
DBPDO::$db->execute($query1, [QUEST_ITEM_NAME['b'], User::$current->getId()]);
} else {
$mas = $ziton * 0.1;
$fo = mysql_query("INSERT INTO `inventory`(name,duration,maxdur,img,owner,type,isrep,massa,present) VALUES('Жетон','0','$ziton','ziton.gif','" . $user['id'] . "','200','0','$mas', 'Лука')");
}
DBPDO::$db->execute($query2, [$ostalos_b, $ostalos_b * 0.1, $bls_id]);
}
if (!empty($ziton_v)) {
$gv = mysql_fetch_array(mysql_query("SELECT `maxdur` FROM `inventory` WHERE `owner`='" . $user['id'] . "' and `type`='200' and `name`='Жетон'"));
$kollv = $gv["maxdur"];
$mas = $ziton_v * 0.1;
if ($kollv > '0') {
mysql_query("UPDATE `inventory` SET maxdur=maxdur+$ziton_v, massa=massa+$mas,`present`='Лука' WHERE owner='" . $user['id'] . "' and `type`='200' and `name`='Жетон'");
} else {
$mas = $ziton_v * 0.1;
$fov = mysql_query("INSERT INTO `inventory`(name,duration,maxdur,img,owner,type,isrep,massa, present) VALUES('Жетон','0','$ziton_v','ziton.gif','" . $user['id'] . "','200','0','$mas', 'Лука')");
}
}
unset($query1, $query2);
if (!empty($ziton_b)) {
$gb = mysql_fetch_array(mysql_query("SELECT `maxdur` FROM `inventory` WHERE `owner`='" . $user['id'] . "' and `type`='200' and `name`='Жетон'"));
$kollb = $gb["maxdur"];
$mas = $ziton_b * 0.1;
if ($kollb > '0') {
mysql_query("UPDATE `inventory` SET maxdur=maxdur+$ziton_b, massa=massa+$mas,`present`='Лука' WHERE owner='" . $user['id'] . "' and `type`='200' and `name`='Жетон'");
} else {
$mas = $ziton_b * 0.1;
$fob = mysql_query("INSERT INTO `inventory`(name,duration,maxdur,img,owner,type,isrep,massa, present) VALUES('Жетон','0','$ziton_b','ziton.gif','" . $user['id'] . "','200','0','$mas', 'Лука')");
}
}
$query1 = 'select durability from inventory where owner_id = ? and item_type = 200 and name = ?';
$query2 = 'update inventory set durability = durability + ?, weight = weight + ?, present = ? where owner_id = ? and item_type = 200 and name = ?';
$query3 = 'insert into inventory (name, durability, owner_id, item_type, weight, present) values (?,?,?,?,?,?)';
if (empty($ziton) && empty($ziton_v) && empty($ziton_b)) {
$all_zitons = $ziton + $ziton_v + $ziton_b;
if (!empty($all_zitons)) {
$check = DBPDO::$db->fetch($query1, [User::$current->getId(), QUEST_ITEM_NAME['z']]);
if ($check['durability'] > 0) {
DBPDO::$db->execute($query2, [$all_zitons, $all_zitons * 0.1, 'Лука', User::$current->getId(), QUEST_ITEM_NAME['z']]);
} else {
DBPDO::$db->execute($query3, [QUEST_ITEM_NAME['z'], $all_zitons, User::$current->getId(), 200, $all_zitons * 0.1 . 'Лука']);
}
unset($query1, $query2, $query3);
} else {
print" ИХ больше у тебя нету... Неси еще, Луке нужно больше ИХ! ";
}
if ($ziton > 0) {
print" Вы отдали: <b>$vsego</b> шт.Гаек <br> Получили: <b>$ziton</b> шт.Жетонов.<br>";
}
@ -693,20 +205,18 @@ if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 эта
print"А?...";
}
if ($_GET['d'] == '5') {
print"Лука и Мартын тут живут давно... чииинят трубыы. Лука Чинит. Лука не любит пауков... Лука любит жетоны... Они красивые... Лука любит играть с ними... Мартын к паукам ушел... Теперь Лука один, чииинит...";
echo 'Лука и Мартын тут живут давно... чииинят трубыы. Лука Чинит. Лука не любит пауков... Лука любит жетоны... Они красивые... Лука любит играть с ними... Мартын к паукам ушел... Теперь Лука один, чииинит...';
}
if ($qwest != '1') {
if ($_GET['d'] == '6') {
print"Да да! Мартын гаад... он украл у Луки важную вещь 'Ключиик'... убей Мартына... забери 'Ключиик'... принеси его к Луке... Лука вознаградит тебя...";
echo 'Да да! Мартын гаад... он украл у Луки важную вещь ' . QUEST_ITEM_NAME['k'] . '... убей Мартына... забери ' . QUEST_ITEM_NAME['k'] . '... принеси его к Луке... Лука вознаградит тебя...';
}
if ($_GET['d'] == '7') {
if ($qwest != '1') {
$T1 = mysql_query("INSERT INTO qwest (user_id,login,name_qwest,name_items,id_items,dlja,zadanie,kw,status) VALUES('" . $user['id'] . "','" . $user['login'] . "','kluchiik','Ключиик','','Лука','Найти ключиик','0','no')");
print"<span style='font-size:11px; color:red;'>Вы приняли задание.(Найти 'ключиик').</span><br><br>
Хорошо... Лука будет ждать...";
$T1 = DBPDO::$db->execute('insert into qwest (user_id,login,name_qwest,name_items,id_items,dlja,zadanie,kw,status) values (?,?,?,?,?,?,?,?,?)', [User::$current->getId(), User::$current->getLogin(), 'kluchiik', QUEST_ITEM_NAME['k'], '', 'Лука', 'Найти ключиик', 0, 'no']);
echo sprintf('<span style="font-size:11px; color:red;">Вы приняли задание.(Найти %s).</span><br><br>Хорошо... Лука будет ждать...', QUEST_ITEM_NAME['k']);
} else {
print"<span style='font-size:11px; color:red;'>Вы уже приняли задание.(Найти 'ключиик').</span><br><br>
Ну что? Лука ждёт...";
echo sprintf('<span style="font-size:11px; color:red;">Вы уже приняли задание.(Найти %s).</span><br><br>Ну что? Лука ждёт...', QUEST_ITEM_NAME['k']);
}
}
}
@ -779,18 +289,14 @@ if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 эта
</TD>
<TD>
<?php
$bot = "Лука";
$buser = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login` = '$bot' LIMIT 1;"));
$buser = DBPDO::$db->fetch('select * from users where login = ?', 'Лука');
//Этот класс не умеет работать с ботами! Этот вызов - заглушка!
$botInfo = new \Battles\User('Лука');
$botInfo = new UserInfo('Лука');
$botInfo->showUserDoll();
?>
</TD>
</TR>
</TABLE>
<!-- <DIV ID=oMenu CLASS=menu onmouseout="closeMenu()"></DIV> -->
<DIV ID="oMenu" style="position:absolute; border:1px solid #666; background-color:#CCC; display:none; "></DIV>
<TEXTAREA ID=holdtext STYLE="display:none;"></TEXTAREA>
<?
}
</TABLE>
<!-- <DIV ID=oMenu CLASS=menu onmouseout="closeMenu()"></DIV> -->
<DIV ID="oMenu" style="position:absolute; border:1px solid #666; background-color:#CCC; display:none; "></DIV>
<TEXTAREA ID=holdtext STYLE="display:none;"></TEXTAREA>

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);
}
}