Hi,
I have this scipt here,
and I want to add an ASort by TYPE and then by NAME
<?php
ini_set("max_execution_time", "300");
$rootpath = "c:";
if (empty($path)) {
$rootdir = $rootpath;
} else {
$rootdir = $path;
}
echo"<p><font face=\"Tahoma,Verdana,Arial,Helvetica\" size=\"2\" color=\"#000000\">$path</font></p>\n";
echo" <table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
$file_array = array();
if (is_dir($rootdir)) {
if (($handle = opendir($rootdir)) !== false) {
while (($filename = readdir($handle)) !== false) {
if ($filename != '.' && $filename != '..') {
$file_array[] = $filename;
}
}
} else {
echo "'" . $rootdir . "' could not be opened"; exit();
}
} else {
echo "'" . $rootdir . "' is not a directory"; exit();
}
if($handle = opendir("$rootdir")) $i=0;
if (is_array($file_array)) {
arsort($file_array);
{
while (false !== ($filename = readdir($handle))) {
$i++;
if ($filename != "." && $filename != "..") {
if ($i%2) { $bgcolorm="bgcolor=\"#DADFF7\""; } else { $bgcolorm="bgcolor=\"#B7BFE5\""; }
$myfiledate = date("d/m/Y H:i:s", filemtime("$rootdir/$filename"));
$myfilesize = filesize("$rootdir/$filename");
if($myfilesize >= 1073741824) {
$myyfilesize = number_format($myfilesize/1073741824,2,',','\'');
$myxfilesize = "$myyfilesize GB";
}
else {
if($myfilesize >= 1048576) {
$myyfilesize = number_format($myfilesize/1048576,2,',','\'');
$myxfilesize = "$myyfilesize MB";
}
else {
if($myfilesize >= 1024) {
$myyfilesize = number_format($myfilesize/1024,2,',','\'');
$myxfilesize = "$myyfilesize KB";
}
else {
if($myfilesize >= 1) {
$myyfilesize = number_format($myfilesize,2,',','\'');
$myxfilesize = "$myyfilesize B";
}
else {
if($myfilesize == 0) {
if(is_dir("$rootdir/$filename")) { $myxfilesize=""; } else { $myxfilesize="Empty"; }
}
else {
$myxfilesize="error";
}
}
}
}
}
$chopdot = explode(".", "$filename");
$renameext = str_replace(array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"),array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"),$chopdot[1]);
$myfileext = str_replace(array("acm","ani","avi","ax","bak","bat","bin","bkf","bmp","com","cfg","chm","cmd","cnt","cpl","css","cur","dat","dir","dll","doc","drv","exe","fla","gif","hlp","htm","html","ico","inc","inf","ini","iso","jpeg","jpg","log","mid","midi","mov","mp3","mp4","msg","msi","nrg","obd","oca","ocx","ocx","pdf","php","png","ppt","prx","psd","psp","rar","reg","scr","sql","swf","sys","tmp","ttf","txt","vbs","vxd","wav","wma","xls","xml","zip"),array("ACM File","Animated Cursor","Video Clip","AX File","Backup File","MS-DOS Batch File","BIN File","Microsoft Backup File","Windows Bitmap","MS-DOS Application","Microsoft Office Outlook Configuration File","Compiled HTML Help File","Windows NT Command Script","CNT File","Control Panel Extension","Cascading Style Sheet Document","Cursor","DAT File","Folder","Application Extension","Microsoft Word Document","Device Driver","Applications","Flash Document","GIF Image","Help File","HTML Document","HTML Document","Icon","Include File","Setup Information","Configuration Settings","ISO Image File","JPEG Image","JPEG Image","Log File","MIDI Sequence","MIDI Sequence","QuickTime Movie","MP3 Audio File","MP4 Audio File","Email Message","Windows Installer Package","Nero Project","Microsoft Binder","OCA File","ActiveX Control","OCX File","Adobe Acrobat Document","Hypertext Preprocessor","PNG Image","Microsoft PowerPoint Presentation","Windows Media Profile","Adobe Photoshop Image","Paint Shop Pro Image","WinRAR Archive","Registry File","Screen Saver","SQL File","Flash Movie","System File","Temp File","True Type Font","Text Document","VBScript Script File","Virtual Device Driver","Wave Sound","Microsoft Windows Media Audio","Microsoft Excel Worksheet","XML Document","Zip File Archive"),$renameext);
if($filename=="ntldr") { $myfileext="System File"; }
if(is_dir("$rootdir/$filename")) { $myfileext="Folder"; }
echo "
<tr $bgcolorm>
<td><font face=\"Tahoma,Verdana,Arial,Helvetica\" size=\"2\" color=\"#000000\"><a href=\"$PHP_SELF?path=$rootdir/$filename&prepath=$filename\">$filename</a></font></td>
<td align=\"right\"><font face=\"Tahoma,Verdana,Arial,Helvetica\" size=\"2\" color=\"#000000\">$myxfilesize</font></td>
<td><font face=\"Tahoma,Verdana,Arial,Helvetica\" size=\"2\" color=\"#000000\">$myfileext</font></td>
<td><font face=\"Tahoma,Verdana,Arial,Helvetica\" size=\"2\" color=\"#000000\">$myfiledate</font></td>
</tr>\n";
}
}
closedir($handle);
}}
echo" </table>";
?>