uppercasefive Posted August 6, 2009 Share Posted August 6, 2009 This bloated jumble of code needs some simplification, but I do not know of a way to do it. The directory structure won't change, which is why I did it this way. $handle = opendir($base_url); while($dir = readdir($handle)) // read /news { if($dir != "." && $dir != "..")// && is_dir($dir)) { $dirs[] = $dir; $code .= "<li><a href=\"#\" class=\"news\" id=\"$dir\">$dir</a><ul class=\"sublist\">"; $handle2 = opendir($base_url . $dir . "/"); while($dir2 = readdir($handle2)) // read /news/newslettername { if($dir2 != "." && $dir2 != "..")// && is_dir($dir2)) { $dirs[] = $dir2; $code .= "<li><a href=\"#\" class=\"news\" id=\"$dir2\">$dir2</a><ul class=\"sublist\">"; $handle3 = opendir($base_url . $dir . "/" . $dir2 . "/"); while($dir3 = readdir($handle3)) // read /news/newslettername/year { if($dir3 != "." && $dir3 != "..")// && is_dir($dir3)) { $dirs[] = $dir3; $code .= "<li><a href=\"#\" class=\"news\" id=\"$dir3\">$dir3</a><ul class=\"sublist\">"; $handle4 = opendir($base_url . $dir . "/" . $dir2 . "/" . $dir3 . "/"); while($file = readdir($handle4)) // read /news/newslettername/year/month { if($file != "." && $file != "..")// && is_dir($dir4)) $code .= "<li><a href=\"http://domain/news/$dir/$dir2/$dir3/$file\" target=\"_new\">$file</a></li>"; } $code .= "</ul></li>"; } } $code .= "</ul></li>"; } } $code .= "</ul></li>"; } } $code .= "</ul>"; This does work, I just have a feeling that there is an easier way to do it, just don't know what that is... Got ideas? Link to comment https://forums.phpfreaks.com/topic/169138-output-directoryfile-listing/ Share on other sites More sharing options...
Mardoxx Posted August 6, 2009 Share Posted August 6, 2009 http://autoindex.sourceforge.net/ Link to comment https://forums.phpfreaks.com/topic/169138-output-directoryfile-listing/#findComment-892384 Share on other sites More sharing options...
uppercasefive Posted August 6, 2009 Author Share Posted August 6, 2009 http://autoindex.sourceforge.net/ Not quite what I was looking for. It's supposed to be an index page for an archive of cached newsletters. Link to comment https://forums.phpfreaks.com/topic/169138-output-directoryfile-listing/#findComment-892395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.