php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22065 file() function
Submitted: 2003-02-05 02:48 UTC Modified: 2003-03-07 20:06 UTC
From: paul dot d dot rowlands at delphi dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.2-dev OS: Windows 2000 server
Private report: No CVE-ID: None
 [2003-02-05 02:48 UTC] paul dot d dot rowlands at delphi dot com
Error log fills with warnings abount the file() function.

Apache 2.0/34
Using php module version 4.3.0 rather than cgi.
Errors.log shows:-
[05-Feb-2003 08:33:45] PHP Warning:  file(d:/temp/ht1/050203.ht1) [<a href='http://www.php.net/function.file'>function.file</a>]: failed to create stream: Permission denied in d:\Apache Group\Apache2\htdocs\fa_tools_ht.php on line 103

Code:-
   if(file_exists($file1)==FALSE) die("File1 does not exist");
   if(is_readable($file1)==FALSE) die("File1 not readable");
   // parse files into arrays
   $file_array1=file($file1); //WARNING HERE

   if($file_array1==null) die("Permission denied to open file");

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-05 10:41 UTC] iliaa@php.net
Do you have open_basedir or safe_mode enabled?
 [2003-02-06 01:52 UTC] paul dot d dot rowlands at delphi dot com
safe_mode = Off
;open_basedir =
 [2003-02-06 08:45 UTC] sniper@php.net
Does the file exist?
What are the permissions for it?

(I think it's is_readable() that does not work correctly
on windows)

 [2003-02-06 09:43 UTC] paul dot d dot rowlands at delphi dot com
The file must exist to continue in the code:-
if(file_exists($file1)==FALSE) die("File1 does not exist");
The file is everybody full control.

What would have if the file was in use by another server (updating) ?
Can php detect this condition ?
 [2003-02-18 06:26 UTC] paul dot d dot rowlands at delphi dot com
The warnings have reduced with the stable release. 
6 warnings in 48 hours.
 [2003-02-18 06:28 UTC] paul dot d dot rowlands at delphi dot com
[18-Feb-2003 06:47:42] PHP Warning:  file(d:/temp/ht1/180203.ht1) [<a href='http://www.php.net/function.file'>function.file</a>]: failed to open stream: Permission denied in d:\Apache Group\Apache2\htdocs\fa_tools_ht.php on line 103
 [2003-02-19 09:25 UTC] moptop69 at ntlworld dot com
Warning: Unknown(c:\inetpub\wwwroot\calendar.php): failed to open stream: Permission denied in Unknown on line 0

i get this under IIS on Windows 200 when the IUSR_<hostname> does not have the correct security access to the files, this has only recently started showing this previously I would get a CGI/HTTP500 error message instead.

if needs be make sure that all files in the webroot have the correct permissions for your scripts to execute/read and where needed write.
 [2003-02-19 10:27 UTC] paul dot d dot rowlands at delphi dot com
All files in web root are everyone full control.
Note: 100+ Warnings on php 4.3.0 in 48 hours
New stable release less than 6 in 48 hours.
Php scripts have not changed they are accessing the same files, however these files are not in the web root, but are on the same local drive and are everyone full control.
 [2003-02-19 19:33 UTC] sniper@php.net
Your comment:
"What would have if the file was in use by another server (updating) ? Can php detect this condition ?"

Question: What do you mean by "in use by another server" ?

 [2003-02-25 02:07 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-03-07 16:27 UTC] pdrow at blueyonder dot co dot uk
THE NT WORKSTAION HAS THE FILE OPEN AT ALL TIMES TO APPEND DATA.
2000 SERVER COPIES THE FILE EVERY 2 MINS OVER THE TCP/IP NETWORK.
THE PHP SCRIPT USES FILE TO READ THE LOCAL FILE (WIN 2000 SERVER) EVERY 30 SECONDS.
 [2003-03-07 16:28 UTC] paul dot d dot rowlands at delphi dot com
Re-open ?
 [2003-03-07 20:06 UTC] wez@php.net
Your app/system design is flawed; if you have a file open for exclusive access (eg: writing) you cannot expect any other process to be able to copy (eg: read) or do anything else with the file.

Not a bug in PHP, so this is being marked as bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 07:01:32 2024 UTC