0
1
Fork 0
hedera-web-mindshore/package/usr/share/hedera-web/index.php

86 lines
1.6 KiB
PHP
Raw Normal View History

<?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;
2015-02-17 11:48:53 +00:00
try {
Web::init ();
}
catch (Exception $e)
{
2015-02-17 11:48:53 +00:00
header ('Location: unavailable.html');
exit (0);
}
2015-02-17 11:48:53 +00:00
if (!isset ($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')
if (Web::$sysConn->getValue ('SELECT https FROM config'))
{
2015-02-17 11:48:53 +00:00
header ("Location: https://${_SERVER['SERVER_NAME']}${_SERVER['REQUEST_URI']}");
exit (0);
}
2015-01-31 01:05:12 +00:00
// 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;
}
2015-02-17 11:48:53 +00:00
// Setting the version
setcookie ('hedera_version', $_SESSION['version']);
2015-01-31 01:05:12 +00:00
// 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');
}
Web::deinit ();
?>