Modernize code from krk-litvinov.cz
This commit is contained in:
@@ -8,12 +8,12 @@ function stringEndsWith($string, $end) {
|
||||
}
|
||||
session_start();
|
||||
$included = true;
|
||||
$locale = 'cs';
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
$lang = 'cs';
|
||||
$url = $_SERVER['REQUEST_URI'] ?? '';
|
||||
$root = '/2015/';
|
||||
$uri = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $root) + strlen($root));
|
||||
$uri = substr($url, strpos($url, $root) + strlen($root));
|
||||
if ($uri == '') {
|
||||
header('Location: http://' . $_SERVER['HTTP_HOST'] . $root . $locale . '/');
|
||||
header('Location: http://' . $_SERVER['HTTP_HOST'] . $root . $lang . '/');
|
||||
exit;
|
||||
} elseif (preg_match('/^([a-z]{2})(?:\\/(.+)(\\?.*)?)?$/', $uri, $matches)) {
|
||||
$lang = htmlspecialchars(substr($matches[1], 0, 2));
|
||||
@@ -26,19 +26,23 @@ if ($uri == '') {
|
||||
$lang = htmlspecialchars(substr($matches[1], 0, 2));
|
||||
$_GET['page'] = (isset($matches[2]) ? $matches[2] . '/' : '') . 'main';
|
||||
} else {
|
||||
$_GET['error'] = 404;
|
||||
$_GET['page'] = 'error/404';
|
||||
}
|
||||
if (!in_array($lang, ['cs', 'de', 'en'], true)) {
|
||||
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/en/' . ($_GET['page'] ?? ''));
|
||||
exit;
|
||||
}
|
||||
$page = htmlspecialchars($_GET['page']);
|
||||
$pretitle = '5. přeshraniční skirogaining';
|
||||
$mainMail = 'tojnar@gmail.com';
|
||||
include $lang . '.php';
|
||||
require $lang . '.php';
|
||||
$CMS['%url%'] = 'http://' . $_SERVER['HTTP_HOST'] . htmlspecialchars($url);
|
||||
$CMS['%root%'] = rtrim($root, '/');
|
||||
$CMS['%lang%'] = $lang;
|
||||
$CMS['%unknownAuthor%'] = 'Jan Tojnar';
|
||||
$CMS['%headerLinkHref%'] = rplc('%root%/') . $lang;
|
||||
$CMS['%pretitle%'] = $pretitle;
|
||||
$CMS['%comefrom%'] = $_SERVER['HTTP_REFERER'];
|
||||
$CMS['%comefrom%'] = $_SERVER['HTTP_REFERER'] ?? 'n/a';
|
||||
$CMS['%dateFormat%'] = 'd.m.Y H:i';
|
||||
function rplc($string) {
|
||||
global $CMS;
|
||||
|
||||
Reference in New Issue
Block a user