forkbb/app/bootstrap.php

109 lines
2.4 KiB
PHP
Raw Permalink Normal View History

<?php
2020-12-21 10:40:19 +00:00
/**
* This file is part of the ForkBB <https://github.com/forkbb>.
*
* @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
* @license The MIT License (MIT)
*/
2020-10-14 13:01:43 +00:00
declare(strict_types=1);
namespace ForkBB;
2017-02-21 10:47:34 +00:00
use ForkBB\Core\Container;
2018-08-21 14:12:17 +00:00
use ForkBB\Core\ErrorHandler;
2017-11-03 13:06:22 +00:00
use ForkBB\Models\Page;
2017-02-21 14:59:48 +00:00
use RuntimeException;
2018-08-21 14:12:17 +00:00
\error_reporting(\E_ALL ^ \E_NOTICE);
2020-10-14 13:01:43 +00:00
\ini_set('display_errors', '0');
\ini_set('log_errors', '1');
2020-08-16 12:19:04 +00:00
\setlocale(\LC_ALL, 'C');
2018-03-10 14:24:39 +00:00
\mb_language('uni');
\mb_internal_encoding('UTF-8');
\mb_substitute_character(0xFFFD);
define('FORK_GROUP_UNVERIFIED', 0);
define('FORK_GROUP_ADMIN', 1);
define('FORK_GROUP_MOD', 2);
define('FORK_GROUP_GUEST', 3);
define('FORK_GROUP_MEMBER', 4);
2023-05-13 07:29:53 +00:00
define('FORK_MESS_INFO', 'i');
define('FORK_MESS_SUCC', 's');
define('FORK_MESS_WARN', 'w');
define('FORK_MESS_ERR', 'e');
define('FORK_MESS_VLD', 'v');
2023-05-14 13:31:03 +00:00
define('FORK_GEN_NOT', 0);
define('FORK_GEN_MAN', 1);
define('FORK_GEN_FEM', 2);
2023-05-31 08:38:02 +00:00
define('FORK_JSON_ENCODE', \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR);
2023-05-14 13:31:03 +00:00
2023-10-12 13:50:07 +00:00
$loader = require __DIR__ . '/../vendor/autoload.php';
2018-08-21 14:12:17 +00:00
$errorHandler = new ErrorHandler();
2018-04-01 02:51:59 +00:00
if (\is_file(__DIR__ . '/config/main.php')) {
2017-03-13 16:14:57 +00:00
$c = new Container(include __DIR__ . '/config/main.php');
2018-04-01 02:51:59 +00:00
} elseif (\is_file(__DIR__ . '/config/install.php')) {
2017-03-13 16:14:57 +00:00
$c = new Container(include __DIR__ . '/config/install.php');
} else {
2017-11-26 11:56:54 +00:00
throw new RuntimeException('Application is not configured');
}
2023-10-12 13:50:07 +00:00
$c->autoloader = $loader;
2021-01-28 12:01:09 +00:00
$errorHandler->setContainer($c);
2017-03-13 16:14:57 +00:00
require __DIR__ . '/functions.php';
2017-12-14 12:16:09 +00:00
\ForkBB\_init($c);
2017-09-30 17:12:17 +00:00
// https or http?
2020-06-28 05:10:59 +00:00
if (
! empty($_SERVER['HTTPS'])
&& 'off' !== \strtolower($_SERVER['HTTPS'])
) {
2018-03-10 14:24:39 +00:00
$c->BASE_URL = \str_replace('http://', 'https://', $c->BASE_URL);
2017-09-30 17:12:17 +00:00
} else {
2018-03-10 14:24:39 +00:00
$c->BASE_URL = \str_replace('https://', 'http://', $c->BASE_URL);
2017-09-30 17:12:17 +00:00
}
2023-11-10 04:45:54 +00:00
$c->FORK_REVISION = 73;
2020-07-02 14:07:17 +00:00
$c->START = $forkStart;
$c->PUBLIC_URL = $c->BASE_URL . $forkPublicPrefix;
2020-06-27 06:51:20 +00:00
$controllers = ['Primary', 'Routing'];
2020-06-27 06:51:20 +00:00
foreach ($controllers as $controller) {
$page = $c->{$controller};
if ($page instanceof Page) {
break;
}
2017-02-14 13:05:26 +00:00
}
2017-11-03 13:06:22 +00:00
if (null !== $page->onlinePos) {
$c->Online->calc($page);
2017-02-14 13:05:26 +00:00
}
2017-04-03 09:42:29 +00:00
$tpl = $c->View->rendering($page);
if (
$c->isInit('DB')
&& $c->DB->inTransaction()
) {
$c->DB->commit();
}
2020-06-28 05:10:59 +00:00
if (
null !== $tpl
&& 3 & $c->DEBUG
2020-06-28 05:10:59 +00:00
) {
2023-03-09 16:41:17 +00:00
$debug = \rtrim($c->View->rendering($c->Debug->debug()));
2020-07-02 14:07:17 +00:00
$tpl = \str_replace('<!-- debuginfo -->', $debug, $tpl);
}
exit($tpl);