Login integration

Discussion in 'PHP' started by primeelite, Feb 10, 2008.

  1. #1
    I was wondering what would be the best way to take a login from my phpbb board and add it to my regular homepage and if this can be done. Thanks in advance for any help.
     
    primeelite, Feb 10, 2008 IP
  2. SecureWebDev

    SecureWebDev Active Member

    Messages:
    677
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    80
    #2
    i dont have experience doing this bet im sure it can be done. you can create the login form with the same values and then make it post to the login page.
     
    SecureWebDev, Feb 10, 2008 IP
  3. Cobnut

    Cobnut Peon

    Messages:
    184
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Primeelite,

    It certainly can be done, although the method is different for PHPBB3 and PHPBB2. Which version are you using? For PHPBB3, essentially all you need do is include the following lines in the header of each of your 'external' pages. So, if your main site is the root of your domain and the forum is in /forum, as follows:
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forum/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    $user->session_begin();
    $auth->acl($user->data);
    PHP:
    This will allow you to access the methods/properties of the 'user' class within PHPBB so you can get a username using:
    $username=$user->data['username'];
    PHP:
    and test for registration
    $user->data['is_registered']
    PHP:
    There's one little 'trick' you need to use to go back to the forum from your external pages and that's to add the SID to the URL. I do this as follows:
    
    $sid=$user->session_id;
    $lgedin=($sid&&$_GET['sid'] === $user->session_id)? "?sid=".$sid : "";
    PHP:
    and then append $lgedin to the URL for any external links that point within the forum (by testing the $_SERVER['SCRIPT_NAME']).

    To allow login/logout from the external pages, I just provide links to the relevant pages within the forum structure.

    I'm afraid I can't recall how to do it in V2, but I think the PHPBB community forum has answers to this. LaterHmm, just re-read your OP and realised you may have been asking a different question - is this what you want?

    Hope this helps,

    Jon
     
    Cobnut, Feb 11, 2008 IP
  4. primeelite

    primeelite Peon

    Messages:
    1,825
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I am actually using PHPBB2. I am also using wordpress for the main site I dont know if this matters at all tho
     
    primeelite, Feb 11, 2008 IP