本文介绍了Phpbb3 论坛与现有站点的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 phpbb 论坛与我现有的站点集成.我已经看过这些 链接,它似乎不起作用.我已经复制了这段代码

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

到 loginforum.php 文件中,我将其包含在我希望保留会话的每个页面中.我已经完成了会话集成部分中指示的三个步骤,但是当我尝试检查用户是否通过身份验证时,似乎并非如此.在这里使用相同的代码:

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?

推荐答案

试试这个:

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

这是 PHPBB 数据库中的第一个(也是访客)用户:

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

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

结果:

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

这篇关于Phpbb3 论坛与现有站点的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 18:36