I integrated phpbb3 into my site.When a user login into my website then there is a tab called forum. If he clicks on the forum it will take to a page where it asking user name and password to login. But 开发者_StackOverflowi want when the user clicks on the forum then he has to directly go to forum with his account details without logging again.
Please help me......
I actually did this exact same thing, A user registers on my site and at the same time i would automaticaly create them a phpbb account as well.
Here is the code I use to register them (I don't use the phphash function for passwords, I use my hash functions. The md5 hash for the password is actually hashing a already hashed password):
//Register the user on the forum code
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template,$auth;
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './Forums/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
require('./Forums/includes/functions_user.php');
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewtopic');
$user_row = array(
'username' => $username, //REQUIRED IN FORM
'user_password' => md5($password_1), //REQUIRED IN FORM
'user_email' => $email, //REQUIRED IN FORM
'group_id' => 2,//(int) $group_id,
'user_timezone' => $timezone = date(Z) / 3600,//(float) $data[tz],
'user_dst' => date(I),//$is_dst,
'user_lang' => $user->lang_name,//$data[lang],
'user_type' => USER_NORMAL,//$user_type,
'user_actkey' => '',//$user_actkey,
'user_ip' => $user->ip,
'user_regdate' => time(),
'user_inactive_reason' => 0,//$user_inactive_reason,
'user_inactive_time' => 0,//$user_inactive_time,
);
//Register user on the forum
$forum_user_id = user_add($user_row);
return "both_registered";
Then to log them in I use this:
//Now log them into the forum
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template, $auth;
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : getcwd().'/Forums/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
require(getcwd().'/Forums/includes/functions_user.php');
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Begin phpBB login
if(!$user->data['is_registered'])
{
$username = $username;
$password = $password;
$autologin = 1;
$result = $auth->login($username, $password, $autologin);
//print_r($result);
}
Obviously you might need to change this around a little, I do alot of checks before it even gets to registering them or logging them in. Hopefully this helps and if anyone sees something i am not doing right then please let me know.
精彩评论