Site Integration with 3.2.0

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
Retrospek
Registered User
Posts: 2
Joined: Mon Feb 27, 2017 9:02 pm

Site Integration with 3.2.0

Post by Retrospek » Mon Feb 27, 2017 9:10 pm

Just installed a new clean copy of the phpBB 3.2.0 onto a site, and it went very smoothly. Everything is working on the forums. The forums are located off the root as "/forums/", and the cookie path is set to "/". If I try to get username and is_registered from within the forums directory, it works fine. If I try to from the root, I get an error:
Fatal error: Call to a member function getParameter() on null in /homepages/htdocs/gw2.thehaven-we.com/forums/phpbb/cache/driver/file.php on line 37
And the code I'm using is:

Code: Select all

		define('IN_PHPBB', true);
		$phpbb_root_path = './forums/';
		$phpEx = substr(strrchr(__FILE__, '.'), 1);
		include($phpbb_root_path . 'common.' . $phpEx);
		
		// Start session management
		$user->session_begin();
		$auth->acl($user->data);
		$user->setup(); 
		
		if (!$user->data['is_registered']) {
			// Noone is logged in, redirecting to login, then back here...
			header( 'Location: http://gw2.thehaven-we.com/forums/ucp.php?mode=login&redirect=/' ) ;
			exit();
		}
Thanks for any help anyone can provide on this.
Last edited by JimA on Mon Feb 27, 2017 9:46 pm, edited 1 time in total.
Reason: Moved from 3.2 Support Forum

User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Re: Site Integration with 3.2.0

Post by MichaelTunnell » Tue Feb 28, 2017 2:02 am

It appears that your forum is not at /forums but rather /forums/phpbb based on this file path in the error: "/homepages/htdocs/gw2.thehaven-we.com/forums/phpbb . . ."

So the following should fixed it:

Code: Select all

$phpbb_root_path = './forums/phpbb/';
Alternatively a really simple solution is to include the full path of the forum on the server in the $phpbb_root_path variable.

for example:

Code: Select all

$phpbb_root_path = '/homepages/htdocs/gw2.thehaven-we.com/forums/phpbb/';
The above full path will guarantee it to work regardless of where it is used on the server but it won't be portable to other servers unless the path is changed where it is used. I would suggest adding that variable to a configuration file of whatever site system you use so it can be a global variable.

Retrospek
Registered User
Posts: 2
Joined: Mon Feb 27, 2017 9:02 pm

Re: Site Integration with 3.2.0

Post by Retrospek » Tue Feb 28, 2017 5:12 am

Unfortunately, the './forums/phpbb' solution didn't work. The actual forums do reside in "./forums/" directory, but oddly enough, the "file.php" is in a subdirectory off that in "./forums/phpbb/". Anyhow, I found a work around for the time being.

Turns out that my main page was including another script (for login verification and header), and for whatever reason, that was causing the issue. So, if I just include the script in each page on the site, it should remedy the problem. Not ideal, but it works, I suppose.

Thanks anyhow for the suggestion, it was definitely worth a shot. :)

User avatar
nextgen
Jr. Style Validator
Posts: 2334
Joined: Mon Jul 26, 2010 10:58 pm
Location: Guatemala
Name: Melvin García
Contact:

Re: Site Integration with 3.2.0

Post by nextgen » Thu Mar 02, 2017 4:38 am

Use $phpbb_root_path = 'forums/';

Omit my comment, your problem is other...
メルビン・ガルシア • Xtrato SolutionsMy active styles for phpBBphpBB Argentina - Soporte en español🇦🇷

Please do NOT contact for support via PM or email.

User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Re: Site Integration with 3.2.0

Post by MichaelTunnell » Mon Mar 06, 2017 3:09 am

Oddly enough, I am having the exact same error/issue with my site integration efforts.

I think it is because there are conflicting variables like one platform has a "$config" and so does phpbb.

User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Re: Site Integration with 3.2.0

Post by MichaelTunnell » Sat Mar 11, 2017 3:03 am

Ok I think I have solved this issue @Retrospek

I wrote my own CMS and am using the integration in a custom structure so it wont apply directly to you but here is what solved it for me.

I needed to include some global variables for the session integration to work, which may or may not be needed for you. If needed feel free to use, if not then just delete that part of the following code.

Code: Select all

global $phpbb_container, $phpbb_root_path, $phpEx, $user, $auth, $cache, $db, $config, $template, $table_prefix, $phpbb_dispatcher;
define('IN_PHPBB', true);
define('ROOT_PATH', "/path/to/forum");
$phpEx = "php";
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : ROOT_PATH . '/';
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
Then after lots of trial and error I found that phpbb's session system does NOT like the usage of $_GET global variable. I am not sure why but it that is why we received the error.

I had a $_GET variable being called after the inclusion of the session management. I still needed the variable so I created a temporary non-global variable to call instead.

I was using the following after the inclusion of the session:

Code: Select all

$_GET['example']
I created a new temp variable above the session inclusion script so it would be called before the session, like this:

Code: Select all

$examplevar = $_GET['example'];
For the rest of the code I would only call to that temp variable, $examplevar.

At this point, I could reliably use the phpbb session integrated with my CMS.

Post Reply

Return to “Extension Writers Discussion”