Skip to content

Instantly share code, notes, and snippets.

@Phlow
Last active November 22, 2024 14:43
Show Gist options
  • Save Phlow/42c48e046e74ed197b8d to your computer and use it in GitHub Desktop.
Save Phlow/42c48e046e74ed197b8d to your computer and use it in GitHub Desktop.
Dateien innerhalb eines Verzeichnisses ausgeben
<!doctype html>
<html class="no-js" lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index</title>
<style type="text/css">
body,html {
margin: 0;
padding: 0;
font-family: 'Neue Helvetica', Arial, sans-serif;
}
a {
color: #0085ba;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
nav {
border-bottom: 1px solid #000;
padding: 8px 0 0 30px;
margin: 0 0 30px 0;
height: 42px;
width: 100%;
}
#logo {
display:block;
background-repeat: no-repeat;
width: 128px;
height: 31px;
background-image: url('data:image/svg+xml;base64,PHN2ZyBpZD0icGhsb3ciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHZpZXdCb3g9IjAgMCAyMjguNTQgNTEuODgiPjxkZWZzPjxzdHlsZT4uY2xzLTN7c3Ryb2tlLXdpZHRoOjA7ZmlsbDojMDAwMDAwfTwvc3R5bGU+PGNsaXBQYXRoIGlkPSJjbGlwcGF0aCI+PHJlY3QgeD0iMCIgd2lkdGg9IjIyOC41NCIgaGVpZ2h0PSI1MS44OCIgc3Ryb2tlLXdpZHRoPSIwIiBmaWxsPSJub25lIi8+PC9jbGlwUGF0aD48L2RlZnM+PHBvbHlnb24gY2xhc3M9ImNscy0zIiBwb2ludHM9IjIwOS4wNCAwIDE4NS40MSA1MS4wNyAyMDQuOSA1MS4wNyAyMjguNTQgMCAyMDkuMDQgMCIvPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwcGF0aCkiPjxwYXRoIGNsYXNzPSJjbHMtMyIgZD0iTTc2LjQyLDQ0LjIyaC00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QtLjQ0LjE1LS43Mi4xNy0uOTMuMDItLjIxLjA0LS40NS4wNC0uNzIiLz48cGF0aCBjbGFzcz0iY2xzLTMiIGQ9Ik0xNy4zOCw3LjczaDEwLjgzYzEuNzksMCwzLjA5LjQsMy45LDEuMjEuOC44MSwxLjIxLDEuODEsMS4yMSwzLDAsLjQxLS4wOC45Ny0uMjQsMS42Ni0uMTYuNjktLjM2LDEuNjMtLjU5LDIuODMtLjM3LDEuODktMS4xOCwzLjI5LTIuNDUsNC4yMS0xLjI3LjkyLTIuNzcsMS4zOC00LjUyLDEuMzhoLTExLjA0bDIuOS0xNC4yOFpNOC42OSw1MS4wNGw0LjI3LTIxLjNoMTEuMzhjMi42NywwLDUuMDktLjQyLDcuMjgtMS4yOCwyLjE4LS44NSw0LjA3LTIuMDMsNS42Ni0zLjU1LDEuNTktMS41MiwyLjgyLTMuMzMsMy42OS01LjQ1Ljg3LTIuMTIsMS4zMS00LjQ0LDEuMzEtNi45NywwLTMuODYtMS4yMS02LjkxLTMuNjItOS4xNC0yLjQyLTIuMjMtNS45NC0zLjM1LTEwLjU5LTMuMzVIMTAuMjFMMCw1MS4wNGg4LjY5WiIvPjwvZz48L3N2Zz4=');
}
h2 {
font-weight: normal;
font-size: 2.5em;
margin: 10px 0 10px 0;
}
#wrapper {
padding: 0px 30px;
}
ul {
margin: 0;
padding: 0 0 0 20px;
}
li {
line-height: 1.5em;
}
footer {
height: 180px;
}
</style>
</head>
<body>
<nav>
<a id="logo" class="top" href="http://phlow.de/"></a>
</nav>
<div id="wrapper">
<?php
// Bau die URL zur Datei auf
// http://stackoverflow.com/questions/3429262/get-base-directory-of-current-script
$url = $_SERVER['REQUEST_URI']; //returns the current URL
$parts = explode('/',$url);
$directory = $_SERVER['SERVER_NAME'];
for ($i = 0; $i < count($parts) - 1; $i++) {
$directory .= $parts[$i] . "/";
}
// zeigt alle Dateien und Ordner an.
$dir = @opendir("."); //aktuelles Verzeichnis öffnen
$array = array();
$array_dirs = array();
while( $file = @readdir($dir) )
{
//Filtert jetzt auch alle .htaccess und index.php
if( $file != '.' && $file != '..' && $file !=".htaccess" && $file !="index.php" && $file !="x.php" )
{
if( is_dir($file) ) {
array_push($array_dirs, $file);
} else {
array_push($array, $file);
}
}
}
@closedir($dir);
natcasesort($array);
natcasesort($array_dirs);
?>
<h2>Data</h2>
<ul>
<?php // gibt alle Files aus
while($file = array_shift($array) ) {
echo ' <li><a href=' .$file. '>'. $directory . $file.'</a></li>'. "\xA";
} ?>
</ul>
<footer>
<p><small>&copy; by Phlow Media 2000-<?php echo date('Y'); ?></small></p>
</footer>
</div><!-- /#wrapper -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment