ID: 18332
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
-Bug Type: Documentation problem
+Bug Type: Feature/Change Request
Operating System: any
PHP Version: 4.2.1
New Comment:
I recently ran into this same problem. With the open_basedir config
option set, is_readable() can report unexpected results.
Perhaps a solution may be to run through all of the security checks
that fopen goes through and find out if the file is readable. Another
solution would be to actually just flat out open the file with
php_fopen() for read or append (for is_writable()) and see what is
returned.
Perhaps an argument can be added such as:
is_readable(STRICT) where STRICT checks everything
is_readable(STRICT | ATTEMPT) would actually attempt the open.
I'm just throwing out ideas. My problem is that I would like a way to
guarantee that no errors or warnings are returned by a call to fopen()
with the E_ALL error level set. I was using:
file_exists() && is_readable()
I can't think of any check to perform other than writing a function in
my script that does a "safe" open such as:
function is_truly_readable()
{
$e = error_reporting(0);
if ($f = fopen($file, "r"))
{
fclose($f);
error_reporting($e);
return(TRUE);
}
error_reporting($e);
return(FALSE);
}
Previous Comments:
------------------------------------------------------------------------
[2002-09-22 16:37:38] [EMAIL PROTECTED]
In the current release of the manual is_readable/is_writable now
mention the fact that they will not check safe_mode limitation. The
is_executable however, still needs to be documented.
------------------------------------------------------------------------
[2002-07-15 21:52:19] [EMAIL PROTECTED]
I think stat function can be used to know actual permissions. is_*
function supposed to return if current process can do something or not.
IMO.
We may need to change doc a bit. -> Documentation Problem
------------------------------------------------------------------------
[2002-07-13 18:31:32] [EMAIL PROTECTED]
It would be very useful if is_readable/is_writable/is_executable
series of functions would work with safe mode. Currently is_writable()
will report a file that in reality cannot be accessed undersafe mode is
writeable, which is clearly misleading.
At least, could the manual be modified in such a way as to document
that those functions will not work properly under safe_mode.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18332&edit=1