mám problém, stáhnul jsem si hotový výpis složky (
ukázka)
ale řadí se mi to podle názvu a já bych to potřeboval podle data aktualizace neumíte to někdo upravit? (neumím php)
<?php
////////////////////////////////////
$file = $_POST['file'];
if (isset ($file)) {
dnld ($file);
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1250' />
<title>Soubory ke stažení</title>
</head>
<body>
<?php
$dir = @opendir ('./');
echo "<h1>Soubory ke stažení</h1>";
////////////////////////// navigace
echo "<h2>";
$self = $_SERVER['PHP_SELF'];
$pole = explode("/", $self);
array_pop ($pole); // remove script name
array_shift ($pole); // remove leading slash
$host = $_SERVER["SERVER_NAME"];
$host = "http://" . $host . "/";
echo "<a href=$host>domů</a> ";
while (list (, $hodnota) = each ($pole)) {
$cesta .= "$hodnota" . "/";
// $odkaz = ">>> <a href="$host$cesta" . "index.php">$hodnota</a> ";
$odkaz = ">>> <a href="$host$cesta">$hodnota</a> ";
echo "$odkaz";
}
echo "</h2>";
///////////////////////// tabulka
echo "<table cellspacing='0'>";
echo "<tr><th>Číslo</th><th>Typ</th><th>Soubor</th><th>Bajtů</th><th>Aktual izace</th><th>Otevřít</th></tr>";
if (dir == false) exit ('Nelze otevřít složku.');
$arr = array ();
while (($file = readdir ($dir)) !== false) {
$ext = strrev ($file);
$pos = strpos ($ext, ".");
if ($pos === false) {
$ext = '';
}
else {
$ext = substr ($ext, 0, $pos);
$ext = strrev ($ext);
}
if (substr ($file, 0 ,1) != '.' && $file != 'index.php') {
$fileSize = filesize ($file);
$fileDate = date ("d/m/y H:i:s", filemtime($file));
$isDir = filetype ($file);
if ($isDir == 'dir') {
$isDir = " Složka ";
// $file .= '/'; //// ????
$ext = 'dir';
}
else
$isDir = " Soubor ";
$a = $isDir . '¬' . $file . '¬' . $fileSize . '¬' . $fileDate . '¬' . $ext;
$arr [] = $a;
}
}
natcasesort ($arr);
reset ($arr);
$klic = 0;
while (list (, $hodnota) = each ($arr)) {
list ($isDir, $file, $fileSize, $fileDate, $ext) = explode ('¬', $hodnota);
echo "<tr>";
$klic++;
echo "<td align=right>$klic</td>";
echo "<td>$isDir</td>";
echo" <td><b>$file</b></td>";
echo "<td align=right>$fileSize</td>";
echo "<td><b>$fileDate</b></td>";
echo "<td align=center>";
$file = rawurlencode($file); //// ????
if($ext == 'dir') $file .= '/'; //// ????
if (eregi ("^dir|rar|zip$", $ext)) {
echo "<a href="$file" . "index.php">$ext</a>";
}
else {
echo "
<form method=post action="$self">
<input type=hidden value="$file" name=file>
<input type=submit value="$ext" class=submit>
</form>";
}
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "<p>Celkem souborů: " . count ($arr);
closedir ($dir);
?>
</body>
</html>
<?php
exit;
////////////////////////////// download
function dnld ($file) {
header ("Content-Type: application/octet-stream");
header ("Content-Length: ".filesize($file));
header ("Content-Disposition: attachment; filename=$file");
readfile ($file);
} // end func
?>