100) return; // echo "symlink level: ".$symlink_level."\n"; $ignore = array( 'cgi-bin', '.', '..', '/' ); // Directories to ignore when listing output. Many hosts // will deny PHP access to the cgi-bin. $dh = @opendir( $path ); // Open the directory to the handle $dh while( false !== ( $file = readdir( $dh ) ) ){ // Loop through the directory if( !in_array( $file, $ignore ) && strlen($file) != 0 ){ // Check that this file is not to be ignored if( is_dir( "$path/$file" ) ){ // Its a directory, so we need to keep reading down... $fs = filesize("$path/$file"); $lm = filemtime("$path/$file"); $user = fileowner("$path/$file"); $group = filegroup("$path/$file"); $permissions = fileperms("$path/$file"); outputLine($path, $file, $fs, $lm, $user, $group, $permissions, $level, $symlink_level, True); if ( is_link("$path/$file") && $symlink_level < $max_symlink_level ) { getDirectory( "$path/$file", ($level+1), ($symlink_level + 1) ); } else if (!is_link("$path/$file")) { getDirectory( "$path/$file", ($level+1), $symlink_level ); } // Re-call this same function but on a new directory. // this is what makes function recursive. } else { $fs = filesize("$path/$file"); $lm = filemtime("$path/$file"); $user = fileowner("$path/$file"); $group = filegroup("$path/$file"); $permissions = fileperms("$path/$file"); outputLine($path, $file, $fs, $lm, $user, $group, $permissions, $level, $symlink_level); // Just print out the filename } } } closedir( $dh ); // Close the directory handle } // Output as plaintext with utf8 encoding // change charset to iso-8859-1 to change to ASCII header('Content-Type: text/plain; charset=utf8'); $dir_arg = $_GET['dir']; $print_path = $_GET['print_path']; if ($print_path) { echo "-listing-begin-\n"; echo getcwd() . "\n"; echo "-listing-end-\n"; return; } // Check if dir parameter is valid if( is_dir($dir_arg) ) { //echo $dir_arg."\n\n"; echo "-listing-begin-\n"; getDirectory( $dir_arg ); echo "-listing-end-\n"; } else echo "bad dir"; ?>