Hi,

I am using a one page script on my site, Its a directory indexer script & shows fancy directory of the site, its working fine but there is some problem in script.... its showing the directory/file structure in alphabetically sorting but I want it in Date wise sorting so It would show the latest updated folder/files first.

& also I will be very glad if you can add a more function in it..... It shows all the directory/files in one page.. I want that it should show specific item per page Example. 10 links in a page then there shold be a link-----> back/ next page.

I find many fancy ready script but since I am using this script for mobile xhtml website so I dont want more graphics.... if don't understand still then you can see it working live here: http://clicknenjoy.net/downloads/


<-------------------- SCRIPT ------------------------------->


<?php /*
PHP Directory Indexer
*/ ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta name="description" content="directory listing" />

<title></title>

<style type="text/css">

body { font-family: Tahoma, sans-serif; }

img { border: 0px;

margin-top: 6px; }

h2 { background-color: #eeeeee;

color: #c0c0c0;

letter-spacing: .2em;

padding: .2em;

text-align: center;

border-top: solid #aaaaaa 1px;

border-bottom: solid #aaaaaa 1px; }

table { border-collapse:
collapse;

margin-left: auto;

margin-right: auto;

margin-bottom: 10px;

border: solid #dddddd 1px; }

th { background-color: #dddddd; }

td { padding: 2px 10px 2px 10px;

background-color: #ffffff;

border: solid #dddddd 1px;}

a { text-decoration: none;
font-weight: bold; }
.black { color: #000000; }

</style>

</head>

<body>

<p align="center">
<img border="0" src="/image/clicknenjoy.net.gif" alt="clicknenjoy.net" width="165" height="40"></p>
<?php
// false - don't allow switching to the parent-directory of this script
// true - allow simple switching to the parent-directory (via 'href')

$allow_parent = "false";
$conf["items_per_page"] = 10;
$conf["dirs"] = array (
"."
," "
);

//configuration ends here---------------------------------------------------------------------------------------------------------------------------


//=======================================================================================
$path=$_GET["path"];
$SCRIPT_NAME=getenv("SCRIPT_NAME");
//put directory content in arrays-----------------------------------------------------------------------------------------------------------------
if (!isset($path)) { $path = "./"; }
if (!file_exists($path)) { echo "<h2>File not found!</h2>"; exit; }
if (strstr($path,"..")) { echo "<h2>invalid path!</h2>"; exit; }
$base_dir = getcwd();
chdir($path);
$current_dir = getcwd();
$directory = dir("./");
$directories_array = array();
$files_array = array();

while ($file = $directory->read()) {
if (is_dir($file) AND $file != ".") { $directories_array[] = $file; }

if (is_file($file)) { $files_array[] = $file; }
}
$directory->close();

//sort and output the arrays-----------------------------------------------------------------------------------------------------------------------
$get_sort_order = trim($_GET['order']);
$get_sort_by = trim($_GET['by']);
echo "<h2>Directory listing for <span class=\"black\">".basename($current_dir)."</span></h2>";
echo "<table>";

echo "<tr><th>Name</th><th>Size</th><th>Date</th></tr>";

sort($directories_array);
foreach($directories_array as $value) {
if ($value=="..") { $new_path=strrev(substr(strstr(substr(strstr(strrev($path),"/"),1),"/"),1)); }

else { $new_path=$path.$value; }

if (($value != "..") OR ($base_dir != $current_dir)) {
echo "<tr><td><a href=\"$SCRIPT_NAME?path=".urlencode($new_path."/")."\">$value</a><b></b></td><td></td><td>".gmdate("d M Y H:i",filemtime($value))."</td></tr>"; }
elseif ($allow_parent == "true") {
echo "<tr><td><a href=\"$value\">$value</a><b>/</b></td><td></td><td>".gmdate("d M Y H:i",filemtime($value))."</td></tr>"; }
}
sort($files_array);
foreach($files_array as $value) {
if($value != basename($SCRIPT_NAME) or $path!="./") {
$filesize=filesize($value);
if ($filesize > 1073741823) { $filesize = sprintf("%.1f",($filesize/1073741824))." GB"; }
elseif ($filesize > 1048575) { $filesize = sprintf("%.1f",($filesize/1048576))." MB"; }
elseif ($filesize > 1023) { $filesize = sprintf("%.1f",($filesize/1024))." kB"; }
else { $filesize = $filesize." byte"; }
echo "<tr><td><a href=\"$path$value\">$value</a></td><td>$filesize</td><td>".gmdate("d M Y H:i",filemtime($value))."</td></tr>";
}
}
echo "</table>";

//footer-----------------------------------------------------------------------------------------------------------------------------------------------------


?>
</body>
</html>

Regards,

Mayur