Invision Board

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Invision Board

Post by dwfait »

Im going to create a 'members area' for a website which shares its members database with the one invision board uses. Would there be a way to share logons aswell? So like, when you logon on the site, youd automatically be logged on in the forums, and vise versa. I dont want to use the forum login page for both...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you have to pass/set all information needed to be marked as logged-in through invision, typically, this involves using the session table (if it uses one) along with any cookies/session id information it requires.
dwfait
Forum Contributor
Posts: 113
Joined: Sun Aug 01, 2004 10:36 pm

Post by dwfait »

Thanks for the fast reply..

It does indeed have a sessions table.

In SSI.php, which is a php file which you can call from, from your website, there is a function to show the users that are online:

Code: Select all

function do_active()
{
	global $DB, $ibforums, $templates_dir, $std;
	
	// Load the template...
	
	$template = load_template("active.html");
	
	$to_echo = "";
	
	if ($ibforums->varsї'au_cutoff'] == "")
	{
		$ibforums->varsї'au_cutoff'] = 15;
	}
	
	//--------------------------------
	// Get the users from the DB
	//--------------------------------
	
	$cut_off = $ibforums->varsї'au_cutoff'] * 60;
	$time    = time() - $cut_off;
	$rows    = array( 0 => array( 'login_type'   => substr($ibforums->memberї'login_anonymous'],0, 1),
								  'running_time' => time(),
								  'member_id'    => $ibforums->memberї'id'],
								  'member_name'  => $ibforums->memberї'name'],
								  'member_group' => $ibforums->memberї'mgroup'] ) );
	
	$DB->simple_construct( array( 'select' => 'id, member_id, member_name, login_type, running_time, member_group',
								  'from'   => 'sessions',
								  'where'  => "running_time > $time",
								  'order'  => "running_time DESC"
						 )      );
	
	
	$DB->simple_exec();
	
	//-----------------------------------------
	// FETCH...
	//-----------------------------------------
	
	while ($r = $DB->fetch_row() )
	{
		$rowsї] = $r;
	}
	
	//--------------------------------
	// cache all printed members so we
	// don't double print them
	//--------------------------------
				
	$cached = array();
	$active = array();
	
	foreach( $rows as $result )
	{
		if ($resultї'member_id'] == 0)
		{
			$activeї'GUESTS']++;
		}
		else
		{
			if (empty( $cachedї $resultї'member_id'] ] ) )
			{
				$cachedї $resultї'member_id'] ] = 1;
				
				if ($resultї'login_type'] == 1)
				{
					$activeї'ANON']++;
				}
				else
				{
					$activeї'MEMBERS']++;
				}
			}
			
		}
	}
	
	$activeї'TOTAL'] = $activeї'MEMBERS'] + $activeї'GUESTS'] + $activeї'ANON'];
			   
	
	$to_echo  = parse_template( $template,
								array (
										 'total'   => $activeї'TOTAL']   ? $activeї'TOTAL']   : 0 ,
										 'members' => $activeї'MEMBERS'] ? $activeї'MEMBERS'] : 0,
										 'guests'  => $activeї'GUESTS']  ? $activeї'GUESTS']  : 0,
										 'anon'    => $activeї'ANON']    ? $activeї'ANON']    : 0,
									  )
								);
	
	
	echo $to_echo;
	
	exit();
	
}
But i dont understand that..

And i really wouldnt know how to pass the information or cookies through invision. Could anyone help me with this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there should be a core set of functions called on all pages that starts up the session system and page. All the functionality called for starting the session and page should be called for each page you wish to have the user log in/status tracking. There should be a login function/class that requires calling when a log in request happens through the normal board. This functionality should be called when a user attempts to log in through the other pages.

Often it's a pain to integrate the login functionality from forums. At least that's how trying to integrate the log in for phpbb was like the first time I tried it. :)
Post Reply