note 68903 added to function.scandir
| From: | phpfeedback dot e dot stevegs at spamgourmet dot com | Date: | Tue, 15 Aug 2006 14:18:54 +0000 |
| Subject: | note 68903 added to function.scandir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115937@lists.php.net to get a copy of this message | ||
Perhaps I'm missing something, but none of the other suggestions shown here did what I wanted.
The problem was I wanted to list all files on a hidden (ie. unreferenced) directory on my web site.
Normally, if there's no INDEX.HTM, this will happen automatically. However, my service
provider is a bit smarter: they throw up an 'unauthorised user' message in the absence of
the INDEX.HTM. The following got round the problem - if the directory contents alter, the changes
are shown automatically.
Sorry about the HTML tags below - it was the only way I could get the preview to display properly.
Two files are required:
1) a blank INDEX.HTM that calls LISTFILE.PHP in a single frame:
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="100%" FRAMEBORDER=no BORDER=0 FRAMESPACING="0">
<FRAME src="listfile.php">
</FRAMESET></HTML>
2) a LISTFILE.PHP that lists all files and subdirectories in the current web directory (*except* the
INDEX.HTM and LISTFILE.PHP files, which you know are there!)
Links to all these files are automatically created:
<HTML>
<HEAD>
</HEAD>
<BODY>
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file !=
"index.htm"
&& $file != "listfile.php")
echo "<a href=\"$file\">$file</a><br>";
}
closedir($handle);
}
?>
</BODY></HTML>
Regards,
Steve Glennie-Smith
----
Server IP: 83.138.144.80
Probable Submitter: 81.187.254.38
----
X-Spam-Status: Yes, hits=5.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_30_40,HTML_MESSAGE,HTML_RELAYING_FRAME,HTML_TAG_BALANCE_A
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.scandir.php
Edit -- https://master.php.net/note/edit/68903
Del: integrated -- https://master.php.net/note/delete/68903/integrated
Del: useless -- https://master.php.net/note/delete/68903/useless
Del: bad code -- https://master.php.net/note/delete/68903/bad+code
Del: spam -- https://master.php.net/note/delete/68903/spam
Del: non-english -- https://master.php.net/note/delete/68903/non-english
Del: in docs -- https://master.php.net/note/delete/68903/in+docs
Del: other reasons-- https://master.php.net/note/delete/68903
Reject -- https://master.php.net/note/reject/68903
Search -- https://master.php.net/manage/user-notes.php