diff --git a/Skirogaining_2010/index.php b/Skirogaining_2010/index.php
index f3025fe..43689b8 100644
--- a/Skirogaining_2010/index.php
+++ b/Skirogaining_2010/index.php
@@ -2,27 +2,31 @@
session_start();
$included = true;
$lang = empty($_GET['lang']) ? 'cs' : $_GET['lang'];
-$page = htmlspecialchars($_GET['page']);
-$url = $_SERVER['REQUEST_URI'];
+if (!in_array($lang, ['cs', 'en', 'de'], true)) {
+ header('Location: /en/' . ($_GET['page'] ?? ''));
+ exit;
+}
+$page = htmlspecialchars($_GET['page'] ?? 'main');
+$url = $_SERVER['REQUEST_URI'] ?? '';
$root = '/Skirogaining_2010';
$pretitle = '1. Skirogaining 2010';
$mainMail = 'tojnar@gmail.com';
-include $lang . '.php';
+require $lang . '.php';
$CMS['%url%'] = 'http://skirogaining.tojnar.cz' . htmlspecialchars($url);
$CMS['%root%'] = $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;
return str_replace(array_keys($CMS), $CMS, $string);
}
-include __DIR__ . '/../sboard.php';
-include __DIR__ . '/../load.lib.php';
+require __DIR__ . '/../sboard.php';
+require __DIR__ . '/../load.lib.php';
readPage($page);
$CMS['%releasedate%'] = toDate($date);
$CMS['%releasetime%'] = toTime($date);
diff --git a/imagelightnessat.func.php b/imagelightnessat.func.php
index 59e70e3..402c600 100644
--- a/imagelightnessat.func.php
+++ b/imagelightnessat.func.php
@@ -11,7 +11,7 @@
* 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/index.php b/index.php
index aa7afa7..7c45d92 100644
--- a/index.php
+++ b/index.php
@@ -2,19 +2,23 @@
session_start();
$included = true;
$lang = empty($_GET['lang']) ? 'cs' : $_GET['lang'];
-$page = htmlspecialchars($_GET['page']);
-$url = $_SERVER['REQUEST_URI'];
+if (!in_array($lang, ['cs', 'de'], true)) {
+ header('Location: /cs/' . ($_GET['page'] ?? ''));
+ exit;
+}
+$page = htmlspecialchars($_GET['page'] ?? 'main');
+$url = $_SERVER['REQUEST_URI'] ?? '';
$root = '';
$pretitle = '2. Skirogaining 2012';
$mainMail = 'tojnar@gmail.com';
-include $lang . '.php';
+require $lang . '.php';
$CMS['%url%'] = 'http://skirogaining.tojnar.cz' . htmlspecialchars($url);
$CMS['%root%'] = $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';
if ($lang == 'cs') {
$CMS['%old%'] = '
1. Skirogaining 2010 3. Skirogaining 2012
';
@@ -28,8 +32,8 @@ function rplc($string) {
return str_replace(array_keys($CMS), $CMS, $string);
}
-include 'sboard.php';
-include 'load.lib.php';
+require __DIR__ . '/sboard.php';
+require __DIR__ . '/load.lib.php';
readPage($page);
$CMS['%releasedate%'] = toDate($date);
$CMS['%releasetime%'] = toTime($date);
@@ -72,4 +76,4 @@ ob_start(/*"ob_gzhandler"*/);
include 'template.html';
$buffer = ob_get_clean();
echo rplc(rplc($buffer));
-?>
\ No newline at end of file
+?>
diff --git a/load.lib.php b/load.lib.php
index 702b576..76c0716 100644
--- a/load.lib.php
+++ b/load.lib.php
@@ -1,9 +1,15 @@
]*)hs="([1-9][0-9]?)"([^>]*)>', '', $fileContent);
+ $fileContent = preg_replace('(]*)hs="([1-9][0-9]?)"([^>]*)>)', '', $fileContent);
$sbContent = rplc(sboard_generate($realPage));
$fileContent = str_replace('', $sbContent, $fileContent);
- ereg("(.*)<\/article>", $fileContent, $article); //article body
- $article = trim($article[1]);
+ if (preg_match('((.*))s', $fileContent, $article)) {
+ //article body
+ $article = trim($article[1]);
+ } else {
+ $article = '';
+ }
- ereg("(.*)<\/title>", $fileContent, $title); //article title
- $title = trim($title[1]);
+ if (preg_match('((.*))s', $fileContent, $title)) {
+ //article title
+ $title = trim($title[1]);
+ } else {
+ $title = '';
+ }
- ereg("(.*)<\/date>", $fileContent, $date); //article title
- $date = trim($date[1]);
+ if (preg_match('((.*))s', $fileContent, $date)) {
+ //article release time
+ $date = trim($date[1]);
+ } else {
+ $date = null;
+ }
- ereg("(.*)<\/author>", $fileContent, $author); //article title
- $author = trim($author[1]);
+ if (preg_match('((.*))s', $fileContent, $author)) {
+ //article author
+ $author = trim($author[1]);
+ } else {
+ $author = null;
+ }
$languages = ['cs', 'en', 'de'];
- ereg(']*)cs="([^"]*)"([^>]*)>', $fileContent, $cs); //article czech version link
- $aliases['cs'] = trim($cs[2]);
+ if (preg_match('(]*)cs="([^"]*)"([^>]*)>)', $fileContent, $cs)) {
+ //article czech version link
+ $aliases['cs'] = trim($cs[2]);
+ }
- ereg(']*)en="([^"]*)"([^>]*)>', $fileContent, $en); //article english version link
- $aliases['en'] = trim($en[2]);
+ if (preg_match('(]*)en="([^"]*)"([^>]*)>)', $fileContent, $en)) {
+ //article english version link
+ $aliases['en'] = trim($en[2]);
+ }
- ereg(']*)de="([^"]*)"([^>]*)>', $fileContent, $de); //article german version link
- $aliases['de'] = trim($de[2]);
+ if (preg_match('(]*)de="([^"]*)"([^>]*)>)', $fileContent, $de)) {
+ //article german version link
+ $aliases['de'] = trim($de[2]);
+ }
+
+ if (preg_match('(