Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 05-29-2008, 02:37 PM   #1 (permalink)
metazai
Regular Contributor
 
Join Date: Apr 2004
Location: Orange County, CA
Posts: 151
metazai is on a distinguished road
$_SERVER ["DOCUMENT ROOT"] problem

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>");}
	}
?>
metazai is offline   Reply With Quote
Old 06-02-2008, 01:41 AM   #2 (permalink)
metazai
Regular Contributor
 
Join Date: Apr 2004
Location: Orange County, CA
Posts: 151
metazai is on a distinguished road
Gah. It was a permissions/ownership problem. Sorry to trouble everyone.
metazai is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A small problem in the output the_master Standard C, C++ 1 12-17-2006 10:09 AM
parse error problem in game.. can't seem to find problem solution. slashdot Standard C, C++ 5 08-03-2005 09:15 PM
JSP code problem j.gohel Java 7 04-15-2005 03:07 PM
Hashing problem jodders Standard C, C++ 1 02-09-2005 02:51 PM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 05:44 PM


All times are GMT -8. The time now is 08:03 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting