2010-04-23 67 views
0

我將phpbb3集成到我的網站中。當用戶登錄到我的網站時,有一個名爲forum的選項卡。如果他點擊論壇,它會進入一個頁面,要求用戶名和密碼登錄。但我想當用戶點擊論壇,然後他不得不直接去他的帳戶詳細信息的論壇,而無需再次登錄。如何從我的網站直接登錄到phpBB3?

請幫幫我......

+1

您是否在使用任何CMS?通常,這種事情需要在phpBB和主站點設置之間同步用戶表。例如,我聽說過Joomla的插件,它可以爲你處理。如果我們更瞭解您的設置,我們可能會指出您朝着正確的方向。 – 2010-04-23 12:21:00

+0

當ajax調用返回成功,然後刷新當前頁面時,您也可以使用jquery/ajax進行登錄,而無需用戶離開頁面。我使用相同的東西來爲我的Facebook開發phpbb mod – 2013-05-06 01:09:39

回答

0

我實際上做了同樣的事情,用戶在我的網站上註冊,同時我也會自動爲他們創建一個phpbb帳戶。

這裏是我用來註冊它們的代碼(我用我的散列函數,我不使用密碼phphash函數MD5散列的口令散列實際上已經一個散列密碼):

//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"; 

然後記錄他們在我使用這個:

//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); 
} 

顯然,你可能需要改變這個局面一點,我做了很多檢查之前,甚至已經開始將它們註冊或登錄他們希望這有助於如果有人看到我不正確的話,請l我知道。