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:
en dit de 'phpbb_login class'
Welnu: wie snapt dit meer dan ik....
Ik wil kunnen inloggen op forum of op rest van site, maar voor allebei ingelogd zijn
(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:
Dit is een example script: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.
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 ]