Modernize code from krk-litvinov.cz

This commit is contained in:
2022-01-14 03:59:38 +01:00
parent 88e5499192
commit 0ab7835c3b
4 changed files with 44 additions and 28 deletions

View File

@@ -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 = '/2012-prosinec/';
$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'], true)) {
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/cs/' . ($_GET['page'] ?? ''));
exit;
}
$page = htmlspecialchars($_GET['page']);
$pretitle = '3. Česko-německý 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;

View File

@@ -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 = '/2014/';
$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', 'en'], true)) {
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/en/' . ($_GET['page'] ?? ''));
exit;
}
$page = htmlspecialchars($_GET['page']);
$pretitle = '4. 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;

View File

@@ -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-prosinec/';
$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', 'en'], true)) {
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/en/' . ($_GET['page'] ?? ''));
exit;
}
$page = htmlspecialchars($_GET['page']);
$pretitle = '6. 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;

View File

@@ -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;