note 52126 deleted from function.apache-request-headers by danbrown

From: Date: Mon, 08 Jun 2009 18:49:55 +0000
Subject: note 52126 deleted from function.apache-request-headers by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156486@lists.php.net to get a copy of this message
Note Submitter: renich at woralelandia dot com ---- 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!

« previous php.notes (#156486) next »