Файл: upload/core/core.php
Строк: 121
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
$installed_lock = __DIR__ . '/installed.lock';
$config_adp = __DIR__ . '/DataADP/config.php';
header("Content-Type: text/html; charset=utf-8");
require_once (__DIR__ . '/function.php');
require_once (__DIR__ . '/version.php');
// Если отсутствует хотя бы один из файлов — отправляем в установщик
if (!file_exists($installed_lock) && !file_exists($config_adp)) {
RedirectToPage('/install');
exit;
}
require_once (__DIR__ . '/DataADP/core.php');
$theme = DataFetchColumn(dbquery("SELECT `id` FROM `themes` WHERE `is_active` = 1 LIMIT 1"));
$theme = $theme ?: 'default';
require_once (__DIR__ . '/functions/error_handler.php');
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED & ~E_STRICT);
require_once (__DIR__ . '/vendor/autoload.php');
require_once (__DIR__ . '/hooks.php');
require_once (__DIR__ . '/plugins_loader.php');
foreach ($_GET as $key => $value) {
if ($key === 'search') {
continue; // пропускаем фильтр для поиска
}
if (!is_string($value) || !preg_match('#^(?:[a-z0-9_-/]+|.+(?!/))*$#i', $value)) {
RedirectToPage('/');
exit;
}
}
///////////////////////// Куки /////////////////////////
if (isset($_COOKIE['uslog']) && isset($_COOKIE['uspass'])) {
$uslog = $_COOKIE['uslog'];
$uspass = $_COOKIE['uspass'];
// Получаем пользователя из базы данных
$usr = checkCookie();
if (isset($user['id'])) {
// Проверяем, совпадают ли логин и пароль
if ($usr && $usr['login'] !== $uslog || $usr['pass'] !== $uspass) {
setcookie('uslog', '', time() - 86400 * 31, '/');
setcookie('uspass', '', time() - 86400 * 31, '/');
}
}
// Получаем пользователя еще раз
$users = checkCookie();
// Обновляем информацию о пользователе
dbquery(
"UPDATE users SET viz = :time, ip = :ip, gde = :gde WHERE id = :id",
[
':time' => time(),
':ip' => $_SERVER['REMOTE_ADDR'],
':gde' => $_SERVER['REQUEST_URI'],
':id' => $users['id']
]
);
// Проверяем, что 'viz' и 'online_us' определены и являются числами
if (isset($users['viz']) && is_numeric($users['viz']) && isset($usr['online_us']) && is_numeric($usr['online_us'])) {
$vremja = time() - $users['viz'];
if ($vremja < 120) {
$newtime = $usr['online_us'] + $vremja;
dbquery("UPDATE users SET k_online = :newtime WHERE id = :id", [
':newtime' => $newtime,
':id' => $users['id']
]);
}
}
// Проверяем, совпадают ли логин и пароль еще раз
if (isset($usr['id']) && ($users['login'] !== $uslog || $users['pass'] !== $uspass)) {
setcookie('uslog', '', time() - 86400 * 31, '/');
setcookie('uspass', '', time() - 86400 * 31, '/');
}
} else {
$usr = [];
}
$user = $usr ?? [];
$levelUs = $user['level_us'] ?? null;
$fingerUs = $user['fingerprint'] ?? null;
$gen_parameters = FetchAssoc(dbquery("SELECT * FROM `general_parameters` WHERE `id` = '1'"));
$site_info = FetchAssoc(dbquery("SELECT * FROM `site_info` WHERE `id` = '1'"));
$usr_perms = FetchAssoc(dbquery("SELECT * FROM `admin_perms` WHERE `id` = ?", [$levelUs]));
$CheckBan = FetchAssoc(dbquery("SELECT * FROM `users_banned` WHERE `us` = ?", [$user['id'] ?? '']));
$CheckFinger = FetchAssoc(dbquery("SELECT * FROM `users_banned` WHERE `fp` = ?", [$fingerUs]));
$users_perms = $usr_perms ?? [];
$CheckFingerBan = $CheckFinger ?? [];
if (!empty($_SESSION['flash_message'])) {
$title = json_encode($_SESSION['flash_title']);
$msg = json_encode($_SESSION['flash_message']);
$type = json_encode($_SESSION['flash_type']);
$dur = intval($_SESSION['flash_duration']);
echo "<script>
document.addEventListener('DOMContentLoaded', function() {
const alertContainer = document.getElementById('alertContainer') || document.body;
const title = $title;
const msg = $msg;
const type = $type;
const alert = document.createElement('div');
alert.className = 'alert ' + type;
alert.innerHTML = `
<div class='alert-title'>${title}</div>
<div class='alert-text'>${msg}</div>
`;
alertContainer.appendChild(alert);
requestAnimationFrame(() => alert.classList.add('show'));
setTimeout(() => {
alert.style.opacity = '0';
setTimeout(() => alert.remove(), 600);
}, $dur);
});
</script>";
unset($_SESSION['flash_title'], $_SESSION['flash_message'], $_SESSION['flash_type'], $_SESSION['flash_duration']);
}
use coreviewTwigView;
require_once (__DIR__ . '/template_loader.php');
load_themes();
$view = new TwigView([
'main' => __DIR__ . "/templates/$theme"
]);
load_plugins();
if (isset($user['id'])) {
CheckBan($user['id'], $CheckBan, $CheckFingerBan, $fingerUs);
}
ob_start();
?>