I can't read directory contents

From: Date: Thu, 29 Jun 2000 19:23:50 +0000
Subject: I can't read directory contents
Groups: php.general 
Request: Send a blank email to php-general+get-3860@lists.php.net to get a copy of this message
Hi, I was using the following code on my Unix server which worked just fine. Now on my NT server, the host company states that I cannot read the directory contents and write them to this page because it's a security problem. Simply put, this should look for .htm files in a directory, and print them out on the page. It doesn't work now, but it works fine on my Unix host machine. Is this a security problem? Is there a setting I need on NT? Can't I do this with the standard read permissions? What do I need in order for a script like this to work? TIA, Peter <?php exec( "ls -la $dir",$lines,$rc); $count = count($lines) - 1; for ($i = 1; $i <= $count; $i++) { $type = substr($lines[$i],0,1); $name = strrchr($lines[$i], " "); $name = substr($name,1); $dire = substr($lines[$i],0,strpos($lines[$i],$name)); if (strpos($name, ".mp3")) { //echo "<font color=\"red\">"; } else { if (strpos($name, ".php") or strpos($name, ".cgi")) { // echo "<font color=\"maroon\">"; } else { if ($type == "d") { //echo "<font color=\"blue\">"; } else { //echo "<font color=\"black\">"; } } } //echo "$dire</font>"; if ($type == "d") { if ($name == "." or $name == "..") { echo ""; } else { if ($dir == "") { // echo "<a href=directory.php?dir=$name>$name</a><br>"; } else { // echo "<a href=directory.php?dir=$dir/$name>$name</a><br>"; } } } else { if ($dir == "" and !strpos($name, ".php") and !strpos($name, ".text")) { echo " <P><font face=\"verdana,arial\">[<a href=$name>view</A>] : <a href=source.php3?page_url=$name>$name</a><br>"; } else { // echo " <P><font face=\"verdana,arial\">[<a href=$name>view</A>] : <a href=source.php3?page_url=$dir/$name>$name</a><br>"; } } } ?>

« previous php.general (#3860) next »