[UPHPU] simple??? php function (display an index)
Saint Chaos
saintchaos at gmail.com
Tue Jul 18 23:14:12 MDT 2006
On 7/18/06, Caleb Call <caleb at macjunk.org> wrote:
>
> Is it possible (or is there a simple way to) create an index.php page
> that will just show all the files in the directory? Similar to not
> having any index page at all. I'd like to just show the files but
> I'd also like to be able to apply a stylesheet to the directory?
> I've tried searching php.net but I really don't know what I am
> searching for. Any help would be greatly appreciated.
Something like this (from Zend Studio code snippets):
______________________________________________________________________
<?
/********************************************************************
* function that reads directory content and
* returns the result as links to every file in the directory
*
* toss it into any directory and get a list of links to every file
*
* This program is free software licensed under the
* GNU General Public License (GPL).
*
*********************************************************************/
function directory($result) {
$handle=opendir(".");
while ($file = readdir($handle)) {
if ($file == "." || $file == "..") { } else { print "<a
href=$file>$file</a><br>\n"; }
}
closedir($handle);
return $result;
}
?>
<b>Select the file you want to go to:</b>
<p>
<?
echo directory($result);
?>
______________________________________________________________________
--
>From the ashes shall rise a new age. An age without rules, without laws and
without men.
More information about the UPHPU
mailing list