Toon posts:

[php] de login van PHPBB met een class

Pagina: 1
Acties:
  • 327 views sinds 30-01-2008

Verwijderd

Topicstarter
Dit heb ik gevonden op een site en wil ik gaan gebruiken, echter ik snap niet wat ze bedoelen, kan iemand het wat beter uitleggen? met voorbeeldscript het liefst?
(ps. niet te snel een slotje graag, want hier staat echt niks over in andere onderwerpen, wel iets wat er op lijkt, maar niet hierover!)

Dit is het verhaal van de bedenker:
Since phpBB has its own user management system and many sites that want to integrate it also have their own user management system, a solution for integrating both systems is often necessary.

The approach of this class to solve that problem is to artificially initiate a login session when the user has successfully authenticated in the login system that the site already had.

This way the users only have to authenticate once to use either the pages of the site or the pages of the phpBB system that require authentication.
Dit is een example script:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?

/*
 * These examples show you how to integrate the phpBB
 * login in and authentication system with your website.
 * 
 * Since we quite like our login system and it's proven
 * itself to be very extensible, we don't want to replace
 * but we do want to have a universal login system for
 * both our website *and* the forum.
 *
 * To take full advantage of this PHPBB_Login class you'll
 * need to modify your own login system to include a call
 * to the relevant login or logout methods.
 *
 * This way, you can handle all of the website login as normal,
 * and also log the user into phpBB in the same step.
 *
 * This system is reliant on the website username being exactly
 * the same as the phpBB username. To insure this, I recommend
 * disabling the ability to change usernames from within the 
 * phpBB admin control panel.

 
/* Example 1: Logging in */

session_start();

/* First, login the user using your own login system, for example; */
$user = new User();

// username and password are implied here,
// they will most likely be form variables
$user->login( $username, $password );

// Then login the user to the forum
$phpBB = new PHPBB_Login();

$phpbb->login( $user->id );




/* Example 2: Logging out */

session_id();

$user = new User();

/* First, logout the user from the forum */
$phpBB = new PHPBB_Login();

$phpbb->logout( session_id(), $user->id) ;

/* Then logout the user from your own login system */
$user->logout( $user->id );

?>

en dit de 'phpbb_login class'
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?

/*
 * PHPBB_Login allows you to integrate your own login system
 * with phpBB. Meaning that you can have one login valid across
 * both your website and phpBB.
 *
 * To take full advantage of this PHPBB_Login class you just
 * need to modify your own login system to include a call
 * to the relevant methods in here.
 *
 * This system is reliant on the website username being exactly
 * the same as the phpBB username. To insure this, I recommend
 * disabling the ability to change usernames from within the 
 * phpBB admin control panel.

 
class PHPBB_Login {

    function PHPBB_Login() {
    }

    function login( $phpbb_user_id ) {
        global $db, $board_config;
        global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
    
        // Setup the phpbb environment and then
        // run through the phpbb login process

        // You may need to change the following line to reflect
        // your phpBB installation.
        require_once( './forum/config.php' );
    
        define('IN_PHPBB',true);

        // You may need to change the following line to reflect
        // your phpBB installation.
        $phpbb_root_path = "./forum/";
        
        require_once( $phpbb_root_path . "extension.inc" );
        require_once( $phpbb_root_path . "common.php" );

        return session_begin( $phpbb_user_id, $user_ip, PAGE_INDEX, FALSE, TRUE );
    
    }

    function logout( $session_id, $phpbb_user_id ) {
        global $db, $lang, $board_config;
        global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
    
        // Setup the phpbb environment and then
        // run through the phpbb login process

        // You may need to change the following line to reflect
        // your phpBB installation.
        require_once( './forum/config.php' );
    
        define('IN_PHPBB',true);
        
        // You may need to change the following line to reflect
        // your phpBB installation.
        $phpbb_root_path = "./forum/";

        require_once( $phpbb_root_path . "extension.inc" );
        require_once( $phpbb_root_path . "common.php" );

        session_end( $session_id, $phpbb_user_id );
    
        // session_end doesn't seem to get rid of these cookies,
        // so we'll do it here just in to make certain.
        setcookie( $board_config[ "cookie_name" ] . "_sid", "", time() - 3600, " " );
        setcookie( $board_config[ "cookie_name" ] . "_mysql", "", time() - 3600, " " );

    }

}

?>

Welnu: wie snapt dit meer dan ik....
Ik wil kunnen inloggen op forum of op rest van site, maar voor allebei ingelogd zijn

[ Voor 12% gewijzigd door Verwijderd op 27-10-2004 12:39 ]


  • Tys
  • Registratie: Januari 2003
  • Laatst online: 07:22

Tys

Verwijderd schreef op 27 oktober 2004 @ 12:37:
Ik wil kunnen inloggen op forum of op rest van site, maar voor allebei ingelogd zijn
Leg uit, want hier begrijpen mensen (ik in ieder geval) vrij weinig van, misschien dat we je in de goede richting kunnen schoppen (volledige script requests mogen hier niet.)

My flight statistics: (456.693km in 128 flights) Next trips: Krakow, Prague, Malta


Verwijderd

Topicstarter
Okay, ik heb zelf een script waarmee ik eenvoudig kan inloggen
en daarnaast heb ik een PHPBB forum waar ik ook op kan inloggen
Deze 2 moeten gebruik gaan maken van dezelfde tabel en user gegevens
Als ik inlog op een gewoon deel van de site met mijn eigen script en ik ga daarna naar het forum dan wil ik dat ik daar ook gelijk voor ingelogd ben en niet nog een keer hoef in te loggen.
Andersom hetzelfde.
Hij moet dus de session
if( !$userdata['session_logged_in'] )
onthouden

  • chem
  • Registratie: Oktober 2000
  • Laatst online: 08:48

chem

Reist de wereld rond

Uh jah, dit is dus een script request.

En daar doen we niet aan :)

Klaar voor een nieuwe uitdaging.


Dit topic is gesloten.