Fix
This commit is contained in:
parent
c4265543d4
commit
5be1dac216
@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
require "lib/sitemap.php";
|
require "lib/account.php";
|
||||||
|
|
||||||
|
|
||||||
function generateSitemap(): string {
|
function generateSitemap(): string {
|
||||||
global $routerConfig;
|
global $routerConfig;
|
||||||
|
|
||||||
$site_dirs = array_diff(scandir($routerConfig["page_dir"]), array('.', '..'));
|
$site_dirs = array_diff(scandir($routerConfig["page_dir"]), array('.', '..'));
|
||||||
|
|
||||||
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
|
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
|
||||||
@ -14,14 +16,34 @@ function generateSitemap(): string {
|
|||||||
foreach ($pages_dir as $page_file) {
|
foreach ($pages_dir as $page_file) {
|
||||||
$page_file_tmp = explode(".", $page_file);
|
$page_file_tmp = explode(".", $page_file);
|
||||||
$page_basename = $page_file_tmp[0];
|
$page_basename = $page_file_tmp[0];
|
||||||
|
$page_file_path = $routerConfig["page_dir"] . $site_dir . "/" . $page_file;
|
||||||
$page_location = "/" . $site_dir . "/" . $page_basename;
|
$page_location = "/" . $site_dir . "/" . $page_basename;
|
||||||
|
|
||||||
|
if ($page_file_tmp[1] == "html") {
|
||||||
|
$page_tmp = file_get_contents($page_file_path);
|
||||||
|
|
||||||
|
$pageMetadata = parsePageTag($page_tmp);
|
||||||
|
|
||||||
|
if (!empty($pageMetadata["parameters"]["minimal_permission_level"])) {
|
||||||
|
$page_required_permission = intval($pageMetadata["parameters"]["minimal_permission_level"]);
|
||||||
|
} else {
|
||||||
|
$page_required_permission = $routerConfig["page"]["default_permissions"];
|
||||||
|
}
|
||||||
|
} elseif ($page_file_tmp[1] == "php") {
|
||||||
|
$page_required_permission = getDynamicPermission($page_file_path);
|
||||||
|
} else {
|
||||||
|
$page_required_permission = $routerConfig["page"]["default_permissions"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the user is authorized to access the page
|
||||||
|
if ($page_required_permission <= $_SESSION["privilege_level"]) {
|
||||||
$sitemap .= '<url>' . PHP_EOL;
|
$sitemap .= '<url>' . PHP_EOL;
|
||||||
$sitemap .= '<loc>' . htmlspecialchars($page_location) . '</loc>' . PHP_EOL;
|
$sitemap .= '<loc>' . htmlspecialchars($page_location) . '</loc>' . PHP_EOL;
|
||||||
// You can add other optional tags like lastmod, changefreq, priority here if needed
|
// You can add other optional tags like lastmod, changefreq, priority here if needed
|
||||||
$sitemap .= '</url>' . PHP_EOL;
|
$sitemap .= '</url>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sitemap .= '</urlset>' . PHP_EOL;
|
$sitemap .= '</urlset>' . PHP_EOL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user