jimbowvu80s Posted December 22, 2010 Share Posted December 22, 2010 I am trying to list the contents of different directories and I am having zero success. I have tested my PHP installation with phpinfo and through the PHP manager in IIS and it works. I am using IIS 7.5 and Win 2008 R2. I've made some basic scripts like what IP address does the machine have and they work. But, when I run the directory listing script in the root of the server it doesn't display any information. When I place the script in another directory it wants to download the file. Here is the script I am using to display the directory contents. It came from another user on the phpfreaks. $f = 0; $d = 0; // Open $var['path'] directory if ($handle = opendir($var['path'])) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_dir("$var[path]/$file")) { // $file is a directory $dirList[$d] = $file; $d++; } elseif ($file != "." && $file != "..") { // $file is not a directory $fileList[$f] = $file; $f++; } } closedir($handle); } @sort($fileList); @sort($dirList); for ($x = 0; $x < $d; $x++) { $html .= "<a href=\"{$var['url']}/fileDir.php?dir=$dirList[$x]\">$dirList[$x]/</a><br>\n"; } for ($x = 0; $x < $f; $x++) { $html .= "<a href=\"{$var['url']}/fileEdit.php?file=$fileList[$x]\">$fileList[$x]</a><br>\n";} I have checked "I think" all the different settings I could and I cannot figure out why it won't display the directory contents. Could it be a rights issue? Right now I am IUSR to access the site, but I will be using windows authentication. Any information would be helpful. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/222408-unable-to-list-directory-contents/ Share on other sites More sharing options...
jimbowvu80s Posted December 22, 2010 Author Share Posted December 22, 2010 I upgraded to PHP Version 5.3.4 today and I did a manual install. Everything worked until I renamed the php.ini-production to php.ini. I've followed the the recommended adjustments to the file, but after I did I started receiving - 500 - Internal server error message. I have several different manuals I've been using for configuring the ini file and I'm not sure what is right. Does anyone have a list of recommended changes to the ini file? Is there a setting in there that will allow directory listing - what I'm trying to figure out? I can run scripts like the one below fun. <?php $ip=@$REMOTE_ADDR; $ip=$_SERVER['REMOTE_ADDR']; echo "<b>IP Address= $ip</b>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/222408-unable-to-list-directory-contents/#findComment-1150500 Share on other sites More sharing options...
trq Posted December 23, 2010 Share Posted December 23, 2010 You have two different question now. One (listing directory contents) has nothing to do with PHP installation & configuration. It is likely either a permissions issue, or just bad code. Make sure the IUSR account has read access to the directories in question. The other (your now misconfigured PHP install). Is php installed under fastcgi or as an module? Quote Link to comment https://forums.phpfreaks.com/topic/222408-unable-to-list-directory-contents/#findComment-1150629 Share on other sites More sharing options...
jimbowvu80s Posted January 4, 2011 Author Share Posted January 4, 2011 Thanks Thorpe for the reply. When you suggested bad code I wanted to make sure there wasn't with the code and I noticed that there were short tags used in the script. I'm new to php and it took a while to figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/222408-unable-to-list-directory-contents/#findComment-1154690 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.