...

View Full Version : open_basedir restriction in effect error in PHP



BenR41
02-25-2008, 12:57 PM
This must be one of the most annoying errors to get when working with php. This error occurs when PHP can't find the specified file in the include statement. This often occurs when a developer has built an application on their machine and uploaded the application to a shared hosting account or if they move the application to a sub folder.

An easy work around is to determine the path to the called file dynamically.


$folcnt = substr_count($_SERVER["PHP_SELF"], "/");
$folappstep = "";
if($folcnt > 1) {
for($i=2;$i<=$folcnt;$i++) {
$folappstep .= "../";
}
} else {
$folappstep = "";
}

include $folappstep."filename.php";

Ben

LTS Media Ltd.

Note: This method doesn't check to see if the file exists, and it might be possible to exploit it because there's no filename whitelist.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum