note 109115 added to function.scandir
| From: | 2bbasic at gmail dot com | Date: | Thu, 21 Jun 2012 11:35:49 +0000 |
| Subject: | note 109115 added to function.scandir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188733@lists.php.net to get a copy of this message | ||
<?php
//-- Directory Navigation with SCANDIR
//--
//-- optional placemenet
$exclude_list = array(".", "..", "example.txt");
if (isset($_GET["dir"])) {
$dir_path = $_SERVER["DOCUMENT_ROOT"]."/".$_GET["dir"];
}
else {
$dir_path = $_SERVER["DOCUMENT_ROOT"]."/";
}
//-- until here
function dir_nav() {
global $exclude_list, $dir_path;
$directories = array_diff(scandir($dir_path), $exclude_list);
echo "<ul style='list-style:none;padding:0'>";
foreach($directories as $entry) {
if(is_dir($dir_path.$entry)) {
echo "<li style='margin-left:1em;'>[`] <a
href='?dir=".$_GET["dir"].$entry."/"."'>".$entry."</a></li>";
}
}
echo "</ul>";
//-- separator
echo "<ul style='list-style:none;padding:0'>";
foreach($directories as $entry) {
if(is_file($dir_path.$entry)) {
echo "<li style='margin-left:1em;'>[ ] <a
href='?file=".$_GET["dir"].$entry."'>".$entry."</a></li>";
}
}
echo "</ul>";
}
dir_nav();
//-- optional placement
if (isset($_GET["file"])) {
echo "<div style='margin:1em;border:1px solid Silver;'>";
highlight_file($dir_path.$_GET['file']);
echo "</div>";
}
//-- until here
//--
//-- Because I love php.net
?>
----
Server IP: 69.147.83.197
Probable Submitter: 182.8.0.92
----
Manual Page -- http://www.php.net/manual/en/function.scandir.php
Edit -- https://master.php.net/note/edit/109115
Del: integrated -- https://master.php.net/note/delete/109115/integrated
Del: useless -- https://master.php.net/note/delete/109115/useless
Del: bad code -- https://master.php.net/note/delete/109115/bad+code
Del: spam -- https://master.php.net/note/delete/109115/spam
Del: non-english -- https://master.php.net/note/delete/109115/non-english
Del: in docs -- https://master.php.net/note/delete/109115/in+docs
Del: other reasons-- https://master.php.net/note/delete/109115
Reject -- https://master.php.net/note/reject/109115
Search -- https://master.php.net/manage/user-notes.php