Проверки с перенаправлениями переехали в functions.php. Глобальный выход если нет сессии в config.php.
This commit is contained in:
+4
-12
@@ -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;">
|
||||
|
||||
Reference in New Issue
Block a user