Other than the root being returned incorrectly (I don't know if it is or not because the host won't get back to me), is there any reason anyone can see why this doesn't work, listing directories on a server?
Code:
function getDirectory($path = null, $level = 0 )
{
if($path == null)
{
$path = $_SERVER["DOCUMENT_ROOT"];
}
$ignore = array( 'cgi-bin', '.', '..','admin','editor','.fp','scripts','includes','images','oldsite','news','real-estate-marketing','standard-services-agreement' );
$dh = @opendir( $path );
$iCount = 0;
if($level == 0)
{
$dirArray[$iCount] = "/";
$iCount++;
}
while( false !== ( $file = readdir( $dh ) ) )
{
if( !is_dir( "$path/$file" ) )
{
continue;
}
if( !in_array( $file, $ignore ) )
{
$dirArray[$iCount] = "/".substr(strstr("$path/$file","/"),strlen($_SERVER['DOCUMENT_ROOT'])-1);
$iCount++;
$childArray = getDirectory( "$path/$file", ($level+1) );
for($xp=0;$xp<sizeof($childArray);$xp++)
{
$dirArray[$iCount] = $childArray[$xp];
$iCount++;
}
}
}
closedir( $dh );
return $dirArray;
}
$myArray = getDirectory();
for($iIndex=0; $iIndex<sizeof($myArray); $iIndex++)
{
$myArray[$iIndex]=str_ireplace("/m","",$myArray[$iIndex]);
if ($myArray[$iIndex] == "/") {
echo(" <tr>
<td width=\"50%\" class=\"bottomborder\"><br />ROOT<br /></td>
<td align=\"center\" class=\"bottomborder\"><br /><span class=\"verd14boldred\">CAN'T DELETE</span><br /></td>
</tr>"); } else {
echo ("<tr><td class=\"bottomborder\"><br />".$myArray[$iIndex]."<br /></td><td align=\"center\" valign=\"middle\" class=\"bottomborder\"><a href=\"#\" onclick=\"precheck('".$iIndex."')\"><img src=\"images/delete.gif\" border=\"0\"></a><div id=\"confirm_delete_".$iIndex."\" style=\"cursor: hand;\"></div><br /></td></tr>");}
}
?>