[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5463 - trunk/www/web/shared
From: |
jcater |
Subject: |
r5463 - trunk/www/web/shared |
Date: |
Mon, 22 Mar 2004 13:24:06 -0600 (CST) |
Author: jcater
Date: 2004-03-22 13:24:05 -0600 (Mon, 22 Mar 2004)
New Revision: 5463
Modified:
trunk/www/web/shared/_listdir.php
Log:
added 'sort by file's date' option to _listdir; updated the download pages
Modified: trunk/www/web/shared/_listdir.php
===================================================================
--- trunk/www/web/shared/_listdir.php 2004-03-22 18:28:05 UTC (rev 5462)
+++ trunk/www/web/shared/_listdir.php 2004-03-22 19:24:05 UTC (rev 5463)
@@ -4,125 +4,69 @@
# lists the files in sub-directory $dir
# split by file type (*.tar.gz, *.zip and *.exe)
#
+# Expects to be passed $dir and $sortby (date|name)
+#
-# .tar.gz files
-
-$handle = opendir( $dir ) ;
-$notyet = true ;
-
-$close = "";
-while ( $entry = readdir($handle) )
- {
- if ( strpos ( $entry, "tar.gz" ) )
+function getFilesByDate($ext, $dir) {
+ $temp=array();
+ if ($handle = opendir($dir))
+ {
+ $lasttime=0;
+ while (false !== ($file = readdir($handle)))
{
- if ( $notyet )
- {
- $notyet = false ;
- echo "<h3>Source files (*.tar.gz format)</h3>\n<ul>" ;
- $close="</ul>";
+ if ( strpos ( $file, $ext ) ) {
+ if(is_file("$dir/$file"))$temp[$file]=filemtime("$dir/$file");
}
- echo "<li><a href=\"$dir/$entry\">" ;
- echo $entry . "</a></li>\n" ;
}
- }
-echo "$close";
+ closedir($handle);
+ }
+ ksort($temp);
+ arsort($temp,SORT_NUMERIC);
+ reset($temp);
+ $rv=array();
+ while(list($k,$v)=each($temp))
+ $rv[] = $k;
+ return $rv;
+}
-closedir($handle);
-
-# .deb files
-
-$handle=opendir( $dir ) ;
-$notyet = true ;
-
-$close="";
-while ( $entry = readdir($handle) )
- {
- $close="";
- if ( strpos ( $entry, ".deb" ) )
+function getFilesByName($ext, $dir) {
+ $temp=array();
+ if ($handle = opendir($dir))
+ {
+ while (false !== ($file = readdir($handle)))
{
- if ( $notyet )
- {
- $notyet = false ;
- echo "<h3>Debian GNU/Linux packages (*.deb format)</h3><ul>\n" ;
- $close="</ul>";
- }
- echo "<li><a href=\"$dir/$entry\">" ;
- echo $entry . "</a></li>\n" ;
+ if ( strpos ( $file, $ext ) )
+ $temp[] = $file;
}
- }
-echo "$close";
+ closedir($handle);
+ }
+ sort($temp);
+ return $temp;
+}
-closedir($handle);
+function handleFileType($ext, $descr, $dir, $sortby) {
+ $notyet = true;
+ $close = "";
+ if ("$sortby" == "date")
+ $files = getFilesByDate($ext, $dir);
+ else
+ $files = getFilesByName($ext, $dir);
+ foreach ($files as $file) {
+ if ( $notyet )
+ {
+ $notyet = false ;
+ echo "<h3>$descr (*.$ext format)</h3><ul>\n" ;
+ $close="</ul>";
+ }
+ echo "<li><a href=\"$dir/$file\">" ;
+ echo $entry . "</a></li>\n" ;
+ }
+ echo "$close\n";
-# .rpm files
+}
-$handle=opendir( $dir ) ;
-$notyet = true ;
-
-$close="";
-while ( $entry = readdir($handle) )
- {
- $close="";
- if ( strpos ( $entry, ".rpm" ) )
- {
- if ( $notyet )
- {
- $notyet = false ;
- echo "<h3>GNU/Linux RPM packages (*.rpm format)</h3><ul>\n" ;
- $close="</ul>";
- }
- echo "<li><a href=\"$dir/$entry\">" ;
- echo $entry . "</a></li>\n" ;
- }
- }
-echo "$close";
-
-closedir($handle);
-
-# .zip files
-
-$handle=opendir( $dir ) ;
-$notyet = true ;
-
-$close="";
-while ( $entry = readdir($handle) )
- {
- if ( strpos ( $entry, ".zip" ) )
- {
- if ( $notyet )
- {
- $notyet = false ;
- echo "<h3>Win 32 source files (*.zip format)</h3><ul>\n" ;
- $close="</ul>";
- }
- echo "<li><a href=\"$dir/$entry\">" ;
- echo $entry . "</a></li>\n" ;
- }
- }
-echo "$close";
-
-closedir($handle);
-
-# .exe files
-
-$handle=opendir( $dir ) ;
-$notyet = true ;
-
-$close = "";
-while ( $entry = readdir($handle) )
- {
- if ( strpos ( $entry, ".exe" ) )
- {
- if ( $notyet )
- {
- $notyet = false ;
- echo "<h3>Win 32 setup files (*.exe format)</h3><ul>\n" ;
- $close="</ul>";
- }
- echo "<li><a href=\"$dir/$entry\">" ;
- echo $entry . "</a></li>\n" ;
- }
- }
-echo "$close";
-
-closedir($handle);
+handleFileType("tar.gz", "Source files", $dir, $sortby);
+handleFileType("deb", "Debian GNU/Linux Packages", $dir, $sortby);
+handleFileType("rpm", "GNU/Linux RPM Packages", $dir, $sortby);
+handleFileType("zip", "Source files", $dir, $sortby);
+handleFileType("exe", "Windows Installation Files", $dir, $sortby);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5463 - trunk/www/web/shared,
jcater <=