mirror of
https://github.com/claradex/nativegallery.git
synced 2025-06-03 13:03:54 +03:00
49 lines
No EOL
1.9 KiB
PHP
49 lines
No EOL
1.9 KiB
PHP
<?php
|
|
// Prevent worker script termination when a client connection is interrupted
|
|
require __DIR__.'/vendor/autoload.php';
|
|
session_start();
|
|
use App\Core\{Routes, Page};
|
|
use App\Services\DB;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
use Tracy\Debugger;
|
|
|
|
class App
|
|
{
|
|
public static function start()
|
|
{
|
|
ini_set('display_errors', 0);
|
|
ini_set('display_startup_errors', 0);
|
|
error_reporting(E_ALL);
|
|
|
|
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/ngallery.yaml')) {
|
|
define("NGALLERY", Yaml::parse(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/ngallery.yaml'))['ngallery']);
|
|
define("NGALLERY_TASKS", Yaml::parse(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/app/Controllers/Exec/Tasks/ngallery-tasks.yaml'))['tasks']);
|
|
if (NGALLERY['root']['debug'] === true) {
|
|
Debugger::enable();
|
|
}
|
|
try {
|
|
|
|
if (NGALLERY['root']['maintenance'] === false) {
|
|
DB::init([
|
|
'driver' => 'mysql',
|
|
'host' => NGALLERY['root']['db']['host'],
|
|
'database' => NGALLERY['root']['db']['name'],
|
|
'username' => NGALLERY['root']['db']['login'],
|
|
'password' => NGALLERY['root']['db']['password'],
|
|
]);
|
|
Routes::init();
|
|
} else {
|
|
Page::set('Errors/ServerDown');
|
|
}
|
|
} catch (PDOException $ex) {
|
|
echo '<details><summary class="p20 s5" style="border:none; margin:0 -20px"><b>Произошла ошибка MySQL</b></summary>'.nl2br($ex).'</details>';
|
|
} catch (Exception $ex) {
|
|
echo '<pre><b>Произошла скриптовая ошибка PHP</b><br><br>'.nl2br($ex).'</pre>';
|
|
}
|
|
} else {
|
|
Page::set('Errors/Problems');
|
|
}
|
|
}
|
|
}
|
|
|
|
App::start(); |