note 52126 added to function.apache-request-headers
| From: | renich at woralelandia dot com | Date: | Thu, 21 Apr 2005 17:50:40 +0000 |
| Subject: | note 52126 added to function.apache-request-headers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88361@lists.php.net to get a copy of this message | ||
Here is a simple listing function. It accepts a path and target. Examples listed bellow
function list_dirs($path, $target)
{
$list = scandir($path);
foreach ($list as $number => $filename)
{
if ( $filename !== '.' && $filename !== '..' &&
!is_file($filename) )
{
// Asign more readable and logic variables
$dir = $filename;
$url = apache_request_headers();
if ($target == '')
{
// Print Dirs with link
print ("<a href=\"http://$url[Host]/$dir\">$dir</a>
<br>\n");
}
else
{
// Print Dirs with link
print ("<a href=\"http://$url[Host]/$dir\"
target=\"$target\">$dir</a> <br>\n");
}
}
}
}
Examples:
1.- List actual dir with no target option
<?php
list_dirs('.', '');
?>
2.- List "mydir" with a "_blank" as target name
<?php
list_dirs('/home/renich/www/mydir', '_blank')
?>
Notes:
- Its a simple function and it uses a function that interacts with apache. I don't know what
will happen if you request a file list of a directory outside of the apache realm!
- Not fully tested!
----
Manual Page -- http://www.php.net/manual/en/function.apache-request-headers.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52126
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52126&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52126&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52126&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52126&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52126&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52126&report=yes
Search -- http://master.php.net/manage/user-notes.php