Проверки с перенаправлениями переехали в functions.php. Глобальный выход если нет сессии в config.php.

pull/19/head
lopar 2020-10-30 01:30:05 +02:00
parent 2024a6fac7
commit 32c72e3413
143 changed files with 6986 additions and 7329 deletions

View File

@ -1,20 +1,7 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once 'functions.php';
$user = $user ?? null;
if ($user->room != 61) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fight.php');
exit;
}
$user = $user ?? new \Battles\User($_SESSION['uid']);
const SMITH = 'оружейник';
const MERCENARY = 'наёмник';
const MEDIC = 'лекарь';

View File

@ -1,10 +1,5 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$start = db::c()->query('SELECT `value` FROM `variables` WHERE `var` = "arena_of_gods"')->fetch_assoc();

View File

@ -1,21 +1,8 @@
<?php
ob_start("ob_gzhandler");
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$user = $user ?? [];
if ($user->room != 29) {
header("Location: main.php");
exit;
}
if ($user->battle != 0) {
header('location: fbattle.php');
exit;
}
$user = $user ?? new \Battles\User($_SESSION['uid']);
const SUCCESS = "Успешная операция!";
$bank = new \Battles\Bank($user->id);

View File

@ -1,9 +1,5 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$header = $_GET['header'] ?? null;
$ch = $_GET['ch'] ?? null;

View File

@ -1,10 +1,6 @@
<?
<?php
session_start();
require_once('functions.php');
if (empty($_SESSION['uid'])) {
header('Location: index.php');
exit;
}
if ($user->room == 51) {
header('location: city.php');
exit;

View File

@ -1,19 +1,6 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include "functions.php";
if ($user->room != 600) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
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;"));
$wait_msg = "Ждем подтверждения от всей группы...";

View File

@ -1,11 +1,5 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include "functions.php";
require_once "functions.php";
$in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}' LIMIT 1;"));
$wait_msg = "Ждем готовности всей группы...";
//rooms
@ -108,14 +102,6 @@ $ch_bots[2]=array
"1"=>"Босс глубин"
);*/
if ($user->room != 601) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
if ($in_haos['status'] == 4) {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '600',`online`.`room` = '600' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
mysql_query("UPDATE `cit_haos_status` SET room='0',bot='0',group='0' WHERE id = '{$user['id']}'; ");

View File

@ -1,9 +1,6 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
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;"));
@ -12,19 +9,7 @@ if (!$in_park) {
$in_park = mysql_fetch_array(mysql_query("SELECT * FROM `cit_park` WHERE `id` = '{$user['id']}' LIMIT 1;"));
}
include "functions.php";
if ($user->room != 602) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
//комнаты парка
$ch_rooms = [
// 0 - empty
"1" => "Площадь (1)",

View File

@ -1,18 +1,9 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$user = $user ?? null;
$user = $user ?? new \Battles\User($_SESSION['uid']);
if ($user->room == 403) {
include "startpodzemel.php";
if ($user->battle != 0) {
header('location: fbattle.php');
exit;
}
if ($_GET['act'] == "cexit") {
$das = mysql_query("select glava,glav_id from `labirint` where user_id='" . $user['id'] . "'");
$rf = mysql_fetch_array($das);

View File

@ -1,9 +1,5 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header('Location: index.php');
exit();
}
require_once 'functions.php';
//require_once 'cave/cave_bots.php';
@ -447,11 +443,6 @@ function getcavedata($caveleader, $floor)
return unserialize(implode("", file("cavedata/$caveleader-$floor.dat")));
}
if (!in_array($user->room, Config::$caverooms)) {
header("Location: main.php");
exit('Not in this life ...');
}
if (isset($_GET['direction'])) {
$dir = (int)$_GET['direction'];
if ($dir >= 0 && $dir <= 3) {

4
ch.php
View File

@ -1,9 +1,5 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once 'functions.php';
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `id` = ?i', time(), $u->i()['id']);

View File

@ -6,10 +6,6 @@
*/
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "config.php";
$msg = $_POST['msg'] ?? null;

View File

@ -3,22 +3,9 @@
* Центральная площадь
*/
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$user = $user ?? [];
$user = $user ?? new \Battles\User($_SESSION['uid']);
if ($user->battle) {
header('location: fbattle.php');
exit;
}
if ($user->in_tower == 1) {
header('Location: towerin.php');
exit;
}
if ($user->zayavka) {
exit;
}

View File

@ -1,11 +1,7 @@
<?php
ob_start("ob_gzhandler");
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include_once 'functions.php';
require_once 'functions.php';
if (!$user->clan) {
exit(err('Вы не состоите в клане!'));
}

View File

@ -1,24 +1,8 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
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;"));
include "functions.php";
if ($user->room != 45) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
$cc_date = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var`='cc_time' LIMIT 1;"));
$ccd = $cc_date['value'];

View File

@ -1,15 +1,7 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once 'functions.php';
$user = $user ?? [];
if ($user->room != 30) {
header("Location: main.php");
exit;
}
$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();
$clanFullName = $_POST['clan_full_name'] ?? '';
$clanShortName = $_POST['clan_short_name'] ?? '';
@ -42,7 +34,7 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
try {
db::c()->query('INSERT INTO clans (owner_id, full_name, short_name, info) VALUES (?i,"?s","?s","?s")', $user->id, $clanFullName, $clanShortName, $clanInfo);
$userBank->setMoney($userBank->getMoney() - Config::$clan_register_cost);
Bank::setBankMoney($userBank->getMoney(), $user->id, 'clanRegister');
Battles\Bank::setBankMoney($userBank->getMoney(), $user->id, 'clanRegister');
// Заглушка для отображения данных по только что зарегистрированному клану, когда запрос в базу в начале файла ещё не проходит.
$userClan = new stdClass();
$userClan->full_name = $clanFullName;
@ -59,8 +51,8 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
}
}
}
\Battles\Template::header(Rooms::$roomNames[30]);
\Battles\Template::buildingTop(Rooms::$roomNames[30], 'strah');
\Battles\Template::header(\Battles\Rooms::$roomNames[30]);
\Battles\Template::buildingTop(\Battles\Rooms::$roomNames[30], 'strah');
if ($userClan): ?>
<div>
<fieldset style="display: inline;">

View File

@ -25,15 +25,15 @@ class DressedItems
private function getDressedItems()
{
try {
$this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->USERID);
} catch (Exception $e) {
$this->DB = \db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->USERID);
} catch (\Exception $e) {
echo '<div class="debug">Не прогрузилась таблица inventory (*) для класса DressedItems.</div>';
}
}
private function getDressedItemById($item_id)
{
return db::c()->query('SELECT * FROM inventory WHERE item_id = ?i AND dressed_slot > 0', $item_id)->fetch_assoc();
return \db::c()->query('SELECT * FROM inventory WHERE item_id = ?i AND dressed_slot > 0', $item_id)->fetch_assoc();
}
private function getBonusesFromDressedItems()
@ -53,8 +53,8 @@ SELECT SUM(add_strength) as sum_strength,
SUM(add_max_physical_damage) as sum_max_phys_damage
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0
SQL;
$this->DBSUM = db::c()->query($query, $this->USERID)->fetch_assoc();
} catch (Exception $e) {
$this->DBSUM = \db::c()->query($query, $this->USERID)->fetch_assoc();
} catch (\Exception $e) {
echo '<div class="debug">Не прогрузилась таблица inventory (SUM) для класса DressedItems:' . $e . '</div>';
}
}
@ -134,7 +134,7 @@ SQL;
self::getItemsInSlots();
// Проверяем, что используется один из 12 слотов и наличие предмета в слоте.
if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem[$slot_id]) {
db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i AND owner_id = ?i', $slot_id, $this->USERID);
\db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i AND owner_id = ?i', $slot_id, $this->USERID);
}
}

View File

@ -15,9 +15,6 @@ class PresentsModel
{
if (!$this->DB) {
$this->DB = \db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
if ($this->DB->getNumRows() == 0) {
throw new GameException("<div class='debug'>class PresentsModel: Не прогрузилась база!</div>");
}
}
}

View File

@ -7,7 +7,7 @@ class Travel
* Соответствие ID комнаты игровому файлу.
* @var string[]
*/
private static $roomFileName = [
public static $roomFileName = [
1 => 'main.php',
20 => 'city.php',
21 => 'city.php',
@ -21,18 +21,31 @@ class Travel
31 => 'tower.php',
34 => 'fshop.php',
37 => 'gotzamok.php',
38 => 'gotzamok.php',
39 => 'gotzamok.php',
40 => 'gotzamok.php',
41 => 'gotzamok.php',
51 => 'city.php',
61 => 'akadem.php',
401 => 'hell.php',
402 => 'lab_chaos_enter.php',
404 => 'vxod.php',
402 => 'vxod.php',
403 => 'canalizaciya.php',
//404 => 'vxod.php',
600 => 'c_haos.php',
601 => 'c_haos_in.php',
602 => 'c_park.php',
603 => 'aren_of_angels.php',
620 => 'enter_cave.php',
621 => 'cave.php',
650 => 'ul_clans.php',
660 => 'hostel.php',
661 => 'hostel_room.php',
662 => 'quest_room.php',
666 => 'jail.php',
760 => 'c_forest.php',
777 => 'obshaga.php',
1051 => 'lab_enter.php',
1052 => 'labirint.php',
1055 => 'group_arena.php',
2111 => 'city.php',
2601 => 'city.php',

View File

@ -20,8 +20,6 @@ class UserInfo extends User
*/
private function UserInfoDoll($isBattle = 0, $isMain = 0)
{
//https://jsfiddle.net/ngx0yvhc
//TODO переверстать grid, чтобы он касался только куклы.
$di = new DressedItems($this->id);
$dressedItems = $di->getItemsInSlots();
for ($i = 1; $i <= 12; $i++) {
@ -103,7 +101,6 @@ class UserInfo extends User
echo $variables;
echo '</div><!-- column -->';
echo '</div><!-- stats-container -->';
echo '<div class="debug">TODO: Сделать рассчёт модификаторов. Вывести полоску здоровья когда будет от чего отталкиваться.</div>';
echo '</div><!-- user-info -->';
}
@ -172,7 +169,7 @@ class UserInfo extends User
private function WatcherStatus()
{
$query = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = ?i', $this->watcher_id)->fetch_assoc();
$query = \db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = ?i', $this->watcher_id)->fetch_assoc();
if ($query['admin']) {
$this->watcherIsAdmin = 1;
}

View File

@ -1,27 +1,8 @@
<?php
session_start();
if (!$_SESSION['uid']) {
header("Location: index.php");
exit;
}
require_once 'functions.php';
$user = $user ?? 0;
if ($user->level < 1) {
header("Location: main.php");
exit;
}
if ($user->room != 25) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
$user = $user ?? new \Battles\User($_SESSION['uid']);
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
$putItemCost = (int)filter_input(INPUT_POST, 'cost', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
$putItemId = (int)filter_input(INPUT_POST, 'putId', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
$returningItemId = (int)filter_input(INPUT_GET, 'back', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);

View File

@ -4,7 +4,10 @@
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
ini_set('display_errors', 'On');
error_reporting(E_ALL);
define("GAMEDOMAIN", "battles.lan");
@ -28,7 +31,7 @@ require_once 'classes/Database/db.php';
* Автозагрузка классов с учётом неймспейсов.
*/
spl_autoload_register(function ($className){
spl_autoload_register(function ($className) {
$fileName = __DIR__ . '/classes/' . str_replace('\\', '/', $className . '.php');
if (file_exists($fileName)) {
require_once $fileName;
@ -204,4 +207,14 @@ trait Config
1500000000 => [10, 1, 5, 8000, 1, 9999999999], # Это тринадцатый уровень
];
public static $cavedata = [621 => ['x1' => 6, 'y1' => 11, 'dir1' => 1, 'x2' => 10, 'y2' => 8, 'dir2' => 1, 'x3' => 20, 'y3' => 4, 'dir3' => 1, 'x4' => 10, 'y4' => 10, 'dir4' => 1, 'delay' => 360, 'name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']];
//DB
protected static $db = [
'host' => '192.168.20.5',
'name' => 'battles',
'user' => 'battles',
'password' => 'bottle-neck-horse',
'port' => 32101,
'charset' => 'utf8',
];
}

View File

@ -1,6 +1,6 @@
<?php
session_start();
include("config.php");
require_once "config.php";
define('ERROR_NO_SUCH_USER', 'Такого пользователя не существует!');
define('ERROR_USER_IS_BLOCKED', 'Пользователь заблокирован!');
define('ERROR_WRONG_PASSWORD', 'Неверный пароль!');

View File

@ -1,16 +1,7 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$user = $user ?? [];
if ($user->battle) {
header('location: fbattle.php');
exit;
}
$user = $user ?? new \Battles\User($_SESSION['uid']);
function secs2hrs($s, $short = 0)
{

View File

@ -1,10 +1,6 @@
<?php
ob_start("ob_gzhandler");
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
if (isset($_POST['end'])) {
header("Location: main.php");
exit;

View File

@ -1,10 +1,5 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once 'config.php';
$userLoginStatus = db::c()->query('SELECT enter_game FROM users WHERE id = ?i', $_SESSION['uid'])->getNumRows() ?? 0;
if (empty($userLoginStatus)) {
@ -15,40 +10,40 @@ if (empty($userLoginStatus)) {
\Battles\Template::header('Окно игры');
?>
<script>
if (!navigator.cookieEnabled) {
document.write('Внимание! В вашем браузере отключена поддержка Cookies. Включите чтобы играть.');
try {
window.stop();
} catch (exception) {
document.execCommand('Stop');
}
}
</script>
<style>
IFRAME.FRAME {
width: 100%;
height: 100%;
border: 0 solid;
<script>
if (!navigator.cookieEnabled) {
document.write('Внимание! В вашем браузере отключена поддержка Cookies. Включите чтобы играть.');
try {
window.stop();
} catch (exception) {
document.execCommand('Stop');
}
}
</script>
<style>
IFRAME.FRAME {
width: 100%;
height: 100%;
border: 0 solid;
}
.frametable {
height: 100%;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: 0 solid;
border-spacing: 0;
}
.frametable {
height: 100%;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: 0 solid;
border-spacing: 0;
}
.frametd {
height: inherit;
padding: 0;
}
</style>
.frametd {
height: inherit;
padding: 0;
}
</style>
<table class="frametable">
<tr style="height: 25px;">
<td class="frametd">

View File

@ -63,11 +63,6 @@ if ($rand < 15 && $user['battle'] == 0) {
addchp('<b style="color:#990000">Внимание!</b> На вас напал "' . $bots[$rbot] . '". ', '{[]}' . Nick::id($user["id"])->short() . '{[]}');
}
if ($user['battle'] > 0) {
header('location: fbattle.php');
exit;
}
$les_login = mysql_fetch_array(mysql_query("SELECT * FROM `les_game` WHERE `owner` = '" . $user['id'] . "' LIMIT 1"));
$rooms = ["A1" => ['20', '', 'A2', '', 'B1'], "A2" => ['15', 'A1', 'A3', '', ''], "A3" => ['15', 'A2', '', '', ''], "A4" => ['15', '', 'A5', '', 'B4'], "A5" => ['15', 'A4', '', '', 'B5'], "A6" => ['15', '', 'A7', '', 'B6'], "A7" => ['15', 'A6', 'A8', '', ''], "A8" => ['15', 'A7', '', '', 'B8'], "B1" => ['20', '', '', 'A1', ''], "B2" => ['15', '', 'B3', '', 'C2'], "B3" => ['15', 'B2', 'B4', '', ''], "B4" => ['15', 'B3', '', 'A4', ''], "B5" => ['15', '', 'B6', 'A5', ''], "B6" => ['15', 'B5', 'B7', 'A6', ''], "B7" => ['15', 'B6', '', '', 'C7'], "B8" => ['15', '', '', 'A8', 'C8'], "C1" => ['20', '', '', '', 'D1'], "C2" => ['15', '', 'C3', 'B2', 'D2'], "C3" => ['15', 'C2', '', '', 'D3'], "C4" => ['15', '', '', '', 'D4'], "C5" => ['15', '', '', '', 'D5'], "C6" => ['15', '', 'C7', '', ''], "C7" => ['15', 'C6', 'C8', 'B7', ''], "C8" => ['15', 'C7', '', 'B8', 'D8'], "D1" => ['20', '', 'D2', 'C1', 'E1'], "D2" => ['15', 'D1', 'D3', 'C2', 'E2'], "D3" => ['15', 'D2', 'D4', 'C3', 'E3'], "D4" => ['15', 'D3', 'D5', 'C4', 'E4'], "D5" => ['15', 'D4', '', 'C5', ''], "D6" => ['15', '', 'D7', '', 'E6'], "D7" => ['15', 'D6', '', '', ''], "D8" => ['15', '', '', 'C8', 'E8'], "E1" => ['20', '', 'E2', 'D1', 'F1'], "E2" => ['15', 'E1', 'E3', 'D2', 'F2'], "E3" => ['15', 'E2', 'E4', 'D3', 'F3'], "E4" => ['15', 'E3', 'E5', 'D4', 'F4'], "E5" => ['15', 'E4', 'E6', '', 'F5'], "E6" => ['15', 'E5', '', 'D6', ''], "E7" => ['15', '', 'E8', '', 'F7'], "E8" => ['15', 'E7', '', 'D8', 'F8'], "F1" => ['20', '', 'F2', 'E1', 'G1'], "F2" => ['15', 'F1', 'F3', 'E2', 'G2'], "F3" => ['15', 'F2', 'F4', 'E3', 'G3'], "F4" => ['15', 'F3', 'F5', 'E4', 'G4'], "F5" => ['15', 'F4', '', 'E5', 'G5'], "F6" => ['15', '', '', '', 'G6'], "F7" => ['15', '', '', 'E7', 'G7'], "F8" => ['15', '', '', 'E8', 'G8'], "G1" => ['20', '', '', 'F1', 'H1'], "G2" => ['15', '', '', 'F2', ''], "G3" => ['15', '', '', 'F3', ''], "G4" => ['15', '', '', 'F4', ''], "G5" => ['15', '', 'G6', 'F5', ''], "G6" => ['15', 'G5', 'G7', 'F6', ''], "G7" => ['15', 'G6', 'G8', 'F7', ''], "G8" => ['15', 'G7', '', 'F8', 'H8'], "H1" => ['20', '', 'H2', 'G1', 'I1'], "H2" => ['15', 'H1', '', '', 'I2'], "H3" => ['15', '', '', '', 'I3'], "H4" => ['15', '', 'H5', '', 'I4'], "H5" => ['15', 'H4', '', '', 'I5'], "H6" => ['15', '', 'H7', '', 'I6'], "H7" => ['15', 'H6', '', '', 'I7'], "H8" => ['15', 'H7', '', 'G8', 'I8'], "I1" => ['20', '', 'I2', 'H1', ''], "I2" => ['15', 'I1', 'I3', 'H2', ''], "I3" => ['15', 'I2', 'I4', 'H3', ''], "I4" => ['15', 'I3', 'I5', 'H4', ''], "I5" => ['15', 'I4', 'I6', 'H5', ''], "I6" => ['15', 'I5', 'I7', 'H6', ''], "I7" => ['15', 'I6', 'I8', 'H7', ''], "I8" => ['15', 'I7', '', 'H8', '']];

View File

@ -1,10 +1,6 @@
<?php
session_start();
require_once 'config.php';
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
$user = new \Battles\User($_SESSION['uid']);
$sleep = db::c()->query('SELECT `id` FROM `effects` WHERE `owner` = ?i AND `time` > ?i AND `type` = 3', $user['id'], time())->fetch_assoc();
$ps = $_GET['page'] ?? 0;

View File

@ -1,19 +1,69 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
require_once 'config.php';
if (empty($_SESSION['uid'])) {
throw new \Exceptions\GameException('Не могу проинициализировать игрока!');
}
$user = new \Battles\User($_SESSION['uid']);
if ($user->id && $user->block) {
exit('user blocked!');
}
/*
* Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
*/
$fbattleCheckFiles = [
'c_haos_in.php',
'c_haos.php',
'c_park.php',
'city.php',
'clan_castle.php',
'comission.php',
'enter_cave.php',
'library.php',
'atk.php',
'podzem_dialog.php',
'post.php',
'shop.php',
'tournament.php',
'vxod.php',
'bank.php',
'canalizaciya,php',
'forest.php',
'main.php',
'repair.php',
'towerstamp.php',
'hell.php',
'ul_clans.php',
'labirint.php',
'akadem.php',
'towerin.php',
'user_anketa.php',
'zayavka.php',
];
//Может просто отовсюду? О_о
if ($user->battle && in_array(pathinfo(debug_backtrace()[0]['file'])['basename'], $fbattleCheckFiles)) {
header('location: fbattle.php');
exit;
}
$towerinCheckFiles = ['main.php', 'city.php', 'tower.php'];
if ($user->in_tower && in_array(pathinfo(debug_backtrace()[0]['file'])['basename'], $towerinCheckFiles)) {
header('location: towerin.php');
exit;
}
$roomsCheck = [22, 23, 25, 27, 29, 30, 31, 37, 38, 39, 40, 41, 45, 53, 61, 401, 402, 600, 601, 602, 621, 650, 1051, 1052];
// Если я в одной из этих комнат,
// [И] Имя файла который инклюдит файл с проверкой не совпадает с именем файла локации в которой я нахожусь
// [И] Номер комнаты который я пытаюсь открыть есть в списке проверяемых
if (in_array($user->room, $roomsCheck)
&& pathinfo(debug_backtrace()[0]['file'])['basename'] != \Battles\Travel::$roomFileName[$user->room]
&& in_array(array_search(pathinfo(debug_backtrace()[0]['file'])['basename'], \Battles\Travel::$roomFileName), $roomsCheck)) {
header('location: main.php');
exit;
}
$ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
if (isset($_GET['goto']) && isset($_GET['tStamp']) && isset($_GET['vcode']) && $_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))) {
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i, `online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_GET['goto'], $_GET['goto'], $_SESSION['uid']);

102
game.php
View File

@ -1,102 +0,0 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
session_start();
if (empty($_SESSION['uid'])) header("Location: index.php");
//include("config.php");
//$msg = filter_input(INPUT_POST,'msg');
//$uid = $_SESSION['uid'];
//if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
\Battles\Template::header('Окно игры');
?>
<style>
form {
width: 100%;
text-align: center;
}
form input {
border: 1px solid silver;
width: 80%;
margin-right: .5%;
}
form input[type="submit"] {
width: 15%;
}
body {
margin: 0;
}
.wrap {
display: grid;
height: 100vh;
grid-template-rows: 45px /* Шапка */ 2fr /* Окно игры */ 1fr /* Окно чата*/ 30px; /* Подвал */
}
header {
text-align: right;
box-shadow: 0 3px 2px -2px slategray;
}
footer {
margin: 5px;
}
#game, #chat {
overflow: auto;
box-shadow: 0 3px 2px -2px slategray;
padding: 5px;
}
a img {
border: 1px solid #fff;
transition: box-shadow 0.5s ease;
margin: 5px;
}
a img:hover {
box-shadow: 0 0 7px slategray;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrap">
<header>
<a href="/user_anketa.php" title="Анкета" target="main"><img src="http://placehold.it/32x32/33ff33?text=A"/></a>
<a href="/friend.php" title="Друзья" target="main"><img src="http://placehold.it/32x32/33ff33?text=F"/></a>
<a href="/main.php?edit=1" title="Инвентарь" target="main"><img src="http://placehold.it/32x32/33ff33?text=I"/></a>
<a href="/relikt.php?edit=1" title="Реликты" target="main"><img src="http://placehold.it/32x32?text=R"/></a>
<a href="/clan.php" title="Клан" target="main"><img src="http://placehold.it/32x32/33ff33?text=K"/></a>
<a href="/orden.php" title="Особые умения" target="main"><img
src="http://placehold.it/32x32/33ff33?text=O"/></a>
<a href="/moderators.php" title="Модераторы" target="main"><img src="http://placehold.it/32x32/33ff33?text=M"/></a>
<a href="/forum.php" title="Форум" target="main"><img src="http://placehold.it/32x32?text=F"/></a>
<a href="javascript:$('#game').load('/forum.php')"><img src="http://placehold.it/32x32?text=F"/></a>
</header>
<div id="game"></div>
<div id="chat"></div>
<footer>
<form action="chat.php" method="post" target="chat">
<input id="msg" name="msg" size="100" placeholder="Введите сообщение...">
<input type="submit" value="Отправить">
</form>
</footer>
</div>
<script>
$("#game").load("main.php");
function loadlink() {
$('#chat').load('chat.php');
}
loadlink(); // This will run on page load
setInterval(function () {
loadlink() // this will run after every 5 seconds
}, 5000);
</script>

206
game2.php
View File

@ -1,206 +0,0 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
session_start();
if (empty($_SESSION['uid'])) header("Location: index.php");
//include("config.php");
//$msg = filter_input(INPUT_POST,'msg');
//$uid = $_SESSION['uid'];
//if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
\Battles\Template::header('Окно игры');
?>
<style>
form {
width: 100%;
text-align: center;
}
form input {
border: 1px solid silver;
width: 80%;
margin-right: .5%;
}
form input[type="submit"] {
width: 15%;
}
body {
margin: 0;
}
.wrap {
display: grid;
height: 100vh;
grid-template-rows: 45px /* Шапка */ 2fr /* Окно игры */ 1fr /* Окно чата*/ 30px; /* Подвал */
}
header {
text-align: right;
box-shadow: 0 3px 2px -2px slategray;
}
footer {
margin: 5px;
}
#game, #chat {
overflow: auto;
box-shadow: 0 3px 2px -2px slategray;
padding: 5px;
}
a img {
border: 1px solid #fff;
transition: box-shadow 0.5s ease;
margin: 5px;
}
a img:hover {
box-shadow: 0 0 7px slategray;
}
.chat {
border: 1px solid #333;
margin: 15px;
width: 40%;
height: 70%;
background: #555;
color: #fff;
}
.chat-messages {
min-height: 93%;
max-height: 93%;
overflow: auto;
}
.chat-messages__content {
padding: 1px;
}
.chat__message {
border-left: 3px solid #333;
margin-top: 2px;
padding: 2px;
}
.chat__message_black {
border-color: #000;
}
.chat__message_blue {
border-color: blue;
}
.chat__message_green {
border-color: green;
}
.chat__message_red {
border-color: red;
}
.chat-input {
min-height: 6%;
}
input {
font-family: arial;
font-size: 16px;
vertical-align: middle;
background: #333;
color: #fff;
border: 0;
display: inline-block;
margin: 1px;
height: 30px;
}
.chat-form__input {
width: 79%;
}
.chat-form__submit {
width: 18%;
}
</style>
<div class="wrap">
<header>
Всякие заголовки, кнопки, ссылки, etc...
</header>
<div id="game"></div>
<div class='chat'>
<div class='chat-messages'>
<div class='chat-messages__content' id='messages'>
Загрузка...
</div>
</div>
<div class='chat-input'>
<form method='post' id='chat-form'>
<input id='message-text' class='chat-form__input' placeholder='Введите сообщение'> <input type='submit'
class='chat-form__submit'
value='=>'>
</form>
</div>
</div>
</div>
<script>
$("#game").load("main.php");
</script>
<script>
var messages__container = document.getElementById('messages');
//Контейнер сообщений — скрипт будет добавлять в него сообщения
var interval = null; //Переменная с интервалом подгрузки сообщений
var sendForm = document.getElementById('chat-form'); //Форма отправки
var messageInput = document.getElementById('message-text'); //Инпут для текста сообщения
function send_request(act, login = null, password = null) {//Основная функция
//Переменные, которые будут отправляться
var var1 = null;
var var2 = null;
if (act == 'auth') {
//Если нужно авторизоваться, получаем логин и пароль, которые были переданы в функцию
var1 = login;
var2 = password;
} else if (act == 'send') {
//Если нужно отправить сообщение, то получаем текст из поля ввода
var1 = messageInput.value;
}
$.post('includes/chat.php', { //Отправляем переменные
act: act,
var1: var1,
var2: var2
}).done(function (data) {
//Заносим в контейнер ответ от сервера
messages__container.innerHTML = data;
if (act == 'send') {
//Если нужно было отправить сообщение, очищаем поле ввода
messageInput.value = '';
}
});
}
function update() {
send_request('load');
}
interval = setInterval(update, 500);
//отлавливается событие отправки формы — это поможет отказаться от обновления страницы:
sendForm.onsubmit = function () {
send_request('send');
return false; //Возвращаем ложь, чтобы остановить классическую отправку формы
};
</script>

View File

@ -1,20 +1,8 @@
<?php /** @noinspection SqlResolve */
/* Разрушенный замок на замковой улице.
* */
<?php
/* Разрушенный замок на замковой улице. */
session_start();
define("CASTLE_MAX_LEVEL", 10);
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once 'functions.php';
if (!($user->room >= 37 && $user->room <= 41)) {
header("Location: main.php");
exit;
}
$castleOwners = db::c()->query('SELECT * FROM `clans` WHERE `short` = (SELECT * FROM `variables` WHERE `var` = "?s")', 'gotzamok');
if ($castleOwners['id'] == $user['klan']) {

View File

@ -1,20 +1,7 @@
<?php
session_start();
if (!$_SESSION['uid']) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$user = $user ?? [];
if ($user->room != 401) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('Location: fbattle.php');
exit;
}
$user = $user ?? new \Battles\User($_SESSION['uid']);
class hellround
{

View File

@ -1,10 +1,6 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header('Location: index.php');
exit;
}
include('config.php');
require_once 'config.php';
$user = new \Battles\User($_SESSION['uid']);
$hostel = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `type`, `time` FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
#include('functions.php');

View File

@ -1,9 +1,5 @@
<?
<?php
session_start();
if (empty($_SESSION['uid'])) {
header('Location: index.php');
exit;
}
require_once "functions.php";
$hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
$base = [1 => [8, 16, 24, 32], 2 => [15, 30, 45, 60], 3 => [25, 50, 75, 100], 4 => [40, 80, 120, 160]];

View File

@ -1,9 +1,5 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header('Location: index.php');
exit;
}
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

@ -1,11 +1,6 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include "functions.php";
require_once "functions.php";
if ($user['lab'] == 0) {
header("Location: index.php");
exit;
@ -18,6 +13,7 @@ $u_res = mysql_fetch_array(mysql_query("select * from `lab_user` where `id_user`
function cut() {
document.getElementById('buy').disabled = 'disabled';
}
setTimeout("document.all['b1'].disabled=false;document.all['b2'].disabled=false;document.all['b3'].disabled=false;document.all['b4'].disabled=false;", <?=(3 - $tt)?>000);
</script>

View File

@ -1,10 +1,6 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include "functions.php";
require_once "functions.php";
if ($user['lab'] == 0) {
header("Location: index.php");
exit;

View File

@ -1,306 +1,301 @@
<?php
ob_start("ob_gzhandler");
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$errkom = '';
if ($user->room == 1051) {
mysql_query('DELETE FROM `laba_zv` WHERE `time` < "' . (time() - 1 * 60 * 60) . '"');
$var = mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `vals` > "' . time() . '" AND `uid` = "' . $user['id'] . '" AND `vars` = "go_labirint" LIMIT 1'));
$zv = mysql_fetch_array(mysql_query('SELECT * FROM `laba_zv` WHERE `uid1` = "' . $user['id'] . '" OR `uid2` = "' . $user['id'] . '" OR `uid3` = "' . $user['id'] . '" OR `uid4` = "' . $user['id'] . '" LIMIT 1'));
$re = '';
if (isset($_GET['exitlaba'])) {
if (isset($zv['id'])) {
$re = 'Подали заявку и убегаем? Не хорошо!';
mysql_query('DELETE FROM `laba_zv` WHERE `time` < "' . (time() - 1 * 60 * 60) . '"');
$var = mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `vals` > "' . time() . '" AND `uid` = "' . $user['id'] . '" AND `vars` = "go_labirint" LIMIT 1'));
$zv = mysql_fetch_array(mysql_query('SELECT * FROM `laba_zv` WHERE `uid1` = "' . $user['id'] . '" OR `uid2` = "' . $user['id'] . '" OR `uid3` = "' . $user['id'] . '" OR `uid4` = "' . $user['id'] . '" LIMIT 1'));
$re = '';
if (isset($_GET['exitlaba'])) {
if (isset($zv['id'])) {
$re = 'Подали заявку и убегаем? Не хорошо!';
} else {
mysql_query("UPDATE `users`, `online` SET `users`.`room` = '2601', `online`.`room` = '2601' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$user['id']}'");
header('Location: city.php');
}
} elseif (isset($_GET['pz1'])) {
if (isset($zv['id'])) {
$re = 'Вы уже подали заявку...';