Phbb3 论坛与现有站点集成

发布于 2024-12-01 00:12:23 字数 1012 浏览 1 评论 0原文

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

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 文件中,该文件包含在我希望保留会话的每个页面中。我已经完成了会话集成部分中指示的三个步骤,但是当我尝试检查用户是否经过身份验证时,情况似乎并非如此。在这里使用相同的代码:

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

即使我登录,我也只收到“请登录”短语。

我已经研究了几个小时了,我不明白问题出在哪里。神奇的三步之后不是应该就可以了吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍白女子 2024-12-08 00:12:23

试试这个:

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

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

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

结果:

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

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文