Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
08-12-2008, 03:41 AM #1
- Join Date
- Dec 2006
- Copenhagen, Denmark
- Thanked 5 Times in 5 Posts
Is tmpfile() restricted by open_basedir setting or not?
According to this comment on the PHP manual pages, the
tmpfile()function is affected by the
Quoting from the mentioned comment about
Remember, that open_basedir affects this function. You will get an error:
Warning: tmpfile() [function.tmpfile]: open_basedir restriction in effect. File(/var/tmp) is not within the allowed path(s): ....blablabla =)
open_basedir = D:\htdocs
open_basedirwas in effect, it was...
Fine, then lets try to run this script which should produce the mentioned warning message since my
"C:\Windows\Temp", (as shown in
phpinfo()) is now outside the
open_basedir, and I would then not expect
tmpfile()to be working.
$temp = tmpfile();
fwrite($temp, "writing to tempfile");
echo 'x:'.fread($temp, 1024);
sleep(10); // sleep 10 seconds
tmpfile()will automatically be deleted again when the script ends so
sleep(10)was added so I could check whether the temporary file was created or not while the script was running.)
Now comes the weird part... Strangely, I get absolutely no warning message when running the above script. On the contrary,
tmpfile()seems to be totally unaffected by the
open_basedirsetting! And when I look in
"C:\Windows\Temp"I indeed see the a file
phpX.tmpappear and vanish when the script starts and stops. But
"C:\Windows\Temp"is not within
"D:\htdocs"which I has set as the
open_basedirrestriction and where the script is running.
My question is therefore: When is
open_basedir, and when not?
Environment: PHP 5.2.6 / Apache / Microsoft Windows Server 2003
If it is of interest, the reason for the above question is that I am trying to figure out why some users are having trouble with the PEAR Spreadsheet_Excel_Writer on some hosts.