<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>The Vault</title>

    <link rel="stylesheet" href="../style.css">
<script src="https://unpkg.com/cursor-effects@latest/dist/browser.js"></script>

<script>
window.addEventListener("load", (event) => {
  new cursoreffects.ghostCursor();
});
</script>

</head>

<body>
    <div class="container bio interests">
    <h1>✨️ The Vault ✨️</h1>
    <p>This is my public file dump, you can find here everything and nothing at the same time. I throw in here things that I either found on the internet, what some people have shared with me or some of my own inventions. Please use it accordingly, authors of the thingies are listed in README files.</p>
            <?php
                function listDirectoryContents($dir, $basePath = '') {
                    $items = array_diff(scandir($dir), array('..', '.', 'index.php'));
                    
                    if (empty($items)) {
                        return;
                    }
                    
                    // Separate directories and files
                    $directories = array();
                    $files = array();
                    
                    foreach ($items as $item) {
                        $fullPath = $dir . '/' . $item;
                        if (is_dir($fullPath)) {
                            $directories[] = $item;
                        } else {
                            $files[] = $item;
                        }
                    }
                    
                    // Sort both arrays
                    sort($directories);
                    sort($files);
                    
                    // Combine with directories first
                    $sortedItems = array_merge($directories, $files);
                    
                    echo '<ul>';
                    foreach ($sortedItems as $item) {
                        $fullPath = $dir . '/' . $item;
                        $isDir = is_dir($fullPath);
                        $icon = $isDir ? '📁 ' : '📄 ';
                        $link = htmlspecialchars($item);
                        $relativePath = $basePath ? $basePath . '/' . $item : $item;
                        
                        if ($isDir) {
                            echo "<li>{$icon}{$link}";
                            listDirectoryContents($fullPath, $relativePath);
                            echo "</li>";
                        } else {
                            $href = htmlspecialchars($relativePath);
                            echo "<li><a href=\"{$href}\" class=\"no-button\">{$icon}{$link}</a></li>";
                        }
                    }
                    echo '</ul>';
                }
                
                $currentDir = dirname(__FILE__);
                listDirectoryContents($currentDir);
            ?>
    </div>

    <footer>
        <p class="center"><img src="../favicon.ico">(c) computer_glamour</p>
        <img src="../buttons/-18.gif" class="footer-button">
        <img src="../buttons/xmpp.gif" class="footer-button">
        <img src="../buttons/notread.gif" class="footer-button">
        <img src="../buttons/right2repair.gif" class="footer-button">
    </footer>

</body>

</html>

