469,270 Members | 1,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

odd basedir() err or

I'm surprised to get an open_basedir error when I'm not only in the
correct folder for web documents, but I'm an extra layer deep. Basedir
is usually there to restrict how high up in the directory structure a
PHP fopen or include statement can reach, yes? The idea is to keep
someone in a hosted environment from launching an attack by including
files, or opening them, that are outside of the web environment? How do
I change the basedir?
Warning: MkDir failed (Permission denied) in
/home/httpd/vhosts/publicdomainsoftware.org/httpdocs/setup/neededFiles/writeAllNeededFolders.php
on line 11

Warning: open_basedir restriction in effect. File is in wrong directory
in
/home/httpd/vhosts/publicdomainsoftware.org/httpdocs/setup/neededFiles/writeAllNeededFolders.php
on line 12

Jul 17 '05 #1
4 1584

lk******@geocities.com wrote:
I'm surprised to get an open_basedir error when I'm not only in the
correct folder for web documents, but I'm an extra layer deep. Basedir is usually there to restrict how high up in the directory structure a
PHP fopen or include statement can reach, yes? The idea is to keep
someone in a hosted environment from launching an attack by including
files, or opening them, that are outside of the web environment? How do I change the basedir?
Warning: MkDir failed (Permission denied) in
/home/httpd/vhosts/publicdomainsoftware.org/httpdocs/setup/neededFiles/writeAllNeededFolders.php on line 11

Warning: open_basedir restriction in effect. File is in wrong directory in
/home/httpd/vhosts/publicdomainsoftware.org/httpdocs/setup/neededFiles/writeAllNeededFolders.php on line 12


I guess I'm looking for the right .htaccess directive to insert the
line

php_admin_value open_basedir none
Do I look to Apache for this, or www.php.net?

Jul 17 '05 #2
I fixed this by using DOCUMENT_ROOT and therefore an absolute address,
rather than a relative one. This is apparently a known bug, you
sometimes get the open_basedir error when using relative paths.

In the end I went:

$root = $GLOBALS["SCRIPT_NAME"];
$root = str_replace("setup.php", "", $root);

The last line was to get the name of the file out of the directory
path. Isn't there another way to get the path, without the file name?

Jul 17 '05 #3
lk******@geocities.com wrote:
I fixed this by using DOCUMENT_ROOT and therefore an absolute address,
rather than a relative one. This is apparently a known bug, you
sometimes get the open_basedir error when using relative paths.

In the end I went:

$root = $GLOBALS["SCRIPT_NAME"];
$root = str_replace("setup.php", "", $root);

The last line was to get the name of the file out of the directory
path. Isn't there another way to get the path, without the file name?


Use strrpos to find the last position of "/", then substr it from the
first position to the position returned from strrpos.
Jul 17 '05 #4
On 20 Dec 2004 11:54:15 -0800, lk******@geocities.com wrote:
I fixed this by using DOCUMENT_ROOT and therefore an absolute address,
rather than a relative one. This is apparently a known bug, you
sometimes get the open_basedir error when using relative paths.

In the end I went:

$root = $GLOBALS["SCRIPT_NAME"];
$root = str_replace("setup.php", "", $root);

The last line was to get the name of the file out of the directory
path. Isn't there another way to get the path, without the file name?


http://php.net/manual/en/ref.filesystem.php
http://php.net/dirname

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Juho Saarikko | last post: by
5 posts views Thread by Juho Saarikko | last post: by
reply views Thread by Nils Valentin | last post: by
11 posts views Thread by comp.lang.php | last post: by
3 posts views Thread by Simon Brooke | last post: by
7 posts views Thread by Dave Kelly | last post: by
4 posts views Thread by aldsaldrin | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.