note 28569 deleted from function.opendir by sniper
| From: | sniper@php.net | Date: | Sun, 12 Oct 2003 04:24:54 +0000 |
| Subject: | note 28569 deleted from function.opendir by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58324@lists.php.net to get a copy of this message | ||
Note Submitter: chris at chrischurch dot net
----
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>") ;
}