Page 1 of 1

Integrating phpBB into my site

Posted: Thu Sep 06, 2007 11:52 pm
by Wishbone
I'm starting up a site that will contain some public content, but much of the content will only be available to members. I currently have my own database for the member info, and would like to integrate a phpBB forum into my site.

It's an easy process for my site to refer to the phpbb members table for login names, and md5 passwords. I would rather not have a separate login for the site and for the forum, and would like to use phpBB's authentication for the site. also just recently read an article that shows how to use phpBB session information to restrict access to content, and to have my own login/password form on the site and have phpBB authenticate it, and set up the user session.

Here is the issue. My users might go to the site to peruse the content, etc, and might not want to browse the forum at that time. The issue will be that the forum will be "marked as read" when they leave and come back to view what they missed in the forum. Is there some way to log into a phpBB session, but not update the "last visited" field in the database, unless they actually browse the forum?

I'm trying not to have a separate login for the site, and for the forum, even if they use the same database.

Wayne
http://foas.us

Re: Integrating phpBB into my site

Posted: Fri Sep 07, 2007 4:23 am
by drathbun
One thing you could do is to set an additional variable like IN_PHPBB that is set only on your site pages, rather than the phpBB pages. If that var is set, then skip updating the last_visit during the sessions logic.

Since you're looking for "how to" coding tips, the best place is the MOD Writers forum rather than the discussion forum, so I will move your topic there now.

Re: Integrating phpBB into my site

Posted: Fri Sep 07, 2007 8:17 pm
by Wishbone
drathbun wrote:One thing you could do is to set an additional variable like IN_PHPBB that is set only on your site pages, rather than the phpBB pages. If that var is set, then skip updating the last_visit during the sessions logic.
That would be pretty easy to setup another variable, but your mentioning of "skipping updating the last_visit" during the session is exactly what I'm trying to achieve.. How is that done?

Re: Integrating phpBB into my site

Posted: Sat Sep 08, 2007 6:04 am
by battye
It is in this part of sessions.php:

Code: Select all

		$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time; 

		if (!$admin)
		{
			$sql = "UPDATE " . USERS_TABLE . " 
				SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
				WHERE user_id = $user_id";
			if ( !$db->sql_query($sql) )
			{
				message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
			}
		}

		$userdata['user_lastvisit'] = $last_visit;

Re: Integrating phpBB into my site

Posted: Tue Sep 11, 2007 5:23 pm
by Wishbone
This post had been moved to the Mod Writers forum, but I'm a bit too new to start writing mods, though it is something I want to do. I was hoping that there was a feature for this or an existing mod.

With all the posts here and elsewhere about using the phpBB authentication system to grant access to specific parts of websites, I was hoping for an easy way to not mark forum posts read if the forum wasn't actually viewed.

I can probably hack the code to not update last_visit when logging into the site itself by using a variable as suggested, but if the user does actually view the forum in that session, last_visit won't be updated, unless I insert more code into the phpBB scripts to update it when the forum index is viewed the first time and not subsequent times. If a user jumps to a specific URL in the forum, this will be bypassed unless I insert this code in each of the forum php scripts, unless I can hack some central init routine that all the scripts call to do this.

Thanks for the help,

Wayne