sam06 Posted November 1, 2008 Share Posted November 1, 2008 Please could someone help me change the following code that gives a directory view to all files and folders, so that it only shows the folders, and that it doesn't search in the folder it is in, but it searches /sites/ folder? Cheersm Sam <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <?php function paintUndersideOfFox($c = '.', $wcwd = false) { if($wcwd === false) $wcwd = substr($wcwd = $_SERVER['REQUEST_URI'], 0, strrpos($wcwd, '/') + 1); echo('<ul class="dirlist">'); $d = opendir($c); while($f = readdir($d)) { if(strpos($f, '.') === 0) continue; $ff = $c . '/' . $f; echo '<li><a href="' . $wcwd . $ff . '">' . $f . '</a>'; if(is_dir($ff)) paintUndersideOfFox($ff, $wcwd); echo '</li>'; } echo('</ul>'); } ?> <title>Directory Listing</title> <style type="text/css"> ul.dirlist, ul.dirlist li { list-style-type: none; padding-left: 1em; } </style> </head> <body> <?php paintUndersideOfFox(); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/131011-solved-quick-change-to-code/ Share on other sites More sharing options...
sam06 Posted November 1, 2008 Author Share Posted November 1, 2008 Or maybe change this so it just displayed folders? <? /** * Change the path to your folder. * * This must be the full path from the root of your * web space. If you're not sure what it is, ask your host. * * Name this file index.php and place in the directory. */ // Define the full path to your folder from root $path = "/home/user/public/foldername/"; // 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 == "index.php" ) continue; echo "<a href=\"$file\">$file</a><br />"; } // Close closedir($dir_handle); ?> Link to comment https://forums.phpfreaks.com/topic/131011-solved-quick-change-to-code/#findComment-680175 Share on other sites More sharing options...
sam06 Posted November 1, 2008 Author Share Posted November 1, 2008 Doesn't matter, I sorted it. Link to comment https://forums.phpfreaks.com/topic/131011-solved-quick-change-to-code/#findComment-680194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.