diff --git a/lob2011/imagelightnessat.func.php b/lob2011/imagelightnessat.func.php
index 8e9ef25..9192249 100644
--- a/lob2011/imagelightnessat.func.php
+++ b/lob2011/imagelightnessat.func.php
@@ -13,7 +13,7 @@ declare(strict_types=1);
* by Jed Smith ", $u, $u, $d) ?>
*/
function imagelightnessat($img, $x, $y) {
- if (!is_resource($img)) {
+ if (!$img instanceof \GdImage && !is_resource($img)) {
trigger_error('imagelightnessat(): supplied argument is not a valid '
. 'Image resource', \E_USER_WARNING);
diff --git a/lob2011/index.php b/lob2011/index.php
index 2ae0600..162f5e9 100644
--- a/lob2011/index.php
+++ b/lob2011/index.php
@@ -2,7 +2,7 @@
session_start();
$included = true;
$lang = empty($_GET['lang']) ? 'cs' : $_GET['lang'];
-$page = htmlspecialchars($_GET['page']);
+$page = htmlspecialchars($_GET['page'] ?? 'main');
$url = $_SERVER['REQUEST_URI'];
$root = '/krk/lob2011';
$pretitle = 'LOB 2011';
@@ -16,7 +16,7 @@ $CMS['%headerLinkHref%'] = rplc('%root%/') . $lang;
$CMS['%pretitle%'] = $pretitle;
$CMS['%comefrom%'] = $_SERVER['HTTP_REFERER'];
$CMS['%dateFormat%'] = 'd.m.Y H:i';
-function rplc($string) {
+function rplc(string $string): string {
global $CMS;
return str_replace(array_keys($CMS), $CMS, $string);
diff --git a/lob2011/load.lib.php b/lob2011/load.lib.php
index 0cc07b4..8c7a617 100644
--- a/lob2011/load.lib.php
+++ b/lob2011/load.lib.php
@@ -2,195 +2,228 @@
declare(strict_types=1);
-if ($included == true) {
- // boolean readPage(string $page)
- function readPage($page) {//main function
- global $lang,$realPageType,$menuUrl,$article,$title,$author,$date,$time,$menu,$mainMail,$langPanel,$notreleased, $eu;
- if (empty($page)) {//page specification
- $realPage = 'pages/' . $lang . '/main.pg';
+function isHttps(): bool {
+ // https://www.designcise.com/web/tutorial/how-to-check-for-https-request-in-php
+ $isHttps = $_SERVER['HTTPS'] ?? $_SERVER['REQUEST_SCHEME'] ?? $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? null;
+
+ return $isHttps && (strcasecmp('on', $isHttps) === 0 || strcasecmp('https', $isHttps) === 0);
+}
+
+function readPage(string $page): bool {
+ //main function
+ $aliases = [];
+ global $lang,$realPageType,$menuUrl,$article,$title,$author,$date,$time,$menu,$mainMail,$langPanel,$notreleased, $eu;
+ if (empty($page)) {//page specification
+ $realPage = 'pages/' . $lang . '/main.pg';
+ } else {
+ if (file_exists('pages/' . $lang . '/' . $page . '.pg')) {
+ $realPage = 'pages/' . $lang . '/' . $page . '.pg';
} else {
- if (file_exists('pages/' . $lang . '/' . $page . '.pg')) {
- $realPage = 'pages/' . $lang . '/' . $page . '.pg';
- } else {
- $realPage = 'pages/' . $lang . '/error/404.pg';
- $log404 = fopen('404.log', 'a+');
- if (!ereg($page . "\n", file_get_contents('404.log'))) {
- fwrite($log404, $page . "\n");
- mail($mainMail, "Stranka nenalezena http://tojnar.cz/krk/lob2011/$page", rplc('Prichozi z: %comefrom%'));
- }
- fclose($log404);
+ $realPage = 'pages/' . $lang . '/error/404.pg';
+ $log404 = fopen('404.log', 'a+');
+ if (!preg_match('(' . preg_quote($page) . '\n)', file_get_contents('404.log'))) {
+ fwrite($log404, $page . "\n");
+ mail($mainMail, "Stranka nenalezena http://www.tojnar.cz/krk/lob2011/$page", rplc('Prichozi z: %comefrom%'));
}
+ fclose($log404);
}
- //end of page specification
- $errPageStart = 'pages/' . $lang . '/error/';
- if (substr($realPage, 0, strlen($errPageStart)) == $errPageStart) {//page type setting
- $realPageType = 2;
- } elseif ($realPage == 'pages/' . $lang . '/main.pg') {
- $realPageType = 1;
- } else {
- $realPageType = 0;
- }
- //end of page type setting
+ }
+ //end of page specification
+ $errPageStart = 'pages/' . $lang . '/error/';
+ if (substr($realPage, 0, strlen($errPageStart)) == $errPageStart) {//page type setting
+ $realPageType = 2;
+ } elseif ($realPage == 'pages/' . $lang . '/main.pg') {
+ $realPageType = 1;
+ } else {
+ $realPageType = 0;
+ }
+ //end of page type setting
- $fileContent = rplc(file_get_contents($realPage));
- //echo($fileContent);
- $fileContent = preg_replace('/]*)hs="([1-9][0-9]?)"([^>]*)>/D', '', $fileContent);
- $sbContent = rplc(sboard_generate($realPage));
- $fileContent = str_replace('', $sbContent, $fileContent);
+ $fileContent = rplc(file_get_contents($realPage));
+ //echo($fileContent);
+ $fileContent = preg_replace('(]*)hs="([1-9][0-9]?)"([^>]*)>)', '', $fileContent);
+ $sbContent = rplc(sboard_generate($realPage));
+ $fileContent = str_replace('', $sbContent, $fileContent);
- preg_match("#(.*)<\/article>#D", $fileContent, $article); //article body
+ if (preg_match('((.*))s', $fileContent, $article)) {
+ //article body
$article = trim($article[1]);
+ } else {
+ $article = '';
+ }
- preg_match("#(.*)<\/title>#D", $fileContent, $title); //article title
+ if (preg_match('((.*))s', $fileContent, $title)) {
+ //article title
$title = trim($title[1]);
+ } else {
+ $title = '';
+ }
- preg_match("#(.*)<\/date>#D", $fileContent, $date); //article title
+ if (preg_match('((.*))s', $fileContent, $date)) {
+ //article release time
$date = trim($date[1]);
+ } else {
+ $date = null;
+ }
- preg_match("#(.*)<\/author>#D", $fileContent, $author); //article title
+ if (preg_match('((.*))s', $fileContent, $author)) {
+ //article author
$author = trim($author[1]);
+ } else {
+ $author = null;
+ }
- $languages = ['cs', 'en', 'de'];
+ $languages = ['cs', 'en', 'de'];
- preg_match('/]*)cs(e?)="([^"]*)"([^>]*)>/D', $fileContent, $cs); //article czech version link
+ if (preg_match('(]*)cs(e?)="([^"]*)"([^>]*)>)', $fileContent, $cs)) {
+ //article czech version link
$aliases['cs'] = ($cs[2] == 'e' ? '*' : '') . trim($cs[3]);
+ }
- preg_match('/]*)en(e?)="([^"]*)"([^>]*)>/D', $fileContent, $en); //article english version link
+ if (preg_match('(]*)en(e?)="([^"]*)"([^>]*)>)', $fileContent, $en)) {
+ //article english version link
$aliases['en'] = ($en[2] == 'e' ? '*' : '') . trim($en[3]);
+ }
- preg_match('/]*)de(e?)="([^"]*)"([^>]*)>/D', $fileContent, $de); //article german version link
+ if (preg_match('(]*)de(e?)="([^"]*)"([^>]*)>)', $fileContent, $de)) {
+ //article german version link
$aliases['de'] = ($de[2] == 'e' ? '*' : '') . trim($de[3]);
+ }
- preg_match('/