I have such script for showing list of files and directories on my server:
[code=php] <?php
function showContent($path){
if ($handle = opendir($path))
{
$up = substr($path, 0, (strrpos(dirname($path.”/.”),”/”)));
echo “<tr><td colspan=’3′>”;
echo “<a href='”.$_SERVER[‘PHP_SELF’].”?path=$up’>Up one level</a>”;
echo “</td></tr>”;
while (false !== ($file = readdir($handle)))
{
if ($file != “.” && $file != “..”)
{
$fName = $file;
$file = $path.’/’.$file;
if(is_file($file)) {
echo “<tr><td> -F- <a href='”.$file.”‘>”.$fName.”</a></td>”
.”<td align=’right’>”.date (‘d-m-Y H:i:s’, filemtime($file)).”</td>”
.”<td align=’right’>”.filesize($file).” bytes</td></tr>”;
} elseif (is_dir($file)) {
print “<tr><td colspan=’3′> -D- <a href='”.$_SERVER[‘PHP_SELF’].”?path=$file’>$fName</a></td></tr>”;
}
}
}
closedir($handle);
}
}
?>
Can I add some script which would add custom icon dependently from file type (it would in place where “-F-” is right now)? I’d like to have different icon for images, audio files, archives etc. so I seems to need a script which would recognize file type and add suitable icon. I’ll be grateful for tips and help.