2017-01-06 13:51:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
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;
|
2017-01-06 13:51:12 +00:00
|
|
|
|
2018-08-21 14:12:17 +00:00
|
|
|
\error_reporting(\E_ALL ^ \E_NOTICE);
|
|
|
|
\ini_set('display_errors', 0);
|
2018-03-10 14:24:39 +00:00
|
|
|
\ini_set('log_errors', 1);
|
2017-01-06 13:51:12 +00:00
|
|
|
|
2018-03-10 14:24:39 +00:00
|
|
|
\mb_language('uni');
|
|
|
|
\mb_internal_encoding('UTF-8');
|
|
|
|
\mb_substitute_character(0xFFFD);
|
2017-01-06 13:51:12 +00:00
|
|
|
|
2017-03-02 08:45:43 +00:00
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
2017-01-06 13:51:12 +00:00
|
|
|
|
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');
|
2017-01-06 13:51:12 +00:00
|
|
|
} else {
|
2017-11-26 11:56:54 +00:00
|
|
|
throw new RuntimeException('Application is not configured');
|
2017-01-06 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2017-03-13 16:14:57 +00:00
|
|
|
require __DIR__ . '/functions.php';
|
2017-12-14 12:16:09 +00:00
|
|
|
\ForkBB\_init($c);
|
2017-01-06 13:51:12 +00:00
|
|
|
|
2017-09-30 17:12:17 +00:00
|
|
|
// https or http?
|
2020-06-27 06:51:20 +00:00
|
|
|
if (! empty($_SERVER['HTTPS']) && \strtolower($_SERVER['HTTPS']) !== 'off') {
|
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
|
|
|
}
|
|
|
|
$c->PUBLIC_URL = $c->BASE_URL . $forkPublicPrefix;
|
|
|
|
|
2017-03-13 16:14:57 +00:00
|
|
|
$c->FORK_REVISION = 1;
|
|
|
|
$c->START = $forkStart;
|
|
|
|
$c->DIR_APP = __DIR__;
|
|
|
|
$c->DIR_PUBLIC = $forkPublic;
|
|
|
|
$c->DIR_CONFIG = __DIR__ . '/config';
|
|
|
|
$c->DIR_CACHE = __DIR__ . '/cache';
|
|
|
|
$c->DIR_VIEWS = __DIR__ . '/templates';
|
|
|
|
$c->DIR_LANG = __DIR__ . '/lang';
|
2017-11-03 13:06:22 +00:00
|
|
|
$c->DATE_FORMATS = [$c->config->o_date_format, 'Y-m-d', 'Y-d-m', 'd-m-Y', 'm-d-Y', 'M j Y', 'jS M Y'];
|
|
|
|
$c->TIME_FORMATS = [$c->config->o_time_format, 'H:i:s', 'H:i', 'g:i:s a', 'g:i a'];
|
2017-02-14 13:05:26 +00:00
|
|
|
|
2020-06-27 06:51:20 +00:00
|
|
|
$controllers = ['Primary', 'Routing'];
|
|
|
|
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
|
|
|
}
|
2018-10-23 14:41:36 +00:00
|
|
|
|
2017-04-03 09:42:29 +00:00
|
|
|
$tpl = $c->View->rendering($page);
|
2018-10-23 14:41:36 +00:00
|
|
|
|
|
|
|
if ($c->isInit('DB')) {
|
|
|
|
$c->DB->commit();
|
|
|
|
}
|
|
|
|
|
2017-11-26 11:56:54 +00:00
|
|
|
if (null !== $tpl && $c->DEBUG > 0) {
|
2017-11-03 13:06:22 +00:00
|
|
|
$debug = $c->View->rendering($c->Debug->debug());
|
2018-03-10 14:24:39 +00:00
|
|
|
$tpl = \str_replace('<!-- debuginfo -->', $debug, $tpl);
|
2017-03-02 08:45:43 +00:00
|
|
|
}
|
2018-10-23 14:41:36 +00:00
|
|
|
|
2017-03-02 08:45:43 +00:00
|
|
|
exit($tpl);
|