<?php
if (!defined('AYCORE_SKIP_BOTAPI_ROUTER')) define('AYCORE_SKIP_BOTAPI_ROUTER', true);
if (session_status() === PHP_SESSION_NONE) session_start();
require_once __DIR__ . '/../../config.php';
require_once __DIR__ . '/icons.php';
if (!($pdo instanceof PDO)) { http_response_code(500); exit('Database unavailable'); }
$q=$pdo->prepare('SELECT * FROM admin WHERE username=:u LIMIT 1');$q->execute([':u'=>$_SESSION['user']??'']);
if(!isset($_SESSION['user'])||!$q->fetch(PDO::FETCH_ASSOC)){header('Location: login.php');exit;}
if(empty($_SESSION['csrf_token']))$_SESSION['csrf_token']=bin2hex(random_bytes(32));
$csrf=$_SESSION['csrf_token'];
$v7=\iTz\V7\Kernel::instance() ?: \iTz\V7\Kernel::boot($pdo);
function itz_v7_h($v): string { return htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8'); }
function itz_v7_csrf(string $csrf): void { if(!hash_equals($csrf,(string)($_POST['_csrf']??''))){http_response_code(403);exit('درخواست معتبر نیست.');} }
