From 9a3656ef281dfcd48aa78c8a72478a8c7cef6c77 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 13 Jan 2022 23:09:36 +0100 Subject: [PATCH] Format PHP code --- 3DCaptcha.php | 60 ++- Skirogaining_2010/3DCaptcha.php | 60 ++- Skirogaining_2010/cs.php | 108 ++--- Skirogaining_2010/de.php | 108 ++--- Skirogaining_2010/en.php | 108 ++--- Skirogaining_2010/imagelightnessat.func.php | 33 +- Skirogaining_2010/index.php | 109 ++--- .../linear_perspective.class.php | 35 +- Skirogaining_2010/load.lib.php | 390 +++++++++--------- Skirogaining_2010/sboard.php | 211 +++++----- Skirogaining_2010/sitemap.php | 57 +-- cs.php | 108 ++--- de.php | 108 ++--- en.php | 108 ++--- imagelightnessat.func.php | 33 +- index.php | 119 +++--- linear_perspective.class.php | 35 +- load.lib.php | 390 +++++++++--------- sboard.php | 211 +++++----- sitemap.php | 57 +-- 20 files changed, 1229 insertions(+), 1219 deletions(-) diff --git a/3DCaptcha.php b/3DCaptcha.php index 90a9b55..5446ebb 100644 --- a/3DCaptcha.php +++ b/3DCaptcha.php @@ -1,59 +1,57 @@ 80, 'y' => 30]; +$captcha_dim = ['x' => 300, 'y' => 90]; +$distance = ['x' => 1, 'y' => 1, 'z' => 1]; +$metric = ['x' => 10, 'y' => 20, 'z' => 5]; +$offset = ['x' => 0, 'y' => -60]; -# konfigurace rozměrů a pozic -$matrix_dim = array('x' => 80, 'y' => 30); -$captcha_dim = array('x' => 300, 'y' => 90); -$distance = array('x' => 1, 'y' => 1, 'z' => 1); -$metric = array('x' => 10, 'y' => 20, 'z' => 5); -$offset = array('x' => 0, 'y' => -60); - -# matrice +// matrice $matrix = imagecreatetruecolor($matrix_dim['x'], $matrix_dim['y']); $black = imagecolorexact($matrix, 0, 0, 0); $white = imagecolorexact($matrix, 255, 255, 255); imagefill($matrix, 0, 0, $white); -# font calibri neni kvůli licenčním podmínkám připojen, použijte jakýkoliv svůj -imagefttext($matrix, 20, 0, 2, 25, $black, './3DCaptcha.ttf', $_SESSION["captcha"]); +// font calibri neni kvůli licenčním podmínkám připojen, použijte jakýkoliv svůj +imagefttext($matrix, 20, 0, 2, 25, $black, './3DCaptcha.ttf', $_SESSION['captcha']); -# výpočet bodů ve 3d -$point = array(); -for ($x = 0; $x < $matrix_dim['x']; $x++) { - for ($y = 0; $y < $matrix_dim['y']; $y++) { - $lightness = imagelightnessat($matrix, $x, $y); - $point[$x][$y] = $perspective->get_projection(array('x' => $x * $metric['x'] + $distance['x'], 'y' => $lightness * $metric['y'] + $distance['y'], 'z' => ($matrix_dim['y'] - $y) * $metric['z'] + $distance['z'])); - } +// výpočet bodů ve 3d +$point = []; +for ($x = 0; $x < $matrix_dim['x']; ++$x) { + for ($y = 0; $y < $matrix_dim['y']; ++$y) { + $lightness = imagelightnessat($matrix, $x, $y); + $point[$x][$y] = $perspective->get_projection(['x' => $x * $metric['x'] + $distance['x'], 'y' => $lightness * $metric['y'] + $distance['y'], 'z' => ($matrix_dim['y'] - $y) * $metric['z'] + $distance['z']]); + } } imagedestroy($matrix); - -# obrázek captcha +// obrázek captcha $captcha = imagecreatetruecolor($captcha_dim['x'], $captcha_dim['y']); -# antialiasing čar - pro menší zátěž lze vypnout +// antialiasing čar - pro menší zátěž lze vypnout //imageantialias($captcha, true); $black = imagecolorexact($captcha, 255, 0, 0); $white = imagecolorexact($captcha, 255, 255, 255); imagefill($captcha, 0, 0, $white); -# vykreslení vrstevnic -for ($x = 1; $x < $matrix_dim['x']; $x++) { - for ($y = 1; $y < $matrix_dim['y']; $y++) { - imageline($captcha, -$point[$x - 1][$y - 1]['x'] + $offset['x'], -$point[$x - 1][$y - 1]['y'] + $offset['y'], -$point[$x][$y]['x'] + $offset['x'], -$point[$x][$y]['y'] + $offset['y'], $black); - } +// vykreslení vrstevnic +for ($x = 1; $x < $matrix_dim['x']; ++$x) { + for ($y = 1; $y < $matrix_dim['y']; ++$y) { + imageline($captcha, -$point[$x - 1][$y - 1]['x'] + $offset['x'], -$point[$x - 1][$y - 1]['y'] + $offset['y'], -$point[$x][$y]['x'] + $offset['x'], -$point[$x][$y]['y'] + $offset['y'], $black); + } } -# výstup +// výstup header('Content-type: image/png'); imagepng($captcha); -?> diff --git a/Skirogaining_2010/3DCaptcha.php b/Skirogaining_2010/3DCaptcha.php index 90a9b55..5446ebb 100644 --- a/Skirogaining_2010/3DCaptcha.php +++ b/Skirogaining_2010/3DCaptcha.php @@ -1,59 +1,57 @@ 80, 'y' => 30]; +$captcha_dim = ['x' => 300, 'y' => 90]; +$distance = ['x' => 1, 'y' => 1, 'z' => 1]; +$metric = ['x' => 10, 'y' => 20, 'z' => 5]; +$offset = ['x' => 0, 'y' => -60]; -# konfigurace rozměrů a pozic -$matrix_dim = array('x' => 80, 'y' => 30); -$captcha_dim = array('x' => 300, 'y' => 90); -$distance = array('x' => 1, 'y' => 1, 'z' => 1); -$metric = array('x' => 10, 'y' => 20, 'z' => 5); -$offset = array('x' => 0, 'y' => -60); - -# matrice +// matrice $matrix = imagecreatetruecolor($matrix_dim['x'], $matrix_dim['y']); $black = imagecolorexact($matrix, 0, 0, 0); $white = imagecolorexact($matrix, 255, 255, 255); imagefill($matrix, 0, 0, $white); -# font calibri neni kvůli licenčním podmínkám připojen, použijte jakýkoliv svůj -imagefttext($matrix, 20, 0, 2, 25, $black, './3DCaptcha.ttf', $_SESSION["captcha"]); +// font calibri neni kvůli licenčním podmínkám připojen, použijte jakýkoliv svůj +imagefttext($matrix, 20, 0, 2, 25, $black, './3DCaptcha.ttf', $_SESSION['captcha']); -# výpočet bodů ve 3d -$point = array(); -for ($x = 0; $x < $matrix_dim['x']; $x++) { - for ($y = 0; $y < $matrix_dim['y']; $y++) { - $lightness = imagelightnessat($matrix, $x, $y); - $point[$x][$y] = $perspective->get_projection(array('x' => $x * $metric['x'] + $distance['x'], 'y' => $lightness * $metric['y'] + $distance['y'], 'z' => ($matrix_dim['y'] - $y) * $metric['z'] + $distance['z'])); - } +// výpočet bodů ve 3d +$point = []; +for ($x = 0; $x < $matrix_dim['x']; ++$x) { + for ($y = 0; $y < $matrix_dim['y']; ++$y) { + $lightness = imagelightnessat($matrix, $x, $y); + $point[$x][$y] = $perspective->get_projection(['x' => $x * $metric['x'] + $distance['x'], 'y' => $lightness * $metric['y'] + $distance['y'], 'z' => ($matrix_dim['y'] - $y) * $metric['z'] + $distance['z']]); + } } imagedestroy($matrix); - -# obrázek captcha +// obrázek captcha $captcha = imagecreatetruecolor($captcha_dim['x'], $captcha_dim['y']); -# antialiasing čar - pro menší zátěž lze vypnout +// antialiasing čar - pro menší zátěž lze vypnout //imageantialias($captcha, true); $black = imagecolorexact($captcha, 255, 0, 0); $white = imagecolorexact($captcha, 255, 255, 255); imagefill($captcha, 0, 0, $white); -# vykreslení vrstevnic -for ($x = 1; $x < $matrix_dim['x']; $x++) { - for ($y = 1; $y < $matrix_dim['y']; $y++) { - imageline($captcha, -$point[$x - 1][$y - 1]['x'] + $offset['x'], -$point[$x - 1][$y - 1]['y'] + $offset['y'], -$point[$x][$y]['x'] + $offset['x'], -$point[$x][$y]['y'] + $offset['y'], $black); - } +// vykreslení vrstevnic +for ($x = 1; $x < $matrix_dim['x']; ++$x) { + for ($y = 1; $y < $matrix_dim['y']; ++$y) { + imageline($captcha, -$point[$x - 1][$y - 1]['x'] + $offset['x'], -$point[$x - 1][$y - 1]['y'] + $offset['y'], -$point[$x][$y]['x'] + $offset['x'], -$point[$x][$y]['y'] + $offset['y'], $black); + } } -# výstup +// výstup header('Content-type: image/png'); imagepng($captcha); -?> diff --git a/Skirogaining_2010/cs.php b/Skirogaining_2010/cs.php index cf8e5e0..a62f2c4 100644 --- a/Skirogaining_2010/cs.php +++ b/Skirogaining_2010/cs.php @@ -1,52 +1,53 @@ URL"; -$CMS["%sbhelp%"]=<<Nápověda
HTML
není podporováno
@@ -59,10 +60,9 @@ $CMS["%sbhelp%"]=<<[yellow]žluté písmo[/yellow]
žluté písmo
EOT; -$CMS["%searchform%"]="006883172923970328180:3wantrdnnzy"; -$CMS["%eustring%"]="Tento projekt byl podpořen z Evropského fondu pro regionální rozvoj, fondu malých projektů Programu Cíl 3 na podporu přeshraniční spolupráce mezi Českou republikou a Svobodným státem Sasko 2007-2013."; -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); + $CMS['%searchform%'] = '006883172923970328180:3wantrdnnzy'; + $CMS['%eustring%'] = 'Tento projekt byl podpořen z Evropského fondu pro regionální rozvoj, fondu malých projektů Programu Cíl 3 na podporu přeshraniční spolupráce mezi Českou republikou a Svobodným státem Sasko 2007-2013.'; +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -?> \ No newline at end of file diff --git a/Skirogaining_2010/de.php b/Skirogaining_2010/de.php index cb62a63..0d15124 100644 --- a/Skirogaining_2010/de.php +++ b/Skirogaining_2010/de.php @@ -1,52 +1,53 @@ URL"; -$CMS["%sbhelp%"]=<<Help
HTML
not supported
@@ -59,10 +60,9 @@ $CMS["%sbhelp%"]=<<[yellow]yellow text[/yellow]
yellow text
EOT; -$CMS["%searchform%"]="006883172923970328180:bfehocs55i8"; -$CMS["%eustring%"]="Das Projekt wurde von dem Europäischen Fonds für Regionalentwicklung (KPF, Ziel 3 - Programm zur Förderung der grenzübergreifenden Zusammenarbeit zwischen dem Freistaat Sachsen und der Tschechischen Republik 2007-2013) unterstützt."; -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); + $CMS['%searchform%'] = '006883172923970328180:bfehocs55i8'; + $CMS['%eustring%'] = 'Das Projekt wurde von dem Europäischen Fonds für Regionalentwicklung (KPF, Ziel 3 - Programm zur Förderung der grenzübergreifenden Zusammenarbeit zwischen dem Freistaat Sachsen und der Tschechischen Republik 2007-2013) unterstützt.'; +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -?> \ No newline at end of file diff --git a/Skirogaining_2010/en.php b/Skirogaining_2010/en.php index c60cca3..075e855 100644 --- a/Skirogaining_2010/en.php +++ b/Skirogaining_2010/en.php @@ -1,52 +1,53 @@ URL"; -$CMS["%sbhelp%"]=<<Help
HTML
not supported
@@ -59,10 +60,9 @@ $CMS["%sbhelp%"]=<<[yellow]yellow text[/yellow]
yellow text
EOT; -$CMS["%searchform%"]="006883172923970328180:bfehocs55i8"; -$CMS["%eustring%"]="The project was supported from European fund of regional development, Common fund of small projects, Programme \"Cil 3\" supporting collaboration of the Czech Republic and Free State Saxony 2007-2013."; -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); + $CMS['%searchform%'] = '006883172923970328180:bfehocs55i8'; + $CMS['%eustring%'] = 'The project was supported from European fund of regional development, Common fund of small projects, Programme "Cil 3" supporting collaboration of the Czech Republic and Free State Saxony 2007-2013.'; +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -?> \ No newline at end of file diff --git a/Skirogaining_2010/imagelightnessat.func.php b/Skirogaining_2010/imagelightnessat.func.php index a99225c..59e70e3 100644 --- a/Skirogaining_2010/imagelightnessat.func.php +++ b/Skirogaining_2010/imagelightnessat.func.php @@ -9,30 +9,28 @@ * x, y The coordinates of the pixel to work on * * by Jed Smith ", $u, $u, $d) ?> - */ -function imagelightnessat($img, $x, $y) -{ - if(!is_resource($img)) - { - trigger_error("imagelightnessat(): supplied argument is not a valid " - . "Image resource", E_USER_WARNING); + */ +function imagelightnessat($img, $x, $y) { + if (!is_resource($img)) { + trigger_error('imagelightnessat(): supplied argument is not a valid ' + . 'Image resource', E_USER_WARNING); + return 0.0; } $c = @imagecolorat($img, $x, $y); - if($c === false) return false; - if(imageistruecolor($img)) - { + if ($c === false) { + return false; + } + if (imageistruecolor($img)) { $red = ($c >> 16) & 0xFF; $green = ($c >> 8) & 0xFF; $blue = $c & 0xFF; - } - else - { + } else { $i = imagecolorsforindex($img, $c); $red = $i['red']; $green = $i['green']; $blue = $i['blue']; - } + } $m = min($red, $green, $blue); $n = max($red, $green, $blue); /* Because RGB isn't normalized in GD, we divide by 510 here. @@ -40,8 +38,7 @@ function imagelightnessat($img, $x, $y) * But that's assuming red, green, and blue are 0 through 1 inclusive. * Red, green, and blue are actually 0-255 (255 + 255 = 510). */ - $lightness = (double)(($m + $n) / 510.0); - return($lightness); -} + $lightness = (float) (($m + $n) / 510.0); -?> \ No newline at end of file + return $lightness; +} diff --git a/Skirogaining_2010/index.php b/Skirogaining_2010/index.php index 972ed77..a155890 100644 --- a/Skirogaining_2010/index.php +++ b/Skirogaining_2010/index.php @@ -1,67 +1,68 @@ -
%eustring%
- -"; -}else{ -$CMS["%eu%"]=""; +$CMS['%author%'] = $author; +$CMS['%ainfo%'] = $aInfo; +if ($eu == true) { + $CMS['%eu%'] = ' + + +
%eustring%
'; +} else { + $CMS['%eu%'] = ''; } ?> diff --git a/Skirogaining_2010/linear_perspective.class.php b/Skirogaining_2010/linear_perspective.class.php index ab52668..76b91b8 100644 --- a/Skirogaining_2010/linear_perspective.class.php +++ b/Skirogaining_2010/linear_perspective.class.php @@ -1,28 +1,25 @@ 10, 'y' => 0, 'z' => -240]; + public $cam_rotation = ['x' => -1, 'y' => 0, 'z' => 0]; + public $viewer_position = ['x' => 0, 'y' => -540, 'z' => -65]; - public $cam_location = array('x' => 10, 'y' => 0, 'z' => -240); - public $cam_rotation = array('x' => -1, 'y' => 0, 'z' => 0); - public $viewer_position = array('x' => 0, 'y' => -540, 'z' => -65); - - public function get_projection(array $point) { + public function get_projection(array $point) { + $translation = []; + $projection = []; - $translation = array(); - $projection = array(); + $translation['x'] = cos($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])) - sin($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']); + $translation['y'] = sin($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) + cos($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); + $translation['z'] = cos($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) - sin($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); - $translation['x'] = cos($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])) - sin($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']); - $translation['y'] = sin($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) + cos($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); - $translation['z'] = cos($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) - sin($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); + $projection['x'] = ($translation['x'] - $this->viewer_position['x']) * ($this->viewer_position['z'] / $translation['z']); + $projection['y'] = ($translation['y'] - $this->viewer_position['y']) * ($this->viewer_position['z'] / $translation['z']); - $projection['x'] = ($translation['x'] - $this->viewer_position['x']) * ($this->viewer_position['z'] / $translation['z']); - $projection['y'] = ($translation['y'] - $this->viewer_position['y']) * ($this->viewer_position['z'] / $translation['z']); - - return $projection; - } + return $projection; + } } -?> \ No newline at end of file diff --git a/Skirogaining_2010/load.lib.php b/Skirogaining_2010/load.lib.php index a9ae5ca..702b576 100644 --- a/Skirogaining_2010/load.lib.php +++ b/Skirogaining_2010/load.lib.php @@ -1,216 +1,216 @@ ]*)hs=\"([1-9][0-9]?)\"([^>]*)>","",$fileContent); -$sbContent=rplc(sboard_generate($realPage)); -$fileContent=str_replace("",$sbContent,$fileContent); + $fileContent = rplc(file_get_contents($realPage)); + //echo($fileContent); + $fileContent = ereg_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]); + ereg("
(.*)<\/article>", $fileContent, $article); //article body + $article = trim($article[1]); -ereg("(.*)<\/title>",$fileContent,$title);//article title -$title=trim($title[1]); + ereg("<title>(.*)<\/title>", $fileContent, $title); //article title + $title = trim($title[1]); -ereg("<date>(.*)<\/date>",$fileContent,$date);//article title -$date=trim($date[1]); + ereg("<date>(.*)<\/date>", $fileContent, $date); //article title + $date = trim($date[1]); -ereg("<author>(.*)<\/author>",$fileContent,$author);//article title -$author=trim($author[1]); + ereg("<author>(.*)<\/author>", $fileContent, $author); //article title + $author = trim($author[1]); -$languages=array("cs","en","de"); + $languages = ['cs', 'en', 'de']; -ereg("<alias([^>]*)cs=\"([^\"]*)\"([^>]*)>",$fileContent,$cs);//article czech version link -$aliases["cs"]=trim($cs[2]); + ereg('<alias([^>]*)cs="([^"]*)"([^>]*)>', $fileContent, $cs); //article czech version link + $aliases['cs'] = trim($cs[2]); -ereg("<alias([^>]*)en=\"([^\"]*)\"([^>]*)>",$fileContent,$en);//article english version link -$aliases["en"]=trim($en[2]); + ereg('<alias([^>]*)en="([^"]*)"([^>]*)>', $fileContent, $en); //article english version link + $aliases['en'] = trim($en[2]); -ereg("<alias([^>]*)de=\"([^\"]*)\"([^>]*)>",$fileContent,$de);//article german version link -$aliases["de"]=trim($de[2]); + ereg('<alias([^>]*)de="([^"]*)"([^>]*)>', $fileContent, $de); //article german version link + $aliases['de'] = trim($de[2]); -ereg("<menu url=\"([^\"]*)\">",$fileContent,$menuUrl);//article menu url -$menuUrl=trim($menuUrl[1]); -foreach($languages as $language){//language box generator -if(!empty($aliases[$language]) AND file_exists("pages/".$language."/".$aliases[$language].".pg")){ -$langPanel.=rplc("<a href=\"%root%/".$language."/".($aliases[$language]=="main"?"":$aliases[$language])."\"><img src=\"%root%/gpx/".$language."flag.png\" alt=\"".$language."\"></a>"); -} -} -//end of language box generator + ereg('<menu url="([^"]*)">', $fileContent, $menuUrl); //article menu url + $menuUrl = trim($menuUrl[1]); + foreach ($languages as $language) {//language box generator + if (!empty($aliases[$language]) and file_exists('pages/' . $language . '/' . $aliases[$language] . '.pg')) { + $langPanel .= rplc('<a href="%root%/' . $language . '/' . ($aliases[$language] == 'main' ? '' : $aliases[$language]) . '"><img src="%root%/gpx/' . $language . 'flag.png" alt="' . $language . '"></a>'); + } + } + //end of language box generator -$author=$realPageType==1?"":rplc($author); -/*if($realPageType==0){ -if(empty($date)){ -$date=date(rplc("%dateFormat%"),filemtime($realPage)); -} -} -*/ -if(empty($menuUrl) OR !file_exists($menuUrl)){ -$menuUrl="main"; -} -$menu=rplc(file_get_contents("pages/".$lang."/".$menuUrl.".mn")); -$article=rplc($article); -if(ereg("<goto url=\"([^\"]+)\">",$fileContent,$gotoUrl)){ -if($page==$gotoUrl[1]){ -$logrecursive=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("recursive.log"))){ -fwrite($logrecursive,$realPage."\n"); -mail($mainMail,"Presmerovaci smycka http://skirogaining.tojnar.cz/$realPage","Stranka se presmerovava sama na sebe"); -} -fclose($logrecursive); -readPage("error/recursive"); -}else{ -readPage($gotoUrl[1]); -} + $author = $realPageType == 1 ? '' : rplc($author); + /*if($realPageType==0){ + if(empty($date)){ + $date=date(rplc("%dateFormat%"),filemtime($realPage)); + } + } + */ + if (empty($menuUrl) or !file_exists($menuUrl)) { + $menuUrl = 'main'; + } + $menu = rplc(file_get_contents('pages/' . $lang . '/' . $menuUrl . '.mn')); + $article = rplc($article); + if (ereg('<goto url="([^"]+)">', $fileContent, $gotoUrl)) { + if ($page == $gotoUrl[1]) { + $logrecursive = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('recursive.log'))) { + fwrite($logrecursive, $realPage . "\n"); + mail($mainMail, "Presmerovaci smycka http://skirogaining.tojnar.cz/$realPage", 'Stranka se presmerovava sama na sebe'); + } + fclose($logrecursive); + readPage('error/recursive'); + } else { + readPage($gotoUrl[1]); + } + } + + if (strpos($fileContent, '<eu>') != false) { + $eu = true; + } else { + $eu = false; + } + + if (empty($title) and empty($article)) { + $logsyntax = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('syntax.log'))) { + fwrite($logsyntax, $realPage . "\n"); + mail($mainMail, "Chyba syntaxe http://skirogaining.tojnar.cz/$realPage", 'Nerozpoznan titulek a clanek'); + } + fclose($logsyntax); + readPage('error/syntax'); + + return false; + } elseif (empty($title)) { + $logsyntax = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('syntax.log'))) { + fwrite($logsyntax, $realPage . "\n"); + mail($mainMail, "Chyba syntaxe http://skirogaining.tojnar.cz/$realPage", 'Nerozpoznan titulek'); + } + fclose($logsyntax); + readPage('error/syntax'); + + return false; + } elseif (empty($article)) { + $logsyntax = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('syntax.log'))) { + fwrite($logsyntax, $realPage . "\n"); + mail($mainMail, "Chyba syntaxe http://skirogaining.tojnar.cz/$realPage", 'Nerozpoznan clanek'); + } + fclose($logsyntax); + readPage('error/syntax'); + + return false; + } else { + return true; + } } + // string|null author(string $author) + function author($author) { + global $realPageType; + if ($realPageType == 0) { + if (empty($author)) { + return rplc('%unknownAuthor%'); + } else { + return $author; + } + } else { + return null; + } + } + // string|null toDate(string $date) + function toDate($dateStr) { + if (!empty($dateStr)) { + $dateStr = explode(' ', $dateStr); + $dateStr = $dateStr[0]; + $dateStr = explode('-', $dateStr); + $year = $dateStr[0]; + $month = ltrim($dateStr[1], '0'); + $day = ltrim($dateStr[2], '0'); -if(strpos($fileContent,"<eu>")!=false){ -$eu=true; -}else{ -$eu=false; -} + return str_replace(['%y%', '%m%', '%d%'], [$year, $month, $day], rplc('%date%')); + } else { + return null; + } + } + function isReleased($dateStr) { + $dateStr = explode(' ', $dateStr); + $dateStr = $dateStr[0]; + $dateStr = explode('-', $dateStr); + $year = $dateStr[0]; + $month = ltrim($dateStr[1], '0'); + $day = ltrim($dateStr[2], '0'); + $time = explode(' ', $dateStr); + $time = explode(':', $time[1]); + $hour = $time[0]; + $minute = $time[1]; + if (date('Y') >= $year) { + if (date('m') >= $month) { + if (date('d') >= $day) { + if (date('H') >= $hour) { + if (date('i') >= $minute) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } + // string|null toTime(string $date) + function toTime($dateStr) { + if (!empty($dateStr)) { + $time = explode(' ', $dateStr); + $time = $time[1]; -if(empty($title) AND empty($article)){ -$logsyntax=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("syntax.log"))){ -fwrite($logsyntax,$realPage."\n"); -mail($mainMail,"Chyba syntaxe http://skirogaining.tojnar.cz/$realPage","Nerozpoznan titulek a clanek"); + return $time; + } else { + return null; + } + } +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -fclose($logsyntax); -readPage("error/syntax"); -return false; -}elseif(empty($title)){ -$logsyntax=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("syntax.log"))){ -fwrite($logsyntax,$realPage."\n"); -mail($mainMail,"Chyba syntaxe http://skirogaining.tojnar.cz/$realPage","Nerozpoznan titulek"); -} -fclose($logsyntax); -readPage("error/syntax"); -return false; -}elseif(empty($article)){ -$logsyntax=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("syntax.log"))){ -fwrite($logsyntax,$realPage."\n"); -mail($mainMail,"Chyba syntaxe http://skirogaining.tojnar.cz/$realPage","Nerozpoznan clanek"); -} -fclose($logsyntax); -readPage("error/syntax"); -return false; -}else{ -return true; -} -} - -// string|null author(string $author) -function author($author){ -global $realPageType; -if($realPageType==0){ -if(empty($author)){ -return rplc("%unknownAuthor%"); -}else{ -return $author; -} -}else{ -return null; -} -} - -// string|null toDate(string $date) -function toDate($dateStr){ -if(!empty($dateStr)){ -$dateStr=explode(" ",$dateStr); -$dateStr=$dateStr[0]; -$dateStr=explode("-",$dateStr); -$year=$dateStr[0]; -$month=ltrim($dateStr[1],"0"); -$day=ltrim($dateStr[2],"0"); -return str_replace(array("%y%","%m%","%d%"),array($year,$month,$day),rplc("%date%")); -}else{ -return null; -} -} - -function isReleased($dateStr){ -$dateStr=explode(" ",$dateStr); -$dateStr=$dateStr[0]; -$dateStr=explode("-",$dateStr); -$year=$dateStr[0]; -$month=ltrim($dateStr[1],"0"); -$day=ltrim($dateStr[2],"0"); -$time=explode(" ",$dateStr); -$time=explode(":",$time[1]); -$hour=$time[0]; -$minute=$time[1]; -if(date("Y")>=$year){ -if(date("m")>=$month){ -if(date("d")>=$day){ -if(date("H")>=$hour){ -if(date("i")>=$minute){ -return true; -}else{ -return false; -} -}else{ -return false; -} -}else{ -return false; -} -}else{ -return false; -} -}else{ -return false; -} -} - -// string|null toTime(string $date) -function toTime($dateStr){ -if(!empty($dateStr)){ -$time=explode(" ",$dateStr); -$time=$time[1]; -return $time; -}else{ -return null; -} -} - -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); -} -?> diff --git a/Skirogaining_2010/sboard.php b/Skirogaining_2010/sboard.php index 3fe350a..da0f149 100644 --- a/Skirogaining_2010/sboard.php +++ b/Skirogaining_2010/sboard.php @@ -1,95 +1,106 @@ <?php -$sbnum=0; -if(0==9){ -header("HTTP/1.0 303 See Other"); + +$sbnum = 0; +if (0 == 9) { + header('HTTP/1.0 303 See Other'); } /** replaces bb tags on html -* @param string $buffer text with bb codes -* @return string replaced string -* @copyright Jan Tojnar, http://jtojnar.php5.cz/ -*/ -function bb2html($buffer){ -$buffer=ereg_replace("\[b\](.*)\[/b\]","<span class=\"bold\">\\1</span>",$buffer); -$buffer=ereg_replace("\[i\](.*)\[/i\]","<span class=\"italic\">\\1</span>",$buffer); -$buffer=ereg_replace("\[red\](.*)\[/red\]","<span class=\"red\">\\1</span>",$buffer); -$buffer=ereg_replace("\[green\](.*)\[/green\]","<span class=\"green\">\\1</span>",$buffer); -$buffer=ereg_replace("\[blue\](.*)\[/blue\]","<span class=\"blue\">\\1</span>",$buffer); -$buffer=ereg_replace("\[purple\](.*)\[/purple\]","<span class=\"purple\">\\1</span>",$buffer); -$buffer=ereg_replace("\[yellow\](.*)\[/yellow\]","<span class=\"yellow\">\\1</span>",$buffer); -$buffer=ereg_replace("%(.*)%","%\\1%",$buffer); -$buffer=ereg_replace("\n","<br>\n",$buffer); -$buffer=ereg_replace("\r\n","<br>\n",$buffer); -$buffer=ereg_replace("\r","<br>\n",$buffer); -return htmlspecialchars($buffer); + * @param string $buffer text with bb codes + * + * @return string replaced string + * + * @copyright Jan Tojnar, http://jtojnar.php5.cz/ + */ +function bb2html($buffer) { + $buffer = ereg_replace("\[b\](.*)\[/b\]", '<span class="bold">\\1</span>', $buffer); + $buffer = ereg_replace("\[i\](.*)\[/i\]", '<span class="italic">\\1</span>', $buffer); + $buffer = ereg_replace("\[red\](.*)\[/red\]", '<span class="red">\\1</span>', $buffer); + $buffer = ereg_replace("\[green\](.*)\[/green\]", '<span class="green">\\1</span>', $buffer); + $buffer = ereg_replace("\[blue\](.*)\[/blue\]", '<span class="blue">\\1</span>', $buffer); + $buffer = ereg_replace("\[purple\](.*)\[/purple\]", '<span class="purple">\\1</span>', $buffer); + $buffer = ereg_replace("\[yellow\](.*)\[/yellow\]", '<span class="yellow">\\1</span>', $buffer); + $buffer = ereg_replace('%(.*)%', '%\\1%', $buffer); + $buffer = ereg_replace("\n", "<br>\n", $buffer); + $buffer = ereg_replace("\r\n", "<br>\n", $buffer); + $buffer = ereg_replace("\r", "<br>\n", $buffer); + + return htmlspecialchars($buffer); } /** control e-mail address -* @param string $email e-mail address -* @return bool is right address syntax -* @copyright Jakub Vrána, http://php.vrana.cz -*/ -function check_email($email){ -$atom='[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; -$domain='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; -return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$",$email); + * @param string $email e-mail address + * + * @return bool is right address syntax + * + * @copyright Jakub Vrána, http://php.vrana.cz + */ +function check_email($email) { + $atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; + $domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; + + return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$", $email); } /** control www address -* @param string $url www address -* @return bool is right address syntax -* @copyright Jan Tojnar, http://jtojnar.php5.cz -*/ -function check_url($url){ -return eregi("^http[s]?://[-a-z0-9]*\.[-a-z0-9]+\.[a-z]+$",$url); + * @param string $url www address + * + * @return bool is right address syntax + * + * @copyright Jan Tojnar, http://jtojnar.php5.cz + */ +function check_url($url) { + return eregi("^http[s]?://[-a-z0-9]*\.[-a-z0-9]+\.[a-z]+$", $url); } /** returns text of shoutboard -* @param string $file page filename -* @return string shoutboard html -* @copyright Jan Tojnar, http://jtojnar.php5.cz/ -*/ -function sboard_generate($file){ -$sbnum++; -$name=htmlspecialchars($_POST["name"]); -$www=htmlspecialchars($_POST["www"]); -$post=htmlspecialchars($_POST["post"]); -$ip=$_SERVER["REMOTE_ADDR"]; -$timestamp=date(rplc("%dateFormat%")); -$formCaptchaSum=sha1($_POST["captcha"]); -$showmail=$_POST["showmail"]; -$checkedshowmailfalse=$showmail=="false"?" checked=\"checked\"":""; -$checkedshowmailtrue=empty($showmail)?" checked=\"checked\"":($showmail=="true"?" checked=\"checked\"":""); -if($showmail=="true"){ -$email=htmlspecialchars($_POST["email"]); -}else{ -$hemail=htmlspecialchars($_POST["email"]); -} -$formCaptchaSumPre=$_POST["captchasum"]; -$captcha=mt_rand(0,9).mt_rand(0,9).mt_rand(0,9).mt_rand(0,9); -$_SESSION["captcha"]=$captcha; -$captchasum=sha1($captcha); -#echo($timestamp); -#echo($post); -if(isset($_POST["post"])){ -if(empty($post)){ -$sbError.="<p>"."%misspost%"."</p>\n"; -} -if(empty($name)){ -$sbError.="<p>"."%missname%"."</p>\n"; -} -if($formCaptchaSumPre!=$formCaptchaSum){ -$sbError.="<p>"."%wrongcode%"."</p>\n"; -} -if(!empty($email) && !check_email($email)){ -$sbError.="<p>"."%wrongmail%"."</p>\n"; -} -if(!empty($www) && !check_url($www)){ -$sbError.="<p>"."%wrongwww%"."</p>\n"; -} -if(empty($sbError)){ -$sbmail=!empty($email)?"<span class=\"sbmail\"><span>{$email}</span></span>\n":(!empty($hemail)?"<hemail>{$hemail}</hemail>":""); -$sbwww=!empty($www)?"<span class=\"sbwww\"><span>{$www}</span></span>\n":""; -$post=bb2html($post); -$write=<<<EOT + * @param string $file page filename + * + * @return string shoutboard html + * + * @copyright Jan Tojnar, http://jtojnar.php5.cz/ + */ +function sboard_generate($file) { + ++$sbnum; + $name = htmlspecialchars($_POST['name']); + $www = htmlspecialchars($_POST['www']); + $post = htmlspecialchars($_POST['post']); + $ip = $_SERVER['REMOTE_ADDR']; + $timestamp = date(rplc('%dateFormat%')); + $formCaptchaSum = sha1($_POST['captcha']); + $showmail = $_POST['showmail']; + $checkedshowmailfalse = $showmail == 'false' ? ' checked="checked"' : ''; + $checkedshowmailtrue = empty($showmail) ? ' checked="checked"' : ($showmail == 'true' ? ' checked="checked"' : ''); + if ($showmail == 'true') { + $email = htmlspecialchars($_POST['email']); + } else { + $hemail = htmlspecialchars($_POST['email']); + } + $formCaptchaSumPre = $_POST['captchasum']; + $captcha = mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9); + $_SESSION['captcha'] = $captcha; + $captchasum = sha1($captcha); + //echo($timestamp); + //echo($post); + if (isset($_POST['post'])) { + if (empty($post)) { + $sbError .= '<p>' . '%misspost%' . "</p>\n"; + } + if (empty($name)) { + $sbError .= '<p>' . '%missname%' . "</p>\n"; + } + if ($formCaptchaSumPre != $formCaptchaSum) { + $sbError .= '<p>' . '%wrongcode%' . "</p>\n"; + } + if (!empty($email) && !check_email($email)) { + $sbError .= '<p>' . '%wrongmail%' . "</p>\n"; + } + if (!empty($www) && !check_url($www)) { + $sbError .= '<p>' . '%wrongwww%' . "</p>\n"; + } + if (empty($sbError)) { + $sbmail = !empty($email) ? "<span class=\"sbmail\"><span>{$email}</span></span>\n" : (!empty($hemail) ? "<hemail>{$hemail}</hemail>" : ''); + $sbwww = !empty($www) ? "<span class=\"sbwww\"><span>{$www}</span></span>\n" : ''; + $post = bb2html($post); + $write = <<<EOT <div class="sbcomment"> <div class="sbheader"> <span class="sbname">{$name}</span> @@ -101,23 +112,23 @@ $write=<<<EOT EOT; -$shoutfile=fopen($file."c".$sbnum,"a+"); -chmod($file."c".$sbnum,0777); -if(fwrite($shoutfile,$write)){ -$sbError.="<p>"."%saved%"."</p>\n"; -unset($name,$email,$www,$captcha,$post,$ip,$timestamp,$formCaptchaSum,$formCaptchaSumPre,$captchasum,$sbname,$sbdate,$sbwww,$sbmail); -fclose($shoutfile); -}else{ -$sbError.="<p>"."%notsaved%"."</p>\n"; -} -} -} -if(file_exists($file."c".$sbnum)){ -$comments=ereg_replace("<ip>([^<]+)</ip>","",ereg_replace("<hemail>([^<]+)</hemail>","",file_get_contents($file."c".$sbnum))); -}else{ -$comments=""; -} -$form=$comments."<hr class=\"sboard\" id=\"sboard{$sbnum}\">".(empty($sbError)?"":"<div class=\"sberrors\">".rplc($sbError)."</div>").<<<EOT + $shoutfile = fopen($file . 'c' . $sbnum, 'a+'); + chmod($file . 'c' . $sbnum, 0777); + if (fwrite($shoutfile, $write)) { + $sbError .= '<p>' . '%saved%' . "</p>\n"; + unset($name,$email,$www,$captcha,$post,$ip,$timestamp,$formCaptchaSum,$formCaptchaSumPre,$captchasum,$sbname,$sbdate,$sbwww,$sbmail); + fclose($shoutfile); + } else { + $sbError .= '<p>' . '%notsaved%' . "</p>\n"; + } + } + } + if (file_exists($file . 'c' . $sbnum)) { + $comments = ereg_replace('<ip>([^<]+)</ip>', '', ereg_replace('<hemail>([^<]+)</hemail>', '', file_get_contents($file . 'c' . $sbnum))); + } else { + $comments = ''; + } + $form = $comments . "<hr class=\"sboard\" id=\"sboard{$sbnum}\">" . (empty($sbError) ? '' : '<div class="sberrors">' . rplc($sbError) . '</div>') . <<<EOT <form method="post" action="#sboard{$sbnum}" class="sbform"> <div> <dl> @@ -135,6 +146,6 @@ $form=$comments."<hr class=\"sboard\" id=\"sboard{$sbnum}\">".(empty($sbError)?" %sbhelp% </div> EOT; -return $form; + + return $form; } -?> \ No newline at end of file diff --git a/Skirogaining_2010/sitemap.php b/Skirogaining_2010/sitemap.php index 015241d..6ff9216 100644 --- a/Skirogaining_2010/sitemap.php +++ b/Skirogaining_2010/sitemap.php @@ -1,30 +1,31 @@ -<?php -header("Content-Type: text/plain; charset=utf-8"); -function directoryToArray($directory,$recursive){ -$array_items=array(); -if($handle=opendir($directory)){ -while(false!==($file=readdir($handle))){ -if($file!="."&&$file!=".."){ -if(is_dir($directory."/".$file)){ -if($recursive){ -$array_items=array_merge($array_items,directoryToArray($directory. "/".$file,$recursive)); +<?php + +header('Content-Type: text/plain; charset=utf-8'); +function directoryToArray($directory, $recursive) { + $array_items = []; + if ($handle = opendir($directory)) { + while (false !== ($file = readdir($handle))) { + if ($file != '.' && $file != '..') { + if (is_dir($directory . '/' . $file)) { + if ($recursive) { + $array_items = array_merge($array_items, directoryToArray($directory . '/' . $file, $recursive)); + } + $file = $directory . '/' . $file; + } else { + $file = $directory . '/' . $file; + $array_items[] = preg_replace("/\/\//si", '/', $file); + } + } + } + closedir($handle); + } + + return $array_items; } -$file=$directory."/".$file; -}else{ -$file=$directory."/".$file; -$array_items[]=preg_replace("/\/\//si","/",$file); +$files = directoryToArray('./pages', true); +foreach ($files as $file) { + if (substr($file, -3) == '.pg' and (substr($file, 0, 17) != './pages/cs/error/' and substr($file, 0, 17) != './pages/en/error/' and substr($file, 0, 17) != './pages/de/error/')) { + $list .= substr($file, 0, -3) . "\n"; + } } -} -} -closedir($handle); -} -return $array_items; -} -$files=directoryToArray("./pages",true); -foreach($files as $file){ -if(substr($file,-3)==".pg" AND (substr($file,0,17)!="./pages/cs/error/" AND substr($file,0,17)!="./pages/en/error/" AND substr($file,0,17)!="./pages/de/error/")){ -$list.=substr($file,0,-3)."\n"; -} -} -echo(str_replace("./pages","http://".$_SERVER["HTTP_HOST"],$list)); -?> \ No newline at end of file +echo str_replace('./pages', 'http://' . $_SERVER['HTTP_HOST'], $list); diff --git a/cs.php b/cs.php index cf8e5e0..a62f2c4 100644 --- a/cs.php +++ b/cs.php @@ -1,52 +1,53 @@ <?php -if($included==true){ -$CMS["%by%"]="%author% ~ %date%, %time%"; -$CMS["%january%"]="leden"; -$CMS["%february%"]="únor"; -$CMS["%march%"]="březen"; -$CMS["%april%"]="duben"; -$CMS["%may%"]="květen"; -$CMS["%june%"]="červen"; -$CMS["%july%"]="červenec"; -$CMS["%august%"]="srpen"; -$CMS["%september%"]="září"; -$CMS["%october%"]="říjen"; -$CMS["%november%"]="listopad"; -$CMS["%december%"]="prosinec"; -$CMS["%date%"]="%d%. %m%. %y%"; -$CMS["%byAuthor%"]="%author%"; -$CMS["%byDate%"]="%date%, %time%"; -$CMS["%longTitle%"]="%title% - %pretitle%"; -$CMS["%enterpost%"]="Zadejte zprávu"; -$CMS["%messages:%"]="Vzkazy:"; -$CMS["%name:%"]="Jméno:"; -$CMS["%message:%"]="Vzkaz:"; -$CMS["%password:%"]="Heslo:"; -$CMS["%red%"]="červená"; -$CMS["%green%"]="zelená"; -$CMS["%blue%"]="modrá"; -$CMS["%yellow%"]="žlutá"; -$CMS["%purple%"]="fialová"; -$CMS["%color:%"]="Barva:"; -$CMS["%send%"]="Odeslat"; -$CMS["%notrequiredpassword%"]="Není vyžadováno"; -$CMS["%no%"]="ne"; -$CMS["%yes%"]="ano"; -$CMS["%areyourobot%"]="Jste robot?"; -$CMS["%www:%"]="WWW:"; -$CMS["%email:%"]="E-Mail:"; -$CMS["%search%"]="Hledat"; -$CMS["%req%"]="(vyžadováno)"; -$CMS["%gotop%"]="↑Nahoru"; -$CMS["%misspost%"]="Nezadali jste zprávu"; -$CMS["%missname%"]="Nezadali jste jméno"; -$CMS["%wrongcode%"]="Zadal jste špatný ověřovací kód"; -$CMS["%wrongmail%"]="To co jste zadali není platný e-mail"; -$CMS["%saved%"]="Zpráva byla odeslána"; -$CMS["%notsaved%"]="Zpráva nebyla odeslána"; -$CMS["%showmail%"]="Zobrazovat e-mail každému"; -$CMS["%wrongwww%"]="To co jste zadali není platné <abbr title=\"Uniform Resource Locale\">URL</abbr>"; -$CMS["%sbhelp%"]=<<<EOT + +if ($included == true) { + $CMS['%by%'] = '%author% ~ %date%, %time%'; + $CMS['%january%'] = 'leden'; + $CMS['%february%'] = 'únor'; + $CMS['%march%'] = 'březen'; + $CMS['%april%'] = 'duben'; + $CMS['%may%'] = 'květen'; + $CMS['%june%'] = 'červen'; + $CMS['%july%'] = 'červenec'; + $CMS['%august%'] = 'srpen'; + $CMS['%september%'] = 'září'; + $CMS['%october%'] = 'říjen'; + $CMS['%november%'] = 'listopad'; + $CMS['%december%'] = 'prosinec'; + $CMS['%date%'] = '%d%. %m%. %y%'; + $CMS['%byAuthor%'] = '%author%'; + $CMS['%byDate%'] = '%date%, %time%'; + $CMS['%longTitle%'] = '%title% - %pretitle%'; + $CMS['%enterpost%'] = 'Zadejte zprávu'; + $CMS['%messages:%'] = 'Vzkazy:'; + $CMS['%name:%'] = 'Jméno:'; + $CMS['%message:%'] = 'Vzkaz:'; + $CMS['%password:%'] = 'Heslo:'; + $CMS['%red%'] = 'červená'; + $CMS['%green%'] = 'zelená'; + $CMS['%blue%'] = 'modrá'; + $CMS['%yellow%'] = 'žlutá'; + $CMS['%purple%'] = 'fialová'; + $CMS['%color:%'] = 'Barva:'; + $CMS['%send%'] = 'Odeslat'; + $CMS['%notrequiredpassword%'] = 'Není vyžadováno'; + $CMS['%no%'] = 'ne'; + $CMS['%yes%'] = 'ano'; + $CMS['%areyourobot%'] = 'Jste robot?'; + $CMS['%www:%'] = 'WWW:'; + $CMS['%email:%'] = 'E-Mail:'; + $CMS['%search%'] = 'Hledat'; + $CMS['%req%'] = '(vyžadováno)'; + $CMS['%gotop%'] = '↑Nahoru'; + $CMS['%misspost%'] = 'Nezadali jste zprávu'; + $CMS['%missname%'] = 'Nezadali jste jméno'; + $CMS['%wrongcode%'] = 'Zadal jste špatný ověřovací kód'; + $CMS['%wrongmail%'] = 'To co jste zadali není platný e-mail'; + $CMS['%saved%'] = 'Zpráva byla odeslána'; + $CMS['%notsaved%'] = 'Zpráva nebyla odeslána'; + $CMS['%showmail%'] = 'Zobrazovat e-mail každému'; + $CMS['%wrongwww%'] = 'To co jste zadali není platné <abbr title="Uniform Resource Locale">URL</abbr>'; + $CMS['%sbhelp%'] = <<<EOT <h3>Nápověda</h3> <dl> <dt><abbr title="HyperText Markup Language">HTML</abbr></dt><dd>není podporováno</dd> @@ -59,10 +60,9 @@ $CMS["%sbhelp%"]=<<<EOT <dt>[yellow]žluté písmo[/yellow]</dt><dd><span class="yellow">žluté písmo</span></dd> </dl> EOT; -$CMS["%searchform%"]="006883172923970328180:3wantrdnnzy"; -$CMS["%eustring%"]="Tento projekt byl podpořen z Evropského fondu pro regionální rozvoj, fondu malých projektů Programu Cíl 3 na podporu přeshraniční spolupráce mezi Českou republikou a Svobodným státem Sasko 2007-2013."; -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); + $CMS['%searchform%'] = '006883172923970328180:3wantrdnnzy'; + $CMS['%eustring%'] = 'Tento projekt byl podpořen z Evropského fondu pro regionální rozvoj, fondu malých projektů Programu Cíl 3 na podporu přeshraniční spolupráce mezi Českou republikou a Svobodným státem Sasko 2007-2013.'; +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -?> \ No newline at end of file diff --git a/de.php b/de.php index cb62a63..0d15124 100644 --- a/de.php +++ b/de.php @@ -1,52 +1,53 @@ <?php -if($included==true){ -$CMS["%by%"]="%author% ~ %date%, %time%"; -$CMS["%january%"]="of January"; -$CMS["%february%"]="of February"; -$CMS["%march%"]="of March"; -$CMS["%april%"]="of April"; -$CMS["%may%"]="of May"; -$CMS["%june%"]="of June"; -$CMS["%july%"]="of July"; -$CMS["%august%"]="of August"; -$CMS["%september%"]="of September"; -$CMS["%october%"]="of October"; -$CMS["%november%"]="of November"; -$CMS["%december%"]="of December"; -$CMS["%date%"]="%d%. %m%. %y%"; -$CMS["%byAuthor%"]="%author%"; -$CMS["%byDate%"]="%date%, %time%"; -$CMS["%longTitle%"]="%title% - %pretitle%"; -$CMS["%enterpost%"]="Enter message"; -$CMS["%messages:%"]="Messages:"; -$CMS["%name:%"]="Name:"; -$CMS["%message:%"]="Message:"; -$CMS["%password:%"]="Password:"; -$CMS["%red%"]="red"; -$CMS["%green%"]="green"; -$CMS["%blue%"]="blue"; -$CMS["%yellow%"]="yellow"; -$CMS["%purple%"]="purple"; -$CMS["%color:%"]="Color:"; -$CMS["%send%"]="Submit"; -$CMS["%notrequiredpassword%"]="Not required"; -$CMS["%no%"]="no"; -$CMS["%yes%"]="yes"; -$CMS["%areyourobot%"]="Are you robot?"; -$CMS["%www:%"]="WWW:"; -$CMS["%email:%"]="E-Mail:"; -$CMS["%search%"]="Search"; -$CMS["%req%"]="(required)"; -$CMS["%gotop%"]="↑Go top"; -$CMS["%misspost%"]="Message is missing"; -$CMS["%missname%"]="Name is missing"; -$CMS["%wrongcode%"]="You have entered wrong verification code"; -$CMS["%wrongmail%"]="You have entered wrong e-mail"; -$CMS["%saved%"]="Message have been sent"; -$CMS["%notsaved%"]="Message have not been sent"; -$CMS["%showmail%"]="Show e-mail to everyone"; -$CMS["%wrongwww%"]="You have entered wrong <abbr title=\"Uniform Resource Locale\">URL</abbr>"; -$CMS["%sbhelp%"]=<<<EOT + +if ($included == true) { + $CMS['%by%'] = '%author% ~ %date%, %time%'; + $CMS['%january%'] = 'of January'; + $CMS['%february%'] = 'of February'; + $CMS['%march%'] = 'of March'; + $CMS['%april%'] = 'of April'; + $CMS['%may%'] = 'of May'; + $CMS['%june%'] = 'of June'; + $CMS['%july%'] = 'of July'; + $CMS['%august%'] = 'of August'; + $CMS['%september%'] = 'of September'; + $CMS['%october%'] = 'of October'; + $CMS['%november%'] = 'of November'; + $CMS['%december%'] = 'of December'; + $CMS['%date%'] = '%d%. %m%. %y%'; + $CMS['%byAuthor%'] = '%author%'; + $CMS['%byDate%'] = '%date%, %time%'; + $CMS['%longTitle%'] = '%title% - %pretitle%'; + $CMS['%enterpost%'] = 'Enter message'; + $CMS['%messages:%'] = 'Messages:'; + $CMS['%name:%'] = 'Name:'; + $CMS['%message:%'] = 'Message:'; + $CMS['%password:%'] = 'Password:'; + $CMS['%red%'] = 'red'; + $CMS['%green%'] = 'green'; + $CMS['%blue%'] = 'blue'; + $CMS['%yellow%'] = 'yellow'; + $CMS['%purple%'] = 'purple'; + $CMS['%color:%'] = 'Color:'; + $CMS['%send%'] = 'Submit'; + $CMS['%notrequiredpassword%'] = 'Not required'; + $CMS['%no%'] = 'no'; + $CMS['%yes%'] = 'yes'; + $CMS['%areyourobot%'] = 'Are you robot?'; + $CMS['%www:%'] = 'WWW:'; + $CMS['%email:%'] = 'E-Mail:'; + $CMS['%search%'] = 'Search'; + $CMS['%req%'] = '(required)'; + $CMS['%gotop%'] = '↑Go top'; + $CMS['%misspost%'] = 'Message is missing'; + $CMS['%missname%'] = 'Name is missing'; + $CMS['%wrongcode%'] = 'You have entered wrong verification code'; + $CMS['%wrongmail%'] = 'You have entered wrong e-mail'; + $CMS['%saved%'] = 'Message have been sent'; + $CMS['%notsaved%'] = 'Message have not been sent'; + $CMS['%showmail%'] = 'Show e-mail to everyone'; + $CMS['%wrongwww%'] = 'You have entered wrong <abbr title="Uniform Resource Locale">URL</abbr>'; + $CMS['%sbhelp%'] = <<<EOT <h3>Help</h3> <dl> <dt><abbr title="HyperText Markup Language">HTML</abbr></dt><dd>not supported</dd> @@ -59,10 +60,9 @@ $CMS["%sbhelp%"]=<<<EOT <dt>[yellow]yellow text[/yellow]</dt><dd><span class="yellow">yellow text</span></dd> </dl> EOT; -$CMS["%searchform%"]="006883172923970328180:bfehocs55i8"; -$CMS["%eustring%"]="Das Projekt wurde von dem Europäischen Fonds für Regionalentwicklung (KPF, Ziel 3 - Programm zur Förderung der grenzübergreifenden Zusammenarbeit zwischen dem Freistaat Sachsen und der Tschechischen Republik 2007-2013) unterstützt."; -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); + $CMS['%searchform%'] = '006883172923970328180:bfehocs55i8'; + $CMS['%eustring%'] = 'Das Projekt wurde von dem Europäischen Fonds für Regionalentwicklung (KPF, Ziel 3 - Programm zur Förderung der grenzübergreifenden Zusammenarbeit zwischen dem Freistaat Sachsen und der Tschechischen Republik 2007-2013) unterstützt.'; +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -?> \ No newline at end of file diff --git a/en.php b/en.php index c60cca3..075e855 100644 --- a/en.php +++ b/en.php @@ -1,52 +1,53 @@ <?php -if($included==true){ -$CMS["%by%"]="%author% ~ %date%, %time%"; -$CMS["%january%"]="of January"; -$CMS["%february%"]="of February"; -$CMS["%march%"]="of March"; -$CMS["%april%"]="of April"; -$CMS["%may%"]="of May"; -$CMS["%june%"]="of June"; -$CMS["%july%"]="of July"; -$CMS["%august%"]="of August"; -$CMS["%september%"]="of September"; -$CMS["%october%"]="of October"; -$CMS["%november%"]="of November"; -$CMS["%december%"]="of December"; -$CMS["%date%"]="%d%. %m%. %y%"; -$CMS["%byAuthor%"]="%author%"; -$CMS["%byDate%"]="%date%, %time%"; -$CMS["%longTitle%"]="%title% - %pretitle%"; -$CMS["%enterpost%"]="Enter message"; -$CMS["%messages:%"]="Messages:"; -$CMS["%name:%"]="Name:"; -$CMS["%message:%"]="Message:"; -$CMS["%password:%"]="Password:"; -$CMS["%red%"]="red"; -$CMS["%green%"]="green"; -$CMS["%blue%"]="blue"; -$CMS["%yellow%"]="yellow"; -$CMS["%purple%"]="purple"; -$CMS["%color:%"]="Color:"; -$CMS["%send%"]="Submit"; -$CMS["%notrequiredpassword%"]="Not required"; -$CMS["%no%"]="no"; -$CMS["%yes%"]="yes"; -$CMS["%areyourobot%"]="Are you robot?"; -$CMS["%www:%"]="WWW:"; -$CMS["%email:%"]="E-Mail:"; -$CMS["%search%"]="Search"; -$CMS["%req%"]="(required)"; -$CMS["%gotop%"]="↑Go top"; -$CMS["%misspost%"]="Message is missing"; -$CMS["%missname%"]="Name is missing"; -$CMS["%wrongcode%"]="You have entered wrong verification code"; -$CMS["%wrongmail%"]="You have entered wrong e-mail"; -$CMS["%saved%"]="Message have been sent"; -$CMS["%notsaved%"]="Message have not been sent"; -$CMS["%showmail%"]="Show e-mail to everyone"; -$CMS["%wrongwww%"]="You have entered wrong <abbr title=\"Uniform Resource Locale\">URL</abbr>"; -$CMS["%sbhelp%"]=<<<EOT + +if ($included == true) { + $CMS['%by%'] = '%author% ~ %date%, %time%'; + $CMS['%january%'] = 'of January'; + $CMS['%february%'] = 'of February'; + $CMS['%march%'] = 'of March'; + $CMS['%april%'] = 'of April'; + $CMS['%may%'] = 'of May'; + $CMS['%june%'] = 'of June'; + $CMS['%july%'] = 'of July'; + $CMS['%august%'] = 'of August'; + $CMS['%september%'] = 'of September'; + $CMS['%october%'] = 'of October'; + $CMS['%november%'] = 'of November'; + $CMS['%december%'] = 'of December'; + $CMS['%date%'] = '%d%. %m%. %y%'; + $CMS['%byAuthor%'] = '%author%'; + $CMS['%byDate%'] = '%date%, %time%'; + $CMS['%longTitle%'] = '%title% - %pretitle%'; + $CMS['%enterpost%'] = 'Enter message'; + $CMS['%messages:%'] = 'Messages:'; + $CMS['%name:%'] = 'Name:'; + $CMS['%message:%'] = 'Message:'; + $CMS['%password:%'] = 'Password:'; + $CMS['%red%'] = 'red'; + $CMS['%green%'] = 'green'; + $CMS['%blue%'] = 'blue'; + $CMS['%yellow%'] = 'yellow'; + $CMS['%purple%'] = 'purple'; + $CMS['%color:%'] = 'Color:'; + $CMS['%send%'] = 'Submit'; + $CMS['%notrequiredpassword%'] = 'Not required'; + $CMS['%no%'] = 'no'; + $CMS['%yes%'] = 'yes'; + $CMS['%areyourobot%'] = 'Are you robot?'; + $CMS['%www:%'] = 'WWW:'; + $CMS['%email:%'] = 'E-Mail:'; + $CMS['%search%'] = 'Search'; + $CMS['%req%'] = '(required)'; + $CMS['%gotop%'] = '↑Go top'; + $CMS['%misspost%'] = 'Message is missing'; + $CMS['%missname%'] = 'Name is missing'; + $CMS['%wrongcode%'] = 'You have entered wrong verification code'; + $CMS['%wrongmail%'] = 'You have entered wrong e-mail'; + $CMS['%saved%'] = 'Message have been sent'; + $CMS['%notsaved%'] = 'Message have not been sent'; + $CMS['%showmail%'] = 'Show e-mail to everyone'; + $CMS['%wrongwww%'] = 'You have entered wrong <abbr title="Uniform Resource Locale">URL</abbr>'; + $CMS['%sbhelp%'] = <<<EOT <h3>Help</h3> <dl> <dt><abbr title="HyperText Markup Language">HTML</abbr></dt><dd>not supported</dd> @@ -59,10 +60,9 @@ $CMS["%sbhelp%"]=<<<EOT <dt>[yellow]yellow text[/yellow]</dt><dd><span class="yellow">yellow text</span></dd> </dl> EOT; -$CMS["%searchform%"]="006883172923970328180:bfehocs55i8"; -$CMS["%eustring%"]="The project was supported from European fund of regional development, Common fund of small projects, Programme \"Cil 3\" supporting collaboration of the Czech Republic and Free State Saxony 2007-2013."; -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); + $CMS['%searchform%'] = '006883172923970328180:bfehocs55i8'; + $CMS['%eustring%'] = 'The project was supported from European fund of regional development, Common fund of small projects, Programme "Cil 3" supporting collaboration of the Czech Republic and Free State Saxony 2007-2013.'; +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -?> \ No newline at end of file diff --git a/imagelightnessat.func.php b/imagelightnessat.func.php index a99225c..59e70e3 100644 --- a/imagelightnessat.func.php +++ b/imagelightnessat.func.php @@ -9,30 +9,28 @@ * x, y The coordinates of the pixel to work on * * by Jed Smith <?php $u = "jed"; $d = "bz"; printf("<%s@%s.%s>", $u, $u, $d) ?> - */ -function imagelightnessat($img, $x, $y) -{ - if(!is_resource($img)) - { - trigger_error("imagelightnessat(): supplied argument is not a valid " - . "Image resource", E_USER_WARNING); + */ +function imagelightnessat($img, $x, $y) { + if (!is_resource($img)) { + trigger_error('imagelightnessat(): supplied argument is not a valid ' + . 'Image resource', E_USER_WARNING); + return 0.0; } $c = @imagecolorat($img, $x, $y); - if($c === false) return false; - if(imageistruecolor($img)) - { + if ($c === false) { + return false; + } + if (imageistruecolor($img)) { $red = ($c >> 16) & 0xFF; $green = ($c >> 8) & 0xFF; $blue = $c & 0xFF; - } - else - { + } else { $i = imagecolorsforindex($img, $c); $red = $i['red']; $green = $i['green']; $blue = $i['blue']; - } + } $m = min($red, $green, $blue); $n = max($red, $green, $blue); /* Because RGB isn't normalized in GD, we divide by 510 here. @@ -40,8 +38,7 @@ function imagelightnessat($img, $x, $y) * But that's assuming red, green, and blue are 0 through 1 inclusive. * Red, green, and blue are actually 0-255 (255 + 255 = 510). */ - $lightness = (double)(($m + $n) / 510.0); - return($lightness); -} + $lightness = (float) (($m + $n) / 510.0); -?> \ No newline at end of file + return $lightness; +} diff --git a/index.php b/index.php index 3a159a3..aa7afa7 100644 --- a/index.php +++ b/index.php @@ -1,74 +1,75 @@ <?php session_start(); -$included=true; -$lang=empty($_GET["lang"])?"cs":$_GET["lang"]; -$page=htmlspecialchars($_GET["page"]); -$url=$_SERVER["REQUEST_URI"]; -$root=""; -$pretitle="2. Skirogaining 2012"; -$mainMail="tojnar@gmail.com"; -include($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["%dateFormat%"]="d.m.Y H:i"; -if($lang=='cs') { -$CMS["%old%"]='<p class="old"><a href="http://skirogaining.tojnar.cz/Skirogaining_2010/">1. Skirogaining 2010</a> <a href="http://skirogaining.krk-litvinov.cz/">3. Skirogaining 2012</a></p>'; -} elseif($lang=='de') { -$CMS["%old%"]='<p class="old"><a href="http://skirogaining.tojnar.cz/Skirogaining_2010/de/">1. Skirogaining 2010</a> <a href="http://skirogaining.krk-litvinov.cz/de/">3. Skirogaining 2012</a></p>'; +$included = true; +$lang = empty($_GET['lang']) ? 'cs' : $_GET['lang']; +$page = htmlspecialchars($_GET['page']); +$url = $_SERVER['REQUEST_URI']; +$root = ''; +$pretitle = '2. Skirogaining 2012'; +$mainMail = 'tojnar@gmail.com'; +include $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['%dateFormat%'] = 'd.m.Y H:i'; +if ($lang == 'cs') { + $CMS['%old%'] = '<p class="old"><a href="http://skirogaining.tojnar.cz/Skirogaining_2010/">1. Skirogaining 2010</a> <a href="http://skirogaining.krk-litvinov.cz/">3. Skirogaining 2012</a></p>'; +} elseif ($lang == 'de') { + $CMS['%old%'] = '<p class="old"><a href="http://skirogaining.tojnar.cz/Skirogaining_2010/de/">1. Skirogaining 2010</a> <a href="http://skirogaining.krk-litvinov.cz/de/">3. Skirogaining 2012</a></p>'; } else { -$CMS["%old%"]=''; + $CMS['%old%'] = ''; } -function rplc($string){ -global $CMS; -return str_replace(array_keys($CMS),$CMS,$string); +function rplc($string) { + global $CMS; + + return str_replace(array_keys($CMS), $CMS, $string); } -include("sboard.php"); -include("load.lib.php"); +include 'sboard.php'; +include '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; -if($eu==true){ -$CMS["%eu%"]="<table class=\"table-no-border\" id=\"ziel3\"> -<tr><td colspan=\"2\"><h6>%eustring%</h6></td></tr> -<tr><td><img src=\"/images/EU-Logo_rgb.jpg\" height=\"45\" width=\"361\"></td><td><img src=\"/images/ziel-small.jpg\" class=\"margin-05\"></td></tr> -</table>"; -}else{ -$CMS["%eu%"]=""; +$CMS['%author%'] = $author; +$CMS['%ainfo%'] = $aInfo; +if ($eu == true) { + $CMS['%eu%'] = '<table class="table-no-border" id="ziel3"> +<tr><td colspan="2"><h6>%eustring%</h6></td></tr> +<tr><td><img src="/images/EU-Logo_rgb.jpg" height="45" width="361"></td><td><img src="/images/ziel-small.jpg" class="margin-05"></td></tr> +</table>'; +} else { + $CMS['%eu%'] = ''; } ?> <?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)); ?> \ No newline at end of file diff --git a/linear_perspective.class.php b/linear_perspective.class.php index ab52668..76b91b8 100644 --- a/linear_perspective.class.php +++ b/linear_perspective.class.php @@ -1,28 +1,25 @@ <?php -# Martin Hozik -# 24.5.2008 -# doublethink.cleverweb.cz +// Martin Hozik +// 24.5.2008 +// doublethink.cleverweb.cz class linear_perspective { + public $cam_location = ['x' => 10, 'y' => 0, 'z' => -240]; + public $cam_rotation = ['x' => -1, 'y' => 0, 'z' => 0]; + public $viewer_position = ['x' => 0, 'y' => -540, 'z' => -65]; - public $cam_location = array('x' => 10, 'y' => 0, 'z' => -240); - public $cam_rotation = array('x' => -1, 'y' => 0, 'z' => 0); - public $viewer_position = array('x' => 0, 'y' => -540, 'z' => -65); - - public function get_projection(array $point) { + public function get_projection(array $point) { + $translation = []; + $projection = []; - $translation = array(); - $projection = array(); + $translation['x'] = cos($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])) - sin($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']); + $translation['y'] = sin($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) + cos($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); + $translation['z'] = cos($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) - sin($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); - $translation['x'] = cos($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])) - sin($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']); - $translation['y'] = sin($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) + cos($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); - $translation['z'] = cos($this->cam_rotation['x']) * (cos($this->cam_rotation['y']) * ($point['z'] - $this->cam_location['z']) + sin($this->cam_rotation['y']) * (sin($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) + cos($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x']))) - sin($this->cam_rotation['z']) * (cos($this->cam_rotation['z']) * ($point['y'] - $this->cam_location['y']) - sin($this->cam_rotation['z']) * ($point['x'] - $this->cam_location['x'])); + $projection['x'] = ($translation['x'] - $this->viewer_position['x']) * ($this->viewer_position['z'] / $translation['z']); + $projection['y'] = ($translation['y'] - $this->viewer_position['y']) * ($this->viewer_position['z'] / $translation['z']); - $projection['x'] = ($translation['x'] - $this->viewer_position['x']) * ($this->viewer_position['z'] / $translation['z']); - $projection['y'] = ($translation['y'] - $this->viewer_position['y']) * ($this->viewer_position['z'] / $translation['z']); - - return $projection; - } + return $projection; + } } -?> \ No newline at end of file diff --git a/load.lib.php b/load.lib.php index 7f496d6..702b576 100644 --- a/load.lib.php +++ b/load.lib.php @@ -1,216 +1,216 @@ <?php -if($included==true){ -// boolean readPage(string $page) -function readPage($page){//main function + +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"; -}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://skirogaining.tojnar.cz/$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 + if (empty($page)) {//page specification + $realPage = 'pages/' . $lang . '/main.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://skirogaining.tojnar.cz/$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 -$fileContent=rplc(file_get_contents($realPage)); -//echo($fileContent); -$fileContent=ereg_replace("<a([^>]*)hs=\"([1-9][0-9]?)\"([^>]*)>","<a\\1onclick=\"return hs.expand(this,{slideshowGroup:\\2})\"\\3>",$fileContent); -$sbContent=rplc(sboard_generate($realPage)); -$fileContent=str_replace("<board>",$sbContent,$fileContent); + $fileContent = rplc(file_get_contents($realPage)); + //echo($fileContent); + $fileContent = ereg_replace('<a([^>]*)hs="([1-9][0-9]?)"([^>]*)>', '<a\\1onclick="return hs.expand(this,{slideshowGroup:\\2})"\\3>', $fileContent); + $sbContent = rplc(sboard_generate($realPage)); + $fileContent = str_replace('<board>', $sbContent, $fileContent); -ereg("<article>(.*)<\/article>",$fileContent,$article);//article body -$article=trim($article[1]); + ereg("<article>(.*)<\/article>", $fileContent, $article); //article body + $article = trim($article[1]); -ereg("<title>(.*)<\/title>",$fileContent,$title);//article title -$title=trim($title[1]); + ereg("<title>(.*)<\/title>", $fileContent, $title); //article title + $title = trim($title[1]); -ereg("<date>(.*)<\/date>",$fileContent,$date);//article title -$date=trim($date[1]); + ereg("<date>(.*)<\/date>", $fileContent, $date); //article title + $date = trim($date[1]); -ereg("<author>(.*)<\/author>",$fileContent,$author);//article title -$author=trim($author[1]); + ereg("<author>(.*)<\/author>", $fileContent, $author); //article title + $author = trim($author[1]); -$languages=array("cs","en","de"); + $languages = ['cs', 'en', 'de']; -ereg("<alias([^>]*)cs=\"([^\"]*)\"([^>]*)>",$fileContent,$cs);//article czech version link -$aliases["cs"]=trim($cs[2]); + ereg('<alias([^>]*)cs="([^"]*)"([^>]*)>', $fileContent, $cs); //article czech version link + $aliases['cs'] = trim($cs[2]); -ereg("<alias([^>]*)en=\"([^\"]*)\"([^>]*)>",$fileContent,$en);//article english version link -$aliases["en"]=trim($en[2]); + ereg('<alias([^>]*)en="([^"]*)"([^>]*)>', $fileContent, $en); //article english version link + $aliases['en'] = trim($en[2]); -ereg("<alias([^>]*)de=\"([^\"]*)\"([^>]*)>",$fileContent,$de);//article german version link -$aliases["de"]=trim($de[2]); + ereg('<alias([^>]*)de="([^"]*)"([^>]*)>', $fileContent, $de); //article german version link + $aliases['de'] = trim($de[2]); -ereg("<menu url=\"([^\"]*)\">",$fileContent,$menuUrl);//article menu url -$menuUrl=trim($menuUrl[1]); -foreach($languages as $language){//language box generator -if(!empty($aliases[$language]) AND file_exists("pages/".$language."/".$aliases[$language].".pg")){ -$langPanel.=rplc("<a href=\"%root%/".$language."/".($aliases[$language]=="main"?"":$aliases[$language])."\"><img src=\"%root%/gpx/".$language."flag.png\" alt=\"".$language."\"></a>"); -} -} -//end of language box generator + ereg('<menu url="([^"]*)">', $fileContent, $menuUrl); //article menu url + $menuUrl = trim($menuUrl[1]); + foreach ($languages as $language) {//language box generator + if (!empty($aliases[$language]) and file_exists('pages/' . $language . '/' . $aliases[$language] . '.pg')) { + $langPanel .= rplc('<a href="%root%/' . $language . '/' . ($aliases[$language] == 'main' ? '' : $aliases[$language]) . '"><img src="%root%/gpx/' . $language . 'flag.png" alt="' . $language . '"></a>'); + } + } + //end of language box generator -$author=$realPageType==1?"":rplc($author); -/*if($realPageType==0){ -if(empty($date)){ -$date=date(rplc("%dateFormat%"),filemtime($realPage)); -} -} -*/ -if(empty($menuUrl) OR !file_exists($menuUrl)){ -$menuUrl="main"; -} -$menu=rplc(file_get_contents("pages/".$lang."/".$menuUrl.".mn")); -$article=rplc($article); -if(ereg("<goto url=\"([^\"]+)\">",$fileContent,$gotoUrl)){ -if($page==$gotoUrl[1]){ -$logrecursive=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("recursive.log"))){ -fwrite($logrecursive,$realPage."\n"); -mail($mainMail,"Presmerovaci smycka http://skirogaining.tojnar.cz/$realPage","Stranka se presmerovava sama na sebe"); -} -fclose($logrecursive); -readPage("error/recursive"); -}else{ -readPage($gotoUrl[1]); -} + $author = $realPageType == 1 ? '' : rplc($author); + /*if($realPageType==0){ + if(empty($date)){ + $date=date(rplc("%dateFormat%"),filemtime($realPage)); + } + } + */ + if (empty($menuUrl) or !file_exists($menuUrl)) { + $menuUrl = 'main'; + } + $menu = rplc(file_get_contents('pages/' . $lang . '/' . $menuUrl . '.mn')); + $article = rplc($article); + if (ereg('<goto url="([^"]+)">', $fileContent, $gotoUrl)) { + if ($page == $gotoUrl[1]) { + $logrecursive = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('recursive.log'))) { + fwrite($logrecursive, $realPage . "\n"); + mail($mainMail, "Presmerovaci smycka http://skirogaining.tojnar.cz/$realPage", 'Stranka se presmerovava sama na sebe'); + } + fclose($logrecursive); + readPage('error/recursive'); + } else { + readPage($gotoUrl[1]); + } + } + + if (strpos($fileContent, '<eu>') != false) { + $eu = true; + } else { + $eu = false; + } + + if (empty($title) and empty($article)) { + $logsyntax = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('syntax.log'))) { + fwrite($logsyntax, $realPage . "\n"); + mail($mainMail, "Chyba syntaxe http://skirogaining.tojnar.cz/$realPage", 'Nerozpoznan titulek a clanek'); + } + fclose($logsyntax); + readPage('error/syntax'); + + return false; + } elseif (empty($title)) { + $logsyntax = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('syntax.log'))) { + fwrite($logsyntax, $realPage . "\n"); + mail($mainMail, "Chyba syntaxe http://skirogaining.tojnar.cz/$realPage", 'Nerozpoznan titulek'); + } + fclose($logsyntax); + readPage('error/syntax'); + + return false; + } elseif (empty($article)) { + $logsyntax = fopen('syntax.log', 'a+'); + if (!ereg($realPage . "\n", file_get_contents('syntax.log'))) { + fwrite($logsyntax, $realPage . "\n"); + mail($mainMail, "Chyba syntaxe http://skirogaining.tojnar.cz/$realPage", 'Nerozpoznan clanek'); + } + fclose($logsyntax); + readPage('error/syntax'); + + return false; + } else { + return true; + } } + // string|null author(string $author) + function author($author) { + global $realPageType; + if ($realPageType == 0) { + if (empty($author)) { + return rplc('%unknownAuthor%'); + } else { + return $author; + } + } else { + return null; + } + } + // string|null toDate(string $date) + function toDate($dateStr) { + if (!empty($dateStr)) { + $dateStr = explode(' ', $dateStr); + $dateStr = $dateStr[0]; + $dateStr = explode('-', $dateStr); + $year = $dateStr[0]; + $month = ltrim($dateStr[1], '0'); + $day = ltrim($dateStr[2], '0'); -if(strpos($fileContent,"<eu>")!=false){ -$eu=true; -}else{ -$eu=false; -} + return str_replace(['%y%', '%m%', '%d%'], [$year, $month, $day], rplc('%date%')); + } else { + return null; + } + } + function isReleased($dateStr) { + $dateStr = explode(' ', $dateStr); + $dateStr = $dateStr[0]; + $dateStr = explode('-', $dateStr); + $year = $dateStr[0]; + $month = ltrim($dateStr[1], '0'); + $day = ltrim($dateStr[2], '0'); + $time = explode(' ', $dateStr); + $time = explode(':', $time[1]); + $hour = $time[0]; + $minute = $time[1]; + if (date('Y') >= $year) { + if (date('m') >= $month) { + if (date('d') >= $day) { + if (date('H') >= $hour) { + if (date('i') >= $minute) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } + // string|null toTime(string $date) + function toTime($dateStr) { + if (!empty($dateStr)) { + $time = explode(' ', $dateStr); + $time = $time[1]; -if(empty($title) AND empty($article)){ -$logsyntax=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("syntax.log"))){ -fwrite($logsyntax,$realPage."\n"); -mail($mainMail,"Chyba syntaxe http://skirogaining.tojnar.cz/$realPage","Nerozpoznan titulek a clanek"); + return $time; + } else { + return null; + } + } +} else { + header('HTTP/1.0 403 Forbidden'); + header('Location: /en/error/403'); } -fclose($logsyntax); -readPage("error/syntax"); -return false; -}elseif(empty($title)){ -$logsyntax=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("syntax.log"))){ -fwrite($logsyntax,$realPage."\n"); -mail($mainMail,"Chyba syntaxe http://skirogaining.tojnar.cz/$realPage","Nerozpoznan titulek"); -} -fclose($logsyntax); -readPage("error/syntax"); -return false; -}elseif(empty($article)){ -$logsyntax=fopen("syntax.log","a+"); -if(!ereg($realPage."\n",file_get_contents("syntax.log"))){ -fwrite($logsyntax,$realPage."\n"); -mail($mainMail,"Chyba syntaxe http://skirogaining.tojnar.cz/$realPage","Nerozpoznan clanek"); -} -fclose($logsyntax); -readPage("error/syntax"); -return false; -}else{ -return true; -} -} - -// string|null author(string $author) -function author($author){ -global $realPageType; -if($realPageType==0){ -if(empty($author)){ -return rplc("%unknownAuthor%"); -}else{ -return $author; -} -}else{ -return null; -} -} - -// string|null toDate(string $date) -function toDate($dateStr){ -if(!empty($dateStr)){ -$dateStr=explode(" ",$dateStr); -$dateStr=$dateStr[0]; -$dateStr=explode("-",$dateStr); -$year=$dateStr[0]; -$month=ltrim($dateStr[1],"0"); -$day=ltrim($dateStr[2],"0"); -return str_replace(array("%y%","%m%","%d%"),array($year,$month,$day),rplc("%date%")); -}else{ -return null; -} -} - -function isReleased($dateStr){ -$dateStr=explode(" ",$dateStr); -$dateStr=$dateStr[0]; -$dateStr=explode("-",$dateStr); -$year=$dateStr[0]; -$month=ltrim($dateStr[1],"0"); -$day=ltrim($dateStr[2],"0"); -$time=explode(" ",$dateStr); -$time=explode(":",$time[1]); -$hour=$time[0]; -$minute=$time[1]; -if(date("Y")>=$year){ -if(date("m")>=$month){ -if(date("d")>=$day){ -if(date("H")>=$hour){ -if(date("i")>=$minute){ -return true; -}else{ -return false; -} -}else{ -return false; -} -}else{ -return false; -} -}else{ -return false; -} -}else{ -return false; -} -} - -// string|null toTime(string $date) -function toTime($dateStr){ -if(!empty($dateStr)){ -$time=explode(" ",$dateStr); -$time=$time[1]; -return $time; -}else{ -return null; -} -} - -}else{ -header("HTTP/1.0 403 Forbidden"); -header("Location: /en/error/403"); -} -?> \ No newline at end of file diff --git a/sboard.php b/sboard.php index 3fe350a..da0f149 100644 --- a/sboard.php +++ b/sboard.php @@ -1,95 +1,106 @@ <?php -$sbnum=0; -if(0==9){ -header("HTTP/1.0 303 See Other"); + +$sbnum = 0; +if (0 == 9) { + header('HTTP/1.0 303 See Other'); } /** replaces bb tags on html -* @param string $buffer text with bb codes -* @return string replaced string -* @copyright Jan Tojnar, http://jtojnar.php5.cz/ -*/ -function bb2html($buffer){ -$buffer=ereg_replace("\[b\](.*)\[/b\]","<span class=\"bold\">\\1</span>",$buffer); -$buffer=ereg_replace("\[i\](.*)\[/i\]","<span class=\"italic\">\\1</span>",$buffer); -$buffer=ereg_replace("\[red\](.*)\[/red\]","<span class=\"red\">\\1</span>",$buffer); -$buffer=ereg_replace("\[green\](.*)\[/green\]","<span class=\"green\">\\1</span>",$buffer); -$buffer=ereg_replace("\[blue\](.*)\[/blue\]","<span class=\"blue\">\\1</span>",$buffer); -$buffer=ereg_replace("\[purple\](.*)\[/purple\]","<span class=\"purple\">\\1</span>",$buffer); -$buffer=ereg_replace("\[yellow\](.*)\[/yellow\]","<span class=\"yellow\">\\1</span>",$buffer); -$buffer=ereg_replace("%(.*)%","%\\1%",$buffer); -$buffer=ereg_replace("\n","<br>\n",$buffer); -$buffer=ereg_replace("\r\n","<br>\n",$buffer); -$buffer=ereg_replace("\r","<br>\n",$buffer); -return htmlspecialchars($buffer); + * @param string $buffer text with bb codes + * + * @return string replaced string + * + * @copyright Jan Tojnar, http://jtojnar.php5.cz/ + */ +function bb2html($buffer) { + $buffer = ereg_replace("\[b\](.*)\[/b\]", '<span class="bold">\\1</span>', $buffer); + $buffer = ereg_replace("\[i\](.*)\[/i\]", '<span class="italic">\\1</span>', $buffer); + $buffer = ereg_replace("\[red\](.*)\[/red\]", '<span class="red">\\1</span>', $buffer); + $buffer = ereg_replace("\[green\](.*)\[/green\]", '<span class="green">\\1</span>', $buffer); + $buffer = ereg_replace("\[blue\](.*)\[/blue\]", '<span class="blue">\\1</span>', $buffer); + $buffer = ereg_replace("\[purple\](.*)\[/purple\]", '<span class="purple">\\1</span>', $buffer); + $buffer = ereg_replace("\[yellow\](.*)\[/yellow\]", '<span class="yellow">\\1</span>', $buffer); + $buffer = ereg_replace('%(.*)%', '%\\1%', $buffer); + $buffer = ereg_replace("\n", "<br>\n", $buffer); + $buffer = ereg_replace("\r\n", "<br>\n", $buffer); + $buffer = ereg_replace("\r", "<br>\n", $buffer); + + return htmlspecialchars($buffer); } /** control e-mail address -* @param string $email e-mail address -* @return bool is right address syntax -* @copyright Jakub Vrána, http://php.vrana.cz -*/ -function check_email($email){ -$atom='[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; -$domain='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; -return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$",$email); + * @param string $email e-mail address + * + * @return bool is right address syntax + * + * @copyright Jakub Vrána, http://php.vrana.cz + */ +function check_email($email) { + $atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; + $domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; + + return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$", $email); } /** control www address -* @param string $url www address -* @return bool is right address syntax -* @copyright Jan Tojnar, http://jtojnar.php5.cz -*/ -function check_url($url){ -return eregi("^http[s]?://[-a-z0-9]*\.[-a-z0-9]+\.[a-z]+$",$url); + * @param string $url www address + * + * @return bool is right address syntax + * + * @copyright Jan Tojnar, http://jtojnar.php5.cz + */ +function check_url($url) { + return eregi("^http[s]?://[-a-z0-9]*\.[-a-z0-9]+\.[a-z]+$", $url); } /** returns text of shoutboard -* @param string $file page filename -* @return string shoutboard html -* @copyright Jan Tojnar, http://jtojnar.php5.cz/ -*/ -function sboard_generate($file){ -$sbnum++; -$name=htmlspecialchars($_POST["name"]); -$www=htmlspecialchars($_POST["www"]); -$post=htmlspecialchars($_POST["post"]); -$ip=$_SERVER["REMOTE_ADDR"]; -$timestamp=date(rplc("%dateFormat%")); -$formCaptchaSum=sha1($_POST["captcha"]); -$showmail=$_POST["showmail"]; -$checkedshowmailfalse=$showmail=="false"?" checked=\"checked\"":""; -$checkedshowmailtrue=empty($showmail)?" checked=\"checked\"":($showmail=="true"?" checked=\"checked\"":""); -if($showmail=="true"){ -$email=htmlspecialchars($_POST["email"]); -}else{ -$hemail=htmlspecialchars($_POST["email"]); -} -$formCaptchaSumPre=$_POST["captchasum"]; -$captcha=mt_rand(0,9).mt_rand(0,9).mt_rand(0,9).mt_rand(0,9); -$_SESSION["captcha"]=$captcha; -$captchasum=sha1($captcha); -#echo($timestamp); -#echo($post); -if(isset($_POST["post"])){ -if(empty($post)){ -$sbError.="<p>"."%misspost%"."</p>\n"; -} -if(empty($name)){ -$sbError.="<p>"."%missname%"."</p>\n"; -} -if($formCaptchaSumPre!=$formCaptchaSum){ -$sbError.="<p>"."%wrongcode%"."</p>\n"; -} -if(!empty($email) && !check_email($email)){ -$sbError.="<p>"."%wrongmail%"."</p>\n"; -} -if(!empty($www) && !check_url($www)){ -$sbError.="<p>"."%wrongwww%"."</p>\n"; -} -if(empty($sbError)){ -$sbmail=!empty($email)?"<span class=\"sbmail\"><span>{$email}</span></span>\n":(!empty($hemail)?"<hemail>{$hemail}</hemail>":""); -$sbwww=!empty($www)?"<span class=\"sbwww\"><span>{$www}</span></span>\n":""; -$post=bb2html($post); -$write=<<<EOT + * @param string $file page filename + * + * @return string shoutboard html + * + * @copyright Jan Tojnar, http://jtojnar.php5.cz/ + */ +function sboard_generate($file) { + ++$sbnum; + $name = htmlspecialchars($_POST['name']); + $www = htmlspecialchars($_POST['www']); + $post = htmlspecialchars($_POST['post']); + $ip = $_SERVER['REMOTE_ADDR']; + $timestamp = date(rplc('%dateFormat%')); + $formCaptchaSum = sha1($_POST['captcha']); + $showmail = $_POST['showmail']; + $checkedshowmailfalse = $showmail == 'false' ? ' checked="checked"' : ''; + $checkedshowmailtrue = empty($showmail) ? ' checked="checked"' : ($showmail == 'true' ? ' checked="checked"' : ''); + if ($showmail == 'true') { + $email = htmlspecialchars($_POST['email']); + } else { + $hemail = htmlspecialchars($_POST['email']); + } + $formCaptchaSumPre = $_POST['captchasum']; + $captcha = mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9); + $_SESSION['captcha'] = $captcha; + $captchasum = sha1($captcha); + //echo($timestamp); + //echo($post); + if (isset($_POST['post'])) { + if (empty($post)) { + $sbError .= '<p>' . '%misspost%' . "</p>\n"; + } + if (empty($name)) { + $sbError .= '<p>' . '%missname%' . "</p>\n"; + } + if ($formCaptchaSumPre != $formCaptchaSum) { + $sbError .= '<p>' . '%wrongcode%' . "</p>\n"; + } + if (!empty($email) && !check_email($email)) { + $sbError .= '<p>' . '%wrongmail%' . "</p>\n"; + } + if (!empty($www) && !check_url($www)) { + $sbError .= '<p>' . '%wrongwww%' . "</p>\n"; + } + if (empty($sbError)) { + $sbmail = !empty($email) ? "<span class=\"sbmail\"><span>{$email}</span></span>\n" : (!empty($hemail) ? "<hemail>{$hemail}</hemail>" : ''); + $sbwww = !empty($www) ? "<span class=\"sbwww\"><span>{$www}</span></span>\n" : ''; + $post = bb2html($post); + $write = <<<EOT <div class="sbcomment"> <div class="sbheader"> <span class="sbname">{$name}</span> @@ -101,23 +112,23 @@ $write=<<<EOT EOT; -$shoutfile=fopen($file."c".$sbnum,"a+"); -chmod($file."c".$sbnum,0777); -if(fwrite($shoutfile,$write)){ -$sbError.="<p>"."%saved%"."</p>\n"; -unset($name,$email,$www,$captcha,$post,$ip,$timestamp,$formCaptchaSum,$formCaptchaSumPre,$captchasum,$sbname,$sbdate,$sbwww,$sbmail); -fclose($shoutfile); -}else{ -$sbError.="<p>"."%notsaved%"."</p>\n"; -} -} -} -if(file_exists($file."c".$sbnum)){ -$comments=ereg_replace("<ip>([^<]+)</ip>","",ereg_replace("<hemail>([^<]+)</hemail>","",file_get_contents($file."c".$sbnum))); -}else{ -$comments=""; -} -$form=$comments."<hr class=\"sboard\" id=\"sboard{$sbnum}\">".(empty($sbError)?"":"<div class=\"sberrors\">".rplc($sbError)."</div>").<<<EOT + $shoutfile = fopen($file . 'c' . $sbnum, 'a+'); + chmod($file . 'c' . $sbnum, 0777); + if (fwrite($shoutfile, $write)) { + $sbError .= '<p>' . '%saved%' . "</p>\n"; + unset($name,$email,$www,$captcha,$post,$ip,$timestamp,$formCaptchaSum,$formCaptchaSumPre,$captchasum,$sbname,$sbdate,$sbwww,$sbmail); + fclose($shoutfile); + } else { + $sbError .= '<p>' . '%notsaved%' . "</p>\n"; + } + } + } + if (file_exists($file . 'c' . $sbnum)) { + $comments = ereg_replace('<ip>([^<]+)</ip>', '', ereg_replace('<hemail>([^<]+)</hemail>', '', file_get_contents($file . 'c' . $sbnum))); + } else { + $comments = ''; + } + $form = $comments . "<hr class=\"sboard\" id=\"sboard{$sbnum}\">" . (empty($sbError) ? '' : '<div class="sberrors">' . rplc($sbError) . '</div>') . <<<EOT <form method="post" action="#sboard{$sbnum}" class="sbform"> <div> <dl> @@ -135,6 +146,6 @@ $form=$comments."<hr class=\"sboard\" id=\"sboard{$sbnum}\">".(empty($sbError)?" %sbhelp% </div> EOT; -return $form; + + return $form; } -?> \ No newline at end of file diff --git a/sitemap.php b/sitemap.php index 015241d..6ff9216 100644 --- a/sitemap.php +++ b/sitemap.php @@ -1,30 +1,31 @@ -<?php -header("Content-Type: text/plain; charset=utf-8"); -function directoryToArray($directory,$recursive){ -$array_items=array(); -if($handle=opendir($directory)){ -while(false!==($file=readdir($handle))){ -if($file!="."&&$file!=".."){ -if(is_dir($directory."/".$file)){ -if($recursive){ -$array_items=array_merge($array_items,directoryToArray($directory. "/".$file,$recursive)); +<?php + +header('Content-Type: text/plain; charset=utf-8'); +function directoryToArray($directory, $recursive) { + $array_items = []; + if ($handle = opendir($directory)) { + while (false !== ($file = readdir($handle))) { + if ($file != '.' && $file != '..') { + if (is_dir($directory . '/' . $file)) { + if ($recursive) { + $array_items = array_merge($array_items, directoryToArray($directory . '/' . $file, $recursive)); + } + $file = $directory . '/' . $file; + } else { + $file = $directory . '/' . $file; + $array_items[] = preg_replace("/\/\//si", '/', $file); + } + } + } + closedir($handle); + } + + return $array_items; } -$file=$directory."/".$file; -}else{ -$file=$directory."/".$file; -$array_items[]=preg_replace("/\/\//si","/",$file); +$files = directoryToArray('./pages', true); +foreach ($files as $file) { + if (substr($file, -3) == '.pg' and (substr($file, 0, 17) != './pages/cs/error/' and substr($file, 0, 17) != './pages/en/error/' and substr($file, 0, 17) != './pages/de/error/')) { + $list .= substr($file, 0, -3) . "\n"; + } } -} -} -closedir($handle); -} -return $array_items; -} -$files=directoryToArray("./pages",true); -foreach($files as $file){ -if(substr($file,-3)==".pg" AND (substr($file,0,17)!="./pages/cs/error/" AND substr($file,0,17)!="./pages/en/error/" AND substr($file,0,17)!="./pages/de/error/")){ -$list.=substr($file,0,-3)."\n"; -} -} -echo(str_replace("./pages","http://".$_SERVER["HTTP_HOST"],$list)); -?> \ No newline at end of file +echo str_replace('./pages', 'http://' . $_SERVER['HTTP_HOST'], $list);