Fix sitemap
Most importantly, make it work globally.
This commit is contained in:
@@ -5,4 +5,6 @@
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ /2015-prosinec [R=302]
|
||||
RewriteRule ^$ /2015-prosinec [R=302,L]
|
||||
RewriteRule ^/sitemap.php$ [F]
|
||||
RewriteRule ^sitemap\.txt$ /sitemap.php
|
||||
|
||||
@@ -9,7 +9,6 @@ RewriteRule ^de$ /2010/de/ [R,QSA]
|
||||
RewriteRule ^cs/$ /2010/index.php?page=main&lang=cs [QSA]
|
||||
RewriteRule ^en/$ /2010/index.php?page=main&lang=en [QSA]
|
||||
RewriteRule ^de/$ /2010/index.php?page=main&lang=de [QSA]
|
||||
RewriteRule ^/sitemap\.txt$ /2010/sitemap.php
|
||||
RewriteRule (.*)\.pg$ [F]
|
||||
RewriteRule (.*)\.pgc[1-9]$ [F]
|
||||
RewriteRule (.*)\.mn$ [F]
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
$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);
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
$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);
|
||||
@@ -9,7 +9,6 @@ RewriteRule ^de$ /2012/de/ [R,QSA]
|
||||
RewriteRule ^cs/$ /2012/index.php?page=main&lang=cs [QSA]
|
||||
RewriteRule ^en/$ /2012/index.php?page=main&lang=en [QSA]
|
||||
RewriteRule ^de/$ /2012/index.php?page=main&lang=de [QSA]
|
||||
RewriteRule ^/sitemap\.txt$ /sitemap.php
|
||||
RewriteRule (.*)\.pg$ [F]
|
||||
RewriteRule (.*)\.pgc[1-9]$ [F]
|
||||
RewriteRule (.*)\.mn$ [F]
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
$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);
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
$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);
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
$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);
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
$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);
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
if ($included !== true) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
header('Location: /en/error/403');
|
||||
exit;
|
||||
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 {
|
||||
|
||||
26
sitemap.php
Normal file
26
sitemap.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/load.lib.php';
|
||||
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
|
||||
$directory = new \RecursiveDirectoryIterator('.');
|
||||
$filter = new class($directory) extends \RecursiveFilterIterator {
|
||||
public function accept() {
|
||||
$components = explode('/', $this->current()->getPathname(), 4);
|
||||
return ($this->current()->isDir() && !isset($components[2])) || (isset($components[2]) && $components[2] === 'pages');
|
||||
}
|
||||
};
|
||||
$iterator = new \RecursiveIteratorIterator($filter);
|
||||
|
||||
$isHttps = isHttps();
|
||||
foreach ($iterator as $info) {
|
||||
if ($info->isFile()) {
|
||||
[, $year, $pages, $page] = explode('/', $info->getPathname(), 4);
|
||||
if (str_ends_with($page, '.pg') && !str_starts_with($page, 'cs/error/') && !str_starts_with($page, 'en/error/') && !str_starts_with($page, 'de/error/')) {
|
||||
$file = substr($page, 0, -3);
|
||||
$file = str_replace('/pages', '', $file);
|
||||
echo ($isHttps ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . $year . '/' . $file . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user