note 28569 added to function.opendir
| From: | chris at rack1 dot php dot net | Date: | Fri, 17 Jan 2003 03:22:23 +0000 |
| Subject: | note 28569 added to function.opendir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42249@lists.php.net to get a copy of this message | ||
Was getting all kinds of directory output, printout, or listing including hidden file on web page
from innocently reading a directory in PHP. This was happening in the function below, and the fix
is the "@" sign in not one, but two places.
function read_file ( )
{
//http://www.zend.com/manual/function.readdir.php
global $image_path ,
$image_fname ,
$my_error_check ;
$image_fname = "" ;
if ( $handle = @opendir ( $image_path ) )
{
while (false !== ( $file = @readdir ( $handle ) ) )
{
if ( $file != "." && $file != ".." )
{
if ( $my_error_check )
echo ( "file: $file<br>") ;
$image_fname = $image_fname . $file . ":" ;
if ( $my_error_check )
echo ( "image_fname: $image_fname<br>") ;
}
}
closedir ( $handle ) ;
}
if ( $my_error_check )
echo ("leaving read_file<br>") ;
}
--
http://www.php.net/manual/en/function.opendir.php
http://master.php.net/manage/user-notes.php?action=edit+28569
http://master.php.net/manage/user-notes.php?action=delete+28569
http://master.php.net/manage/user-notes.php?action=reject+28569