note 35182 added to function.file-exists
| From: | andy at acomm-hosting dot co dot uk | Date: | Fri, 22 Aug 2003 13:39:58 +0000 |
| Subject: | note 35182 added to function.file-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54870@lists.php.net to get a copy of this message | ||
PHP 4.3.2 on Apache 1.3.27 has some interesting effects. On all VHOSTS we use the:
open_basedir .:/tmp:/usr/local/lib/php:/home/12345:/home/theirdomain.com
as a security measure. All sites reside in:
/home/12345
(Where 12345 is their userid), and then their domain is symlinked to it for ease of use:
/home/theirdomain.com
What we've found is after upgrading, whenever a user uses
file_exists("/home/theirdomain.com/file.ext")
If the file does NOT exist, then it generates an error like this:
Warning: file_exists(): open_basedir restriction in effect.
File(/home/theirdomain.com/docs/notthere.txt) is not within the allowed path(s):
(.:/tmp:/usr/local/lib/php:/home/12345:/home/theirdomain.com/) in /home/12345/www/docs/test.php on
line 3
To combat this, as noted elsewhere change:
if (file_exists("/home/theirdomain.com/file.ext"))
to
if(file_exists(realpath("/home/theirdomain.com/file.ext"))
Hope that saves people some hair-pulling!!
-Andy
----
Manual Page -- http://www.php.net/manual/en/function.file-exists.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35182
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35182&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35182&report=yes