Format code from krk-litvinov.cz

This commit is contained in:
2022-01-14 03:30:26 +01:00
parent ef87fd0ae6
commit 88e5499192
20 changed files with 1028 additions and 1012 deletions

View File

@@ -1,81 +1,84 @@
<?php
function stringEndsWith($string, $end) {
if(strLen($end)==0)
return false;
return (substr($string, -strLen($end))==$end);
if (strlen($end) == 0) {
return false;
}
return substr($string, -strlen($end)) == $end;
}
session_start();
$included=true;
$included = true;
$locale = 'cs';
$url=$_SERVER["REQUEST_URI"];
$root="/2015/";
$uri = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $root)+strlen($root));
if($uri==''){
header('Location: http://'.$_SERVER['HTTP_HOST'].$root.$locale.'/');
exit;
}elseif(preg_match('/^([a-z]{2})(?:\\/(.+)(\\?.*)?)?$/', $uri, $matches)){
$lang = htmlspecialchars(substr($matches[1], 0, 2));
if(stringEndsWith($matches[2], 'main')){
header('Location: http://'.$_SERVER['HTTP_HOST'].$root.$lang.'/'.substr($matches[2], 0, -4));
exit;
}
$_GET['page'] = $matches[2];
}elseif(preg_match('/^([a-z]{2})\\/(?:(.*)\\/)?$/', $uri, $matches)){
$lang = htmlspecialchars(substr($matches[1], 0, 2));
$_GET['page'] = (isset($matches[2])?$matches[2].'/':'').'main';
}else{
$_GET['error'] = 404;
$url = $_SERVER['REQUEST_URI'];
$root = '/2015/';
$uri = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $root) + strlen($root));
if ($uri == '') {
header('Location: http://' . $_SERVER['HTTP_HOST'] . $root . $locale . '/');
exit;
} elseif (preg_match('/^([a-z]{2})(?:\\/(.+)(\\?.*)?)?$/', $uri, $matches)) {
$lang = htmlspecialchars(substr($matches[1], 0, 2));
if (stringEndsWith($matches[2], 'main')) {
header('Location: http://' . $_SERVER['HTTP_HOST'] . $root . $lang . '/' . substr($matches[2], 0, -4));
exit;
}
$_GET['page'] = $matches[2];
} elseif (preg_match('/^([a-z]{2})\\/(?:(.*)\\/)?$/', $uri, $matches)) {
$lang = htmlspecialchars(substr($matches[1], 0, 2));
$_GET['page'] = (isset($matches[2]) ? $matches[2] . '/' : '') . 'main';
} else {
$_GET['error'] = 404;
}
$page=htmlspecialchars($_GET["page"]);
$pretitle="5. přeshraniční skirogaining";
$mainMail="tojnar@gmail.com";
include($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["%dateFormat%"]="d.m.Y H:i";
function rplc($string){
global $CMS;
return str_replace(array_keys($CMS),$CMS,$string);
$page = htmlspecialchars($_GET['page']);
$pretitle = '5. přeshraniční skirogaining';
$mainMail = 'tojnar@gmail.com';
include $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['%dateFormat%'] = 'd.m.Y H:i';
function rplc($string) {
global $CMS;
return str_replace(array_keys($CMS), $CMS, $string);
}
require __DIR__ . '/../sboard.php';
require __DIR__ . '/../load.lib.php';
readPage($page);
$CMS["%releasedate%"]=toDate($date);
$CMS["%releasetime%"]=toTime($date);
if(isReleased($date)==false){
$notreleased=true;
}else{
$notreleased=false;
$CMS['%releasedate%'] = toDate($date);
$CMS['%releasetime%'] = toTime($date);
if (isReleased($date) == false) {
$notreleased = true;
} else {
$notreleased = false;
}
if($notreleased==true){
readPage("error/notreleased");
if ($notreleased == true) {
readPage('error/notreleased');
}
$CMS["%title%"]=$title;
$CMS["%titleTag%"]=str_replace(array("%pretitle%","%title%"),array($pretitle,$title),rplc("%longTitle%"));
$CMS["%langPanel%"]=$langPanel;
$CMS["%article%"]=$article;
$CMS["%menu%"]=$menu;
if(!empty($author) AND !empty($date)){
$aInfo=str_replace(array("%author%","%date%","%time%"),array(author($author),toDate($date),toTime($date)),rplc("%by%"));
}elseif(!empty($author)){
$aInfo=str_replace("%author%",author($author),rplc("%byAuthor%"));
}elseif(!empty($date)){
$aInfo=str_replace(array("%date%","%time%"),array(toDate($date),toTime($date)),rplc("%byDate%"));
}else{
$aInfo="";
$CMS['%title%'] = $title;
$CMS['%titleTag%'] = str_replace(['%pretitle%', '%title%'], [$pretitle, $title], rplc('%longTitle%'));
$CMS['%langPanel%'] = $langPanel;
$CMS['%article%'] = $article;
$CMS['%menu%'] = $menu;
if (!empty($author) and !empty($date)) {
$aInfo = str_replace(['%author%', '%date%', '%time%'], [author($author), toDate($date), toTime($date)], rplc('%by%'));
} elseif (!empty($author)) {
$aInfo = str_replace('%author%', author($author), rplc('%byAuthor%'));
} elseif (!empty($date)) {
$aInfo = str_replace(['%date%', '%time%'], [toDate($date), toTime($date)], rplc('%byDate%'));
} else {
$aInfo = '';
}
//var_dump(date(rplc("%dateFormat%"),filemtime($realPage)));
$CMS["%author%"]=$author;
$CMS["%ainfo%"]=$aInfo;
$CMS['%author%'] = $author;
$CMS['%ainfo%'] = $aInfo;
?>
<?php
ob_start(/*"ob_gzhandler"*/);
include("template.html");
$buffer=ob_get_clean();
echo(rplc(rplc($buffer)));
include 'template.html';
$buffer = ob_get_clean();
echo rplc(rplc($buffer));
?>