Chandigarh HomePages List

method=post> Display PHPs HTMLs both   

http://$SERVER_NAME$prefix/

"; function list_dir($cwd, $dir) { global $root, $display, $prefix; unset($sdirs); unset($sfiles); $cwd1[0] = $cwd; $cwd1[1] = $dir; $chdir = join("/", $cwd1); chdir($chdir); //delete all files from previous runs not to mess up the script with the old data, determine the path of the desired working directory and switch to it $handle = opendir('.'); while (false !== ($file = readdir($handle))) { $PHP_SELF1 = basename($PHP_SELF); if(is_dir($file) && $file != "." && $file != "..") { $sdirs[] = $file; } elseif(is_file($file) && $file != "$PHP_SELF1" && (ereg("php$", $file) || ereg("html$", $file) || ereg("htm$", $file) || ereg("shtml$", $file))) { $sfiles[] = $file; } } //read the content of the directory, save directories, PHP and HTML files (except the script itself) if(is_array($sdirs)) { sort($sdirs); reset ($sdirs); $dir = getcwd(); $dir1 = str_replace($root, "", $dir); $count = substr_count($dir1, "/") + substr_count($dir1, "\\"); //determine the number of subdirectories we're in to be able to add the appropriate number of |s before the directory name for($y=0; $y   "; } echo ""; echo " $sdirs[$y]
"; list_dir($dir, $sdirs[$y]); //call the script itself in all directories found to recursively read all subdirectories } for($z=0; $z<=$count; $z++) { echo "   "; } echo "
"; } //if directories were found, display them in a tree chdir($chdir); //change back to the directory the files are in, we need to do this because in the loop above we've read all subdirectories and therefore changed the working directory if(is_array($sfiles)) { sort($sfiles); reset($sfiles); $dir = getcwd(); $dir = str_replace($root, "", $dir); $count = substr_count($dir, "/") + substr_count($dir, "\\"); //Same as above - determine number of subdirectories. We can't keep this variable as the loop above resets it for every subdirectory. if(!isset($display)) { $display = "both"; } if($display == "both") { for($y=0; $y   "; } echo ""; echo " "; echo "$sfiles[$y]
"; } elseif(ereg("html$", $sfiles[$y]) || ereg("htm$", $sfiles[$y]) || ereg("shtml$", $sfiles[$y])) { for($z=1; $z<=$count; $z++) { echo "   "; } echo ""; echo " "; echo "$sfiles[$y]
"; } } } elseif($display == "PHP") { for($y=0; $y   "; } echo ""; echo " "; echo "$sfiles[$y]
"; } } } elseif($display == "HTML") { for($y=0; $y   "; } echo ""; echo " "; echo "$sfiles[$y]
"; } } } //check which files to display and display them for($z=1; $z<=$count; $z++) { echo "   "; } echo "
"; } //now display the files in the directory with links to themselves } //We defined this function because we needed a script that calls itself recursively to read all subdirectories on the server. Now we just need to call it. list_dir($root, ""); $ftime = gettimeofday(); $time = round(($ftime[sec] + $ftime[usec] / 1000000) - ($stime[sec] + $stime[usec] / 1000000), 5); echo "

This page was generated in $time seconds.
"; ?>