gpt4 book ai didi

php - CodeIgniter 和 PhPBB 3.1.3 集成

转载 作者:行者123 更新时间:2023-12-01 16:23:50 25 4
gpt4 key购买 nike

我开发了一个基于CodeIgniter的网站,最新版本2.2.1,并安装了PhPBB论坛(版本3.1.3)。

我想在我的网站上使用论坛的功能(如连接/个人资料等)。我看过这个网站:http://www.3cc.org/blog/2010/03/integrating-your-existing-site-into-phpbb3/简单地显示我的伪。

我的 Controller 只是第一段的复制/粘贴

class Forum_test extends CI_Controller{

function __construct()
{
parent::__construct();
}

function index()
{
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
}
}

我的问题是当我尝试使用此代码时,出现以下错误

Fatal error: Call to a member function header() on a non-object in /var/www/forum/phpbb/session.php on line 224

但是如果我创建一个简单的文档,仅使用

<?php
define('IN_PHPBB', true);

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management

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

它有效(我没有任何错误)

您知道我的代码有什么问题吗?

谢谢。

最佳答案

所以......我经过长期研究找到了解决方案......

https://www.phpbb.com/community/viewtopic.php?f=71&t=2287546

解决方案是在函数索引中添加全局变量

global $request;
global $phpbb_container;
global $phpbb_root_path, $phpEx, $user, $auth, $cache, $db, $config, $template, $table_prefix;
global $request;
global $phpbb_dispatcher;
global $symfony_request;
global $phpbb_filesystem;

关于php - CodeIgniter 和 PhPBB 3.1.3 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28586272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com