In many cases, we need to create a forum for the website. Of course, we cannot write a complete Forum from the beginning. In this case, the more economical approach is to adopt an open Source code Forum Program And then do a good job of Single Sign-On transformation.
The phpBB Forum program can be easily integrated with your website. The official website provides the sessions integration of phpbb3 and the sessions integration model of phpbb2. Article . Because the official website has stopped the maintenance of phpbb2, we will briefly introduce the bridging method of phpbb3 sessions.
First, set the following section Code Add to the page where you want to bridge phpbb3:
<? PHP define ('in _ phpbb', true); $ phpbb_root_path = (defined ('phpbb _ root_path '))? Phpbb_root_path :'. /'; $ phpex = substr (strrchr (_ file __,'. '), 1); Include ($ phpbb_root_path. 'Common. '. $ phpex );
// Start session management $ user-> session_begin (); $ auth-> ACL ($ user-> data); $ user-> setup ();?>
Note that the $ phpbb_root_path variable defines the relative path between your phpbb3 and your current file. You need to modify it according to your actual situation. For example, my phpbb3 is installed in the Forum directory, and I should replace it with the following code:
$ Phpbb_root_path = (defined ('phpbb _ root_path '))? Phpbb_root_path: './FORUM /';
Do not forget the last "/" directory character. Otherwise, the following code will go wrong.
The next step is to determine whether a user has logged on. If yes, the welcome message is output. If no, the login message is displayed.
<? PHP if ($ user-> data ['user _ id'] = anonymous) {echo 'Please login! ';}
Else {echo 'Thanks for logging in, '. $ user-> data ['username _ clean'];} [...]