Page 1 of 1

Login tie-in with phpBB

Posted: Wed Mar 08, 2006 3:21 pm
by LiveFree
Hey!

I am developing a phpBB - intergrated Login system for UberHardware .. but what I need to know is if there is a global variable phpBB checks for isset or empty to determine if the user is logged in.

like for example...

Code: Select all

<form method='POST' action='/phpBB/login.php'>
But then how would I access the user details when phpBB loggs him in?

I have seen a few refrences to:

Code: Select all

$userdata[]
Any and All Help is appriciated!

Posted: Wed Mar 08, 2006 3:36 pm
by neophyte
Set up the system variables some where near the top of the page before headers are sent...

Code: Select all

define('IN_PHPBB', true);
   $phpbb_root_path = '/somepath/toyour/root/';
  include($phpbb_root_path . 'extension.inc');
   include($phpbb_root_path . 'common.php');
   // Start session management
   define('PAGE_HOMEPAGE', -12);
   $userdata = session_pagestart($user_ip, PAGE_HOMEPAGE);
   init_userprefs($userdata);
   // End session management
   //
The login:

Code: Select all

<?php if(!$userdata['session_logged_in']){ ?>
 			
        <h3>Login</h3> 
            <form action="forum/login.php" method="post" enctype="">
                    User name:<br />
                      <input  size="12" name="username" /><br />
					  Password:<br />
                      <input  type="password" size="12" name="password" /><br />
                      <input  type="submit" value="Login" name="login" />
                      <br />
                      Not a member? <a href="<?php echo "http://".$board_config['server_name']; ?>/forum/profile.php?mode=register" class="boldblack">Join Today</a> <br />
                      <a href="http://<?php echo $board_config['server_name']; ?>/forum/profile.php?mode=sendpassword" class="boldblack">Forgot Password?</a>
            </form>
        <?php } else { 
          		$avatar = get_avatar($userdata['user_avatar_type'], $userdata['user_allowavatar'],  $userdata['user_avatar']);
				if ($avatar === false){
				 	$avatardisplay = ''; 
				} else {
					$avatardisplay = '<p><a href="http://'.$board_config['server_name'].'/forum/index.php">'.$avatar.'</a></p>';
				}			
				echo ' 
				    <p>Welcome back:</p>
				    <h2>'.$userdata['username'].'</h2>
				    '.$avatardisplay.'
				     <p>Total Posts: '. $userdata['user_posts'].'<p>
					<p> Registered: '. date('d M Y', $userdata['user_regdate']). ' </p>
					<p><a href="http://'.$board_config['server_name'].'/forum/index.php">boards</a> | <a href="http://'.$board_config['server_name'].'/forum/login.php?logout=true&sid='.$userdata['session_id'].'">log out</a></p>';  
			}
		?>
That should get you started. The get Avatar function is not native. I built it out of the phpbb code. If it gives you trouble yank it...