<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body { background-color:#f1facc; }
* { color:black; font-size:12pt; font-family:'NotoSansMono-Regular'; }
td { padding-right:24px; }
@font-face { font-family:'NotoSansMono-Regular'; src:url('https://cardimg.com/fonts/Noto_Sans_Mono/static/NotoSansMono-Regular.ttf'); }
</style>
</head>
<body>
<?php
if(isset($_GET['text'])){ //Show a custom decoration text file
$filename = $_GET['text'];
$content = file_get_contents($filename);
if($content !== false){
echo "<p>";
$content = htmlspecialchars($content);
$newString = preg_replace("/\n/", "<br />", $content);
$newString = preg_replace("/\t/", " ", $newString);
echo $newString;
echo "</p>";
}else{
echo "Error: Could not read the file.";
}
}else{
$currentDirectory = getcwd();
$directory_path = $currentDirectory; // Replace with your directory path
echo "<p>" . substr($directory_path, strlen("/var/www/html/")) . "</p>";
$dir = $currentDirectory;
$files = scandir($dir);
// Remove the '.' and '..' entries from the array
$files = array_diff($files, ['.', '..', 'index.php']);
// Sort the files by last modified time (newest first)
usort($files, function($a, $b) use ($dir) {
return filemtime("$dir/$b") - filemtime("$dir/$a");
});
//globe: 🌐
echo "<table>";
if($directory_path != "/var/www/html/howeverwhich.com") $parent_directory = true;
if($parent_directory){
echo "<tr><td><a href=\"..\">[Go Up One Directory]</a></td></tr>";
}
$file_name_suffixes = [".png", ".zip", ".html", ".jpg", ".jpeg", "_url.xml"];
function file_name_suffix($filename){
//This should not need to use mb_strlen because a file type suffix will not usually contain multi-byte characters, such as French or Chinese.
if(strcasecmp($file_name_suffixes[$i], substr($filename, 0-strlen($file_name_suffixes[$i])) == 0) /* Uppercase and lowercase are irrelevant. The segment of the file name contains a suffix. */ return $suffix;
}
foreach ($files as $filename) {
$is_directory = is_dir($dir . "/" . $filename);
//The file is a directory.
if($is_directory) $append = "/"; else $append = "";
if($is_directory){
echo "<tr><td><a href=\"" . $filename . "\">" . $filename . $append . "</a></td>" . "<td>" . date('Y-m-d H:i:s', filemtime("$dir/$filename")) . "</td></tr>";
//The file name suffix is relevant.
switch(file_name_suffix($filename)){
//[Left off: Tue Oct 14 12:39:37 AM EDT 2025]
}
}else if(substr($filename, -4) == ".png"){
echo "<tr><td><a href=\"" . $filename . "\">" . $filename . $append . "</a></td>" . "<td>" . date('Y-m-d H:i:s', filemtime("$dir/$filename")) . "</td></tr>";
// Show text for all files except (and what was not included in previous list):
}else if(substr($filename, -4) != ".zip" && substr($filename, -5) != ".html" && substr($filename, -4) != ".jpg" && substr($filename, -5) != ".jpeg"){
echo "<tr><td><a href=\"index.php?text=" . urlencode($filename) . "\">" . $filename . "</a></td>" . "<td>" . date('Y-m-d H:i:s', filemtime("$dir/$filename")) . "</td></tr>";
}else{
echo "<tr><td><a href=\"" . $filename . "\">" . $filename . $append . "</a></td>" . "<td>" . date('Y-m-d H:i:s', filemtime("$dir/$filename")) . "</td></tr>";
}
}
echo "</table>";
}
?>
</body>
</html>