hey all,
i found a snippet on the archives which i used and modified:
<?php
//Title
print "<head><title>Listed directory</title></head>\n";
//Display contents of a directory, start off display table with headings
print "
<center><table width=\"600\" border=\"0\" cellspacing=\"1\">\n".
"<tr bgcolor='#6699CC'>\n\t".
"<th align=\"left\" width=\"150\">Files in this folder:</th>\n".
"<th align=\"left\"> </th>\n".
"<th align=\"center\" width=\"100\">Modified:</th>\n".
"</tr>\n";
//Get contents of current directory using the getcwd() function, and pass it thru the parse_dir() function in: path/to/include/dircontents.php
$scanthis = getcwd();
$rootDir = "http://test.sothq.net/";
$dir = @opendir($scanthis);
while(false!=($file = @readdir($dir))) {
if ($file != "." && $file != ".." && is_file($file) && is_readable($file)) {
if(exif_imagetype($file)==IMAGETYPE_GIF
or exif_imagetype($file)==IMAGETYPE_JPEG
or exif_imagetype($file)==IMAGETYPE_PNG
or exif_imagetype($file)==IMAGETYPE_BMP) {
$scanthispp = preg_replace("/\s/","%20",$scanthis);
$filep = preg_replace("/\s/","%20",$file);
$theFile = $scanthispp . "/" . $filep;
$scanthispp = substr($scanthis,25); //trim absolute file path
$modDate = filemtime($theFile); //get last modified date of file
$modDate = date("Y-m-d", $modDate);
$yr = substr($modDate,0,4); //display 'new' if item not-older than 7days
$mnth = substr($modDate,5,2);
$dy = substr($modDate,8,2);
$newday = date("Y-m-d", mktime(0,0,0,$mnth,$dy + 7));
$now = date("Y-m-d");
if ($now <= $newday) {
$tag = "<b>new</b>";
} else {
$tag = " ";
}
$dispThis .= "<tr bgcolor='#CCCCCC'>\n".
"<td align=\"left\" valign=\"middle\" width=\"470\"><p><a class=\"fileText\" href=\"$rootDir$scanthispp$filep\">$filep</a></p></td>\n".
"<td align=\"center\" valign=\"top\" width=\"30\">$tag</td>\n".
"<td align=\"center\" valign=\"middle\" width=\"100\"><span class=\"fileText\">$modDate</span></td>\n".
"</tr>\n";
}
}
}
print $dispThis;
//Finish off display table
echo "</table></center>\n";
?>
It works quite nice but im wondering if theres a way to sort the files alphabetically or on date or something...
thanks!