117 lines
2.2 KiB
PHP
Executable File
117 lines
2.2 KiB
PHP
Executable File
<?php
|
|
|
|
require_once ('vn/hedera/web.php');
|
|
require_once ('vn/hedera/js.php');
|
|
require_once ('vn/hedera/util.php');
|
|
|
|
use Vn\Hedera\Web;
|
|
use Vn\Lib\Locale;
|
|
|
|
ini_set ('log_errors', TRUE);
|
|
ini_set ('error_log', Vn\Hedera\_LOG_DIR .'/hedera-web.log');
|
|
|
|
function myExitHandler ()
|
|
{
|
|
Web::deinit ();
|
|
}
|
|
|
|
function myGlobalErrorHandler ()
|
|
{
|
|
header ('Location: unavailable.html');
|
|
myExitHandler ();
|
|
exit (0);
|
|
}
|
|
|
|
function myErrorHandler ($errno, $message, $file, $line, $context)
|
|
{
|
|
error_log ("$file:$line: $message");
|
|
|
|
switch ($errno)
|
|
{
|
|
case E_USER_ERROR:
|
|
myGlobalErrorHandler ();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
function myExceptionHandler ($e)
|
|
{
|
|
error_log ($e->getFile () .':'. $e->getLine () .': '. $e->getMessage ());
|
|
myGlobalErrorHandler ();
|
|
}
|
|
|
|
set_error_handler ('myErrorHandler', E_ALL);
|
|
set_exception_handler ('myExceptionHandler');
|
|
|
|
Web::sysInit ();
|
|
|
|
if (!Web::isHttps () && Web::$sysConn->getValue ('SELECT https FROM config'))
|
|
{
|
|
header ("Location: https://${_SERVER['SERVER_NAME']}${_SERVER['REQUEST_URI']}");
|
|
exit (0);
|
|
}
|
|
|
|
Web::init ();
|
|
|
|
// Getting the requested page
|
|
|
|
if (isset ($_GET['page']) && Vn\Hedera\checkToken ($_GET['page']))
|
|
$page = $_GET['page'];
|
|
else
|
|
$page = 'login';
|
|
|
|
// Checking the browser version
|
|
|
|
if (!isset ($_SESSION['skipBrowser']) && $page != 'update-browser')
|
|
{
|
|
$updateBrowser = FALSE;
|
|
|
|
if (!isset ($_GET['skipBrowser'])
|
|
&& ($browser = get_browser ($_SERVER['HTTP_USER_AGENT'])))
|
|
{
|
|
$browserVersion = $browser->version;
|
|
set_type ($browserVersion, TYPE_DOUBLE);
|
|
|
|
$minVersion = Web::$sysConn->getValue (
|
|
'SELECT version FROM browser WHERE name = #', [$browser->browser]);
|
|
|
|
$updateBrowser = $browserVersion > 0
|
|
&& isset ($minVersion) && $browserVersion < $minVersion;
|
|
}
|
|
|
|
if ($updateBrowser)
|
|
{
|
|
header ('Location: ?page=update-browser');
|
|
exit (0);
|
|
}
|
|
else
|
|
$_SESSION['skipBrowser'] = TRUE;
|
|
}
|
|
|
|
// Setting the version
|
|
|
|
setcookie ('hedera_version', Web::getVersion ());
|
|
|
|
// Loading the requested page
|
|
|
|
$basePath = 'pages/'. $page;
|
|
|
|
header ('Content-Type: text/html; charset=utf-8');
|
|
|
|
if (file_exists ($basePath))
|
|
{
|
|
Locale::addPath ($basePath);
|
|
|
|
$phpFile = $basePath .'/'. $page .'.php';
|
|
|
|
if (file_exists ($phpFile))
|
|
require ($phpFile);
|
|
|
|
require ($basePath .'/html.php');
|
|
}
|
|
|
|
myExitHandler ();
|
|
|
|
?>
|