Phpbb3 forum integration with existing site

萝らか妹 提交于 2019-12-24 07:09:36

问题


I am trying to integrate the phpbb forum with my existing site. I have already looked at these links, and it doesn't seem to work. I have copied this code

define('IN_PHPBB', true);
define('ROOT_PATH', "/path/to/forums"); 
    if (!defined('IN_PHPBB') || !defined('ROOT_PATH')) {
exit();
}
$phpEx = "php";
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : ROOT_PATH . '/';
include($phpbb_root_path . 'common.' . $phpEx);

$user->session_begin();
$auth->acl($user->data);

into a loginforum.php file, which I include in every page I want the sessions to be kept. I have done the three steps indicated in the sessions integration section, but when I try to check whether the user is authenticated, it doesn't seem so. Using the same code here:

<?php
if ($user->data['user_id'] == ANONYMOUS){
    echo 'Please login!';
}
else{
    echo 'Thanks for logging in, ' . $user->data['username_clean'];
}
?>

I only get the "Please login" phrase, even when I login.

I've been over this for hours, I don't understand where the problem is. Shouldn't it work after the three miraculous steps?


回答1:


Try this:

if ($user->data['username'] == 'Anonymous')
{
    echo 'Please login!';
}

This is the first (and guest) user in the PHPBB database:

SELECT  `user_id`, 
    `username`, 
    `username_clean` 
    FROM 
`phpbb_users` WHERE user_id = 1

Result:

"user_id"   "username"  "username_clean"
"1" "Anonymous" "anonymous"


来源:https://stackoverflow.com/questions/7161416/phpbb3-forum-integration-with-existing-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!