Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/222408-unable-to-list-directory-contents/
Share on other sites

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>"; 

?>

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?

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.