--- /dev/null
+<?php
+// Set the current directory
+$dir = ".";
+
+// Get the full path for the current directory
+$currentPath = realpath($dir);
+$baseDir = realpath(dirname(__FILE__)); // Get the base directory path
+$relativePath = str_replace($baseDir, '', $currentPath); // Get the relative path
+$relativePath = trim($relativePath, '/'); // Trim leading and trailing slashes
+
+// Construct the full path for the title
+if (empty($relativePath)) {
+ $fullPath = basename($baseDir); // This will be "files" when in the root
+} else {
+ $fullPath = basename($baseDir) . '/' . $relativePath; // This will be "files/bg_music" or similar
+}
+
+// If the relative path is not empty, prepend a slash
+if (!empty($relativePath)) {
+ $fullPath = basename($baseDir) . '/' . $relativePath;
+}
+
+if ($handle = opendir($dir)) {
+ echo "<html>";
+ echo "<head><title>Index of /$fullPath</title></head>";
+ echo "<body>";
+ echo "<h1>Index of /$fullPath</h1><hr><pre>";
+ echo '<a href="../">../</a>' . PHP_EOL;
+
+ $items = [];
+ while (false !== ($entry = readdir($handle))) {
+ // Skip the current and parent directory entries and index.php
+ if ($entry != "." && $entry != ".." && $entry != "index.php") {
+ $items[] = $entry;
+ }
+ }
+ closedir($handle);
+
+ sort($items);
+
+ foreach ($items as $entry) {
+ $filePath = $dir . "/" . $entry;
+ $lastModified = date("d-M-Y H:i", filemtime($filePath));
+ $size = is_dir($filePath) ? "-" : filesize($filePath);
+ $link = htmlspecialchars($entry);
+
+ // Check if it's a directory and add a trailing slash
+ if (is_dir($filePath)) {
+ $link .= '/'; // Add trailing slash for directories
+ }
+
+ echo "<a href=\"$entry\">$link</a>" . str_repeat(" ", 50 - strlen($link)) . "$lastModified" . str_repeat(" ", 10 - strlen($size)) . "$size" . PHP_EOL;
+ }
+
+ echo "</pre><hr>";
+ echo "</body>";
+ echo "</html>";
+} else {
+ echo "Unable to open directory.";
+}
+?>
--- /dev/null
+<?php
+// Set the current directory
+$dir = ".";
+
+// Get the full path for the current directory
+$currentPath = realpath($dir);
+$baseDir = realpath(dirname(__FILE__)); // Get the base directory path
+$relativePath = str_replace($baseDir, '', $currentPath); // Get the relative path
+$relativePath = trim($relativePath, '/'); // Trim leading and trailing slashes
+
+// Construct the full path for the title
+if (empty($relativePath)) {
+ $fullPath = basename($baseDir); // This will be "files" when in the root
+} else {
+ $fullPath = basename($baseDir) . '/' . $relativePath; // This will be "files/bg_music" or similar
+}
+
+// If the relative path is not empty, prepend a slash
+if (!empty($relativePath)) {
+ $fullPath = basename($baseDir) . '/' . $relativePath;
+}
+
+if ($handle = opendir($dir)) {
+ echo "<html>";
+ echo "<head><title>Index of /$fullPath</title></head>";
+ echo "<body>";
+ echo "<h1>Index of /$fullPath</h1><hr><pre>";
+ echo '<a href="../">../</a>' . PHP_EOL;
+
+ $items = [];
+ while (false !== ($entry = readdir($handle))) {
+ // Skip the current and parent directory entries and index.php
+ if ($entry != "." && $entry != ".." && $entry != "index.php") {
+ $items[] = $entry;
+ }
+ }
+ closedir($handle);
+
+ sort($items);
+
+ foreach ($items as $entry) {
+ $filePath = $dir . "/" . $entry;
+ $lastModified = date("d-M-Y H:i", filemtime($filePath));
+ $size = is_dir($filePath) ? "-" : filesize($filePath);
+ $link = htmlspecialchars($entry);
+
+ // Check if it's a directory and add a trailing slash
+ if (is_dir($filePath)) {
+ $link .= '/'; // Add trailing slash for directories
+ }
+
+ echo "<a href=\"$entry\">$link</a>" . str_repeat(" ", 50 - strlen($link)) . "$lastModified" . str_repeat(" ", 10 - strlen($size)) . "$size" . PHP_EOL;
+ }
+
+ echo "</pre><hr>";
+ echo "</body>";
+ echo "</html>";
+} else {
+ echo "Unable to open directory.";
+}
+?>
-
-<!DOCTYPE html>
-<html>
- <head>
- <style>
- table td {
- padding:4px;
- }
- </style>
- <title>Index of /files/</title>
- </head>
- <body>
- <h1>Index of /files/</h1>
-
- <table>
- <th>Name</th><th>Size</th><th>Date Modified</th>
-
- <tr>
- <td><a href="../">../</a></td>
- <td></td>
- <td></td>
- </tr>
-
- <tr>
- <td><a href="\files\90279.jpg">90279.jpg</a></td>
- <td>222.8 kB</td>
- <td>3/24/25, 19:16:28</td>
- </tr>
-
- <tr>
- <td><a href="\files\ascent.jpg">ascent.jpg</a></td>
- <td>45.0 kB</td>
- <td>3/24/25, 19:20:25</td>
- </tr>
-
- <tr>
- <td><a href="\files\autumn.avif">autumn.avif</a></td>
- <td>237.4 kB</td>
- <td>3/24/25, 19:17:35</td>
- </tr>
-
- <tr>
- <td><a href="\files\azul.jpg">azul.jpg</a></td>
- <td>83.9 kB</td>
- <td>3/24/25, 19:20:10</td>
- </tr>
-
- <tr>
- <td><a href="\files\Bliss_(Windows_XP).png">Bliss_(Windows_XP).png</a></td>
- <td>107.3 kB</td>
- <td>3/24/25, 19:14:58</td>
- </tr>
-
- <tr>
- <td><a href="\files\childhood2.mp3">childhood2.mp3</a></td>
- <td>1.6 MB</td>
- <td>3/24/25, 19:58:44</td>
- </tr>
-
- <tr>
- <td><a href="\files\rejectedworld.mp3">rejectedworld.mp3</a></td>
- <td>1.4 MB</td>
- <td>3/24/25, 19:58:44</td>
- </tr>
-
- </table>
- </body>
-
- <script data-goatcounter="https://bochard.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
-</html>
+<?php
+// Set the current directory
+$dir = ".";
+
+// Get the full path for the current directory
+$currentPath = realpath($dir);
+$baseDir = realpath(dirname(__FILE__)); // Get the base directory path
+$relativePath = str_replace($baseDir, '', $currentPath); // Get the relative path
+$relativePath = trim($relativePath, '/'); // Trim leading and trailing slashes
+
+// Construct the full path for the title
+if (empty($relativePath)) {
+ $fullPath = basename($baseDir); // This will be "files" when in the root
+} else {
+ $fullPath = basename($baseDir) . '/' . $relativePath; // This will be "files/bg_music" or similar
+}
+
+// If the relative path is not empty, prepend a slash
+if (!empty($relativePath)) {
+ $fullPath = basename($baseDir) . '/' . $relativePath;
+}
+
+if ($handle = opendir($dir)) {
+ echo "<html>";
+ echo "<head><title>Index of /$fullPath</title></head>";
+ echo "<body>";
+ echo "<h1>Index of /$fullPath</h1><hr><pre>";
+ echo '<a href="../">../</a>' . PHP_EOL;
+
+ $items = [];
+ while (false !== ($entry = readdir($handle))) {
+ // Skip the current and parent directory entries and index.php
+ if ($entry != "." && $entry != ".." && $entry != "index.php") {
+ $items[] = $entry;
+ }
+ }
+ closedir($handle);
+
+ sort($items);
+
+ foreach ($items as $entry) {
+ $filePath = $dir . "/" . $entry;
+ $lastModified = date("d-M-Y H:i", filemtime($filePath));
+ $size = is_dir($filePath) ? "-" : filesize($filePath);
+ $link = htmlspecialchars($entry);
+
+ // Check if it's a directory and add a trailing slash
+ if (is_dir($filePath)) {
+ $link .= '/'; // Add trailing slash for directories
+ }
+
+ echo "<a href=\"$entry\">$link</a>" . str_repeat(" ", 50 - strlen($link)) . "$lastModified" . str_repeat(" ", 10 - strlen($size)) . "$size" . PHP_EOL;
+ }
+
+ echo "</pre><hr>";
+ echo "</body>";
+ echo "</html>";
+} else {
+ echo "Unable to open directory.";
+}
+?>