Page 1 of 1

Integration problem after 3.1: get_container_filename() and phpbb_root_path

Posted: Wed Dec 24, 2014 7:00 pm
by gianluigi.zanettini
I'm experiencing some major problem while migrating my site from phpBB 3.0 to 3.1

My site works like this: I have my site in pages such as /user/site/index.php and my phpBB installation in /user/site/forum/ . With phpBB 3.0, I was doing the suggested step to integrate phpBB's users session with my site:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = "/user/site/forum/";

require_once($phpbb_root_path  . 'common.php');
require_once($phpbb_root_path  . 'includes/functions_user.php');
require_once($phpbb_root_path  . 'includes/functions_content.php');
require_once($phpbb_root_path  . 'includes/functions_posting.php');

$user->session_begin();
$auth->acl($user->data);
$user->setup();
It worked flawlessly as expected.

Since I upgraded to phpBB 3.1, this no longer works:
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/di/container_builder.php on line 136: file_exists(): open_basedir restriction in effect. File(/user/site/forum/cache/container_/user/site/forum/.php) is not within the allowed path(s)
Nevermind that I have open_basedir set. The problem is that it's just screwing the path. To me, it seems to be related to this function:

Code: Select all

	protected function get_container_filename()
	{
		$filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path);
		return $this->phpbb_root_path . 'cache/container_' . $filename . '.' . $this->php_ext;
	}
To me, it expect $phpbb_root_path to be something like ./ and is not ready to handle a full path.

Am I missing something? what should I set $phpbb_root_path to?

Re: Integration problem after 3.1: get_container_filename() and phpbb_root_path

Posted: Thu Dec 25, 2014 10:42 am
by gianluigi.zanettini
Ok, since I needed to fix this issue quickly, I punched through with an horror such as this (SiteDir is a constant defined as the path to my site root, i.e. /user/site/):
$dai=$_SERVER["SCRIPT_FILENAME"];
$dai2=str_ireplace("\\", "/", SiteDir);
$dai=str_ireplace($dai2, "", $dai);

$depth=substr_count($dai, "/");
$dai="";

for($i=0; $i<$depth; $i++)
{ $dai="../"; }

$dai.="forum/";

$phpbb_root_path=$dai;
I think this ain't right, but it did was effective.

If someone can show me the phpBB-intended way to do this, I'll be more than happy to throw this code away!

Thanks!