meilon
Erfahrenes Mitglied
Hi,
Da mir das schnöde Directorylisting von meinem Apache-Server zu langwilig aussah, wollte ich mir das ma selber bauen.
Soweit ist auch schon alles fertig. Nur selber sortieren kann man nicht. Und da weiß ich nicht weiter. Hier erstmal mein Code (ist jetzt logisch mit fast keinen schöhnmachern )
Das mit dem einblenden und ausblenden ist nur ein selbstgebautes QuickInfo.
Ich weiß nun nicht, wie ich das neusortieren nach Datum machen kann. Irgendwie muss das ja eine neues, mehrdimensionales Array werden, nur wie? Und wie das dann sortiert werden soll, will ich versuchen mir selbst zu erfummeln.
Bitte helft
mfg
Da mir das schnöde Directorylisting von meinem Apache-Server zu langwilig aussah, wollte ich mir das ma selber bauen.
Soweit ist auch schon alles fertig. Nur selber sortieren kann man nicht. Und da weiß ich nicht weiter. Hier erstmal mein Code (ist jetzt logisch mit fast keinen schöhnmachern )
PHP:
<?php
function cmp($a, $b) {
return strcmp(strtolower($a), strtolower($b));
}
$content = scandir("/opt/lampp/htdocs/dir");
unset($content[0]);
unset($content[1]);
unset($content[2]);
unset($content[array_search("index.php", $content)]);
unset($content[array_search("dirlist.php", $content)]);
unset($content[array_search(".htaccess", $content)]);
usort($content, "cmp");
echo "<tr>
<td style='border-bottom-style: solid; border-bottom-width: 1; border-color: #000000'>#</td>
<td style='border-bottom-style: solid; border-bottom-width: 1; border-color: #000000'>Name</td>
<td style='border-bottom-style: solid; border-bottom-width: 1; border-color: #000000'>Größe</td>
<td style='border-bottom-style: solid; border-bottom-width: 1; border-color: #000000'>Datum</td>
<td style='border-bottom-style: solid; border-bottom-width: 1; border-color: #000000'>Rechte</td>
</tr>";
function DownloadSize($file) {
$size = @filesize($file);
$sizes = Array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');
$ext = $sizes[0];
for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) {
$size = $size / 1024;
$ext = $sizes[$i];
}
return round($size, 2).$ext;
}
for ($i = 0; $i <= count($content)-1; $i++) {
$filename = $content[$i];
$filesize = DownloadSize($content[$i]);
if ($filesize == "0B") {
$filesize = "2GB+";
$info1 = 'einblenden(\'info\', \'<font size=-1><font color=#FF0000><b>Achtung:</b></font> Die Datei '.$filename.' lässt sich wegen<br>ihrer größe von über 2GB nicht downloaden! Also ignorieren Sie einfach den Link.</font>\');';
$info2 = 'ausblenden(\'info\');';
} else {
$info1 = '';
$info2 = '';
}
$filedate = date("d.m.Y H:i",@filemtime($content[$i]));
if ($filedate == "01.01.1970 01:00") $filedate = "unbekannt";
$fileperm = substr(sprintf('%o', @fileperms($content[$i])), -4);
if ($fileperm == "0") $fileperm = "unbekannt";
echo '<tr id="'.$i.'" onmousemove="an(\''.$i.'\');'.$info1.'" onmouseout="aus(\''.$i.'\');'.$info2.'">
<td>'.$i.'</td>
<td><a href="'.$filename.'">'.$filename.'</a></td>
<td>'.$filesize.'</td>
<td>'.$filedate.'</td>
<td>'.$fileperm.'</td></tr>';
}
//}
?>
Ich weiß nun nicht, wie ich das neusortieren nach Datum machen kann. Irgendwie muss das ja eine neues, mehrdimensionales Array werden, nur wie? Und wie das dann sortiert werden soll, will ich versuchen mir selbst zu erfummeln.
Bitte helft
mfg