site/sitemap.php

42 lines
1.6 KiB
PHP

<?php
$title = "Sitemap | ~forero";
$language = "en";
include "layout/header.php";
?>
<div id="content">
<?php
function createTree($dir, $base_dir, $depth = 0) {
if (is_dir($dir)) {
$files = array_diff(scandir($dir), array('.', '..'));
echo str_repeat(' ', $depth) . "<ul>\n";
foreach($files as $file) {
$path = $dir . "/" . $file;
if (is_dir($path) && strpos($path, 'layout') === false) {
echo str_repeat(' ', $depth) . " <li>\n";
if (file_exists($path . "/index.php")) {
echo str_repeat(' ', $depth) . " <a href='" . substr($path, strlen($base_dir) + 1) . "/index.php'>" . $file . "</a>\n";
} else {
echo str_repeat(' ', $depth) . " " . $file . "\n";
}
createTree($path, $base_dir, $depth + 2);
echo str_repeat(' ', $depth) . " </li>\n";
} else {
if(strpos($path, 'layout') === false && $file!="default.php" && $file!="count.txt" && $file != "index.php"){
echo str_repeat(' ', $depth) . " <li>\n";
echo str_repeat(' ', $depth) . " <a href='".substr($dir, strlen($base_dir) + 1)."/".$file."'>".$file."</a>\n";
echo str_repeat(' ', $depth) . " </li>\n";
}
}
}
echo str_repeat(' ', $depth) . "</ul>\n";
}
}
createTree(__DIR__, getcwd());
?>
</div>
<?php include "layout/footer.php"; ?>