I have a code that works but it is still not doing exactly what I want. I am trying to get a dynamic side bar that will only show the folders and not the files. I have tried for quite a few hours to get it where it is but till no luck not showing files. Any help would be appreciated.
<?php
$PHP_SELF=$SERVER['PHP_SELF'];
$pfath_info = pathinfo($PHP_SELF);
$C=isset($REQUEST['C']) ? $REQUEST['C'] : "N";
$O=isset($REQUEST['O']) ? $_REQUEST['O'] : "A";
$n=0;
?>
<html>
<head>
<title></title>
</head>
<body>
<style type="text/css">
td {font-family:'Courier New'; font-size:10pt}
</style>
<?
//clearstatcache();
if ($handle = opendir('.'))
{ while (false !== ($file = readdir($handle)))
{ if (($file!=".")&&($file!="..")&&($file!=$pfath_info["basename"]))
{ $n++;
$key=$n;
if($C=="M") $key=filemtime($file).".".$n;
elseif($C=="S")
{ if (filetype($file)=="dir") $key="0.".$file;
else $key=(filesize($file)+1).".$n";
}
if (filetype($file)=="dir") $files[$key]=$file."/";
else $files[$key]=$file;
}
}
closedir($handle);
}
if($C=="N") @natcasesort($files);
else @ksort($files, SORT_REGULAR);
if($O=="D")
{ if (isset($files)) $files = array_reverse($files);
$O="A";
}
else $O="D";
$files = @array_values($files);
echo "<H1></H1>\r\n";
echo "<table border=0>\r\n";
echo "<tr>\t<td nowrap> ";
if($C!="N") echo "";
else echo "";
echo "</a></td>\r\n\t<td nowrap>";
if($C!="M") echo "";
else echo "";
echo "</a></td>\r\n\t<td nowrap>";
if($C!="S") echo "";
else echo "";
echo "</a></td>\r\n";
echo "</tr>\r\n\r\n";
echo "<td> </td>\r\n";
echo "<td> </td>\r\n";
echo "</tr>\r\n";
$n = sizeof($files);
for($i=0;$i<$n;$i++)
{ echo "<tr>\t<td nowrap>";
if(substr($files[$i],-1)=="/")
{ echo "»<a href='".$files[$i]."'><b>".$files[$i]."</b>";
$s="-";
$e="";
}
else
{ echo " <a href='".$files[$i]."'>".$files[$i];
$s=filesize($files[$i]);
$e="";
if ($s>=1024)
{ $s/=1024;
$e="K";
if ($s>=1024)
{ $s/=1024;
$e="M";
if ($s>=1024)
{ $s/=1024;
$e="G";
}
}
$s=round($s*10)/10;
}
}
echo "</tr>\r\n";
}
echo "</table>\r\n";
?>