getMessage(); } }); define('START_TIME', microtime(true)); // засекаем время старта скрипта const CORE_LOADED = true; // флаг корректного запуска require_once __DIR__ . '/config.php'; /** * Реализация механизма автозагрузки классов */ spl_autoload_register(function ($class) { if (strpos($class, 'Core') === 0) { $class = str_replace('\\', '/', $class); $classPath = ROOT_PATH . '/core/lib/' . $class . '.class.php'; if (file_exists($classPath)) { require_once $classPath; } } }); require_once __DIR__ . '/routes.php'; /** * Инициализация шаблонизатора */ $loader = new \Twig\Loader\FilesystemLoader(PATH_TO_TEMPLATES); $twig = new \Twig\Environment($loader, [//'cache' => CACHE_DIR, ]); Cache::init(CACHE_DIR, USE_CACHE); // очистка кэша if (isset($_REQUEST['clear_cache']) && $_REQUEST['clear_cache'] === CODE_VALUE_Y) { Cache::flush(); } // выход из системы if (isset($_REQUEST['logout']) && $_REQUEST['logout'] === CODE_VALUE_Y) { User::logout(); } try { $userId = User::getCurrentUserId(); } catch (CoreException $e) { $userId = null; } if (!empty($userId)) { try { $USER = new User($userId); } catch (CoreException $e) { $USER = null; } } else { $USER = null; } // debug function sendTelegram(?string $message, ?string $file = null): void { (new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN)) ->setChat(TELEGRAM_NOTIFICATION_CHANNEL) ->sendMessage($message); if(!empty($file)) { (new \Core\ExternalServices\TelegramSender(TELEGRAM_BOT_TOKEN)) ->setChat(TELEGRAM_NOTIFICATION_CHANNEL) ->sendDocument($file); } } //end debug /** * Запускаем маршрутизатор если не сказано иного */ if (defined('USE_ROUTER') && USE_ROUTER === true) { Router::execute(); die(); }