List directories in PHP

djfenom

Guppy
Does anyone know how I can list all of the directories I've got in my domain list?

I've tried the code below:

PHP:
// Define the full path to your folder from root
    $path = "/hsphere/local/home/arrivalphp/";

    // Open the folder
    $dir_handle = @opendir($path) or die("Unable to open $path");

    // Loop through the files
    while ($file = readdir($dir_handle)) {

    if($file == "." || $file == ".." || $file == "index2.php" )

        continue;
        echo "<a href=\"$file\">$file</a><br />";

    }
    // Close
    closedir($dir_handle);

But all I’m getting is: Unable to open /hsphere/local/home/arrivalphp/

I can get it working if I add a domain to the end of the path (/hsphere/local/home/arrivalphp/domainname.co.uk), but I need to be able to list all of the domains.

Is there any way around this or another way of doing it?

Jodo said it may not be possible since PHP runs under web server privileges but suggested using Pearl, but I'm not sure how that works?

Thanks

Chris
 
Search for 'perl directory listing script' and you may get one :)

Please ensure you password protect it, for all information it can reveal.
 
I've done that already and tried a few different scripts such as this one:

#!/usr/bin/perl -w

@files = </hsphere/local/home/arrivalphp/*>;
foreach $file (@files) {
print $file . "\n";
}

But all I get is:

Error 500: Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

The problem is on the server side, not with your browser or the address. Most probably, a certain service (e.g., Tomcat engine) is down. Please contact your webmaster.
 
1. Ensure RLimitMem is not enabled for this domain.
2. You must send content-type header before your script output.
 
Back
Top