<?php
/************************************************
* *
* © Autor René Marscheider *
* © E-Mail:
webmaster@janaserver.de *
* © http://www.janaserver.de/ *
* © Bitte entfernen Sie diesen Vermerk nicht! *
* *
************************************************/
class show_dir
{
function file_date($file)
{
return date('d.m.Y H:i:s', filemtime($file));
}
function file_size($file)
{
$eg = filesize($file);
$la = strlen($eg);
$me = 'Bytes';
$nk = 0;
$ta = 0;
if ($la > 3 && $la <= 6)
{
$me = 'KB';
$nk = 2;
$ta = 1;
}
elseif ($la > 6 && $la <= 9)
{
$me = 'MB';
$nk = 2;
$ta = 2;
}
elseif ($la > 9)
{
$me = 'GB';
$nk = 2;
$ta = 3;
}
return number_format(($eg / pow(1024, $ta)), $nk, ',', '.') . ' ' . $me;
}
function dir_file($dir, $pos)
{
$dirs = dir($dir);
while ($file = $dirs->read())
{
if (is_dir($dir . '/' . $file) || preg_match('/(^' . basename($_SERVER['PHP_SELF']) . '$|^\.htaccess$|^\.htpasswd$)/i', $file))
continue;
printf('%' . $pos . 's <a href="javascript:page_view(\'' . str_replace($_SERVER['DOCUMENT_ROOT'], '', $dir . '/' . $file) . '\');">%s</a> '
. '| <span class="time">' . $this->file_date($dir . '/' . $file) . '</span> '
. '| <span class="gross">' . $this->file_size($dir . '/' . $file) . '</span>' . "\r\n", '|-', $file);
}
$dirs->close();
}
function show_dir($dir, $pos = 2, $start = 0)
{
if ($start == 0)
$this->dir_file($dir, $pos);
$dirs = dir($dir);
while ($file = $dirs->read())
{
if (is_file($dir . '/' . $file) || preg_match('/(^\.{1,2}$)/i', $file))
continue;
printf('%' . $pos . 's <span class="dir">%s</span>' . "\r\n", '|-', $file);
$this->dir_file($dir . '/' . $file, $pos + 2);
$this->show_dir($dir . '/' . $file, $pos + 2, 1);
}
$dirs->close();
}
}
/**/
echo '<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="content-language" content="de" />
<title>Directory</title>
<style type="text/css">
<!--
body
{
scrollbar-darkshadow-color: #e0e0f0;
scrollbar-3dlight-color: #e0e0f0;
scrollbar-highlight-color: #008;
scrollbar-track-color: #e0e0f0;
scrollbar-shadow-color: #008;
scrollbar-arrow-color: #d00;
scrollbar-face-color: #ccf;
background-color: #e0e0f0;
border-width: 0px;
overflow: auto;
margin: 10px;
}
pre
{
background-color: #eee;
border: 3px double #000;
padding: 10px;
}
a
{
text-decoration: none;
color: #007;
}
a:hover
{
color: #00f;
}
.dir
{
font-weight: bold;
color: #dc143c;
}
.time
{
color: #080;
}
.gross
{
color: #800;
}
//-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function page_view(url)
{
var dir_index = window.open(url, \'dir_index\', \'\');
dir_index.focus();
}
//-->
</script>
</head>
<body>
<pre>
';
/**/
new show_dir(getcwd());
/**/
echo '</pre>
</body>
</html>';
?>