使用 PhpBB 会话数据的应用程序 - 无法使用短代码

发布于 2024-07-08 06:03:21 字数 792 浏览 6 评论 0原文

我之前已经构建过利用 phpBB 会话和用户数据的 Web 应用程序。 常见的做法是使用这样的代码:

define('IN_PHPBB', true);
//replace $phpbb_root_path with path to your forum
$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();

但是,通过包含 common.php,我带来了一堆其他方法,这些方法会遇到我设置的其他方法。

在我的示例中,我使用 CodeIgniter 运行应用程序,它已经具有“重定向”方法。 这个问题应该适用于任何拥有可能遇到 phpBB 方法的预构建方法的人。

基本上,我需要做的就是:

  1. 确保用户已登录 $user->data[username] == Anonymous
  2. 利用 '$user->data' 中的数据,例如用户的ID、屏幕名称等。

我可以获取 $user->data 数组,并以某种方式将其保存到我自己的会话中吗? 有人对此有什么想法吗? 提前致谢!

I've built web apps before that utilize phpBB session, and user data. The common move is to use code like this:

define('IN_PHPBB', true);
//replace $phpbb_root_path with path to your forum
$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();

However, by including common.php, I bring along a crap-load of other methods that run into other methods I've got setup.

In my example, I'm running the application using CodeIgniter, which already has a "redirect" method. This question should apply to anyone who has pre-built methods that may run into the phpBB methods.

Basically, all I need to do is:

  1. Make sure the user is logged in $user->data[username] == Anonymous
  2. Utilize data from '$user->data' such as the user's ID, screenname, etc.

Could I grab the $user->data array, and somehow save it to my own session? Does anyone have any ideas on this? Thanks in advance!

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

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

发布评论

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

评论(2

小傻瓜 2024-07-15 06:03:21

你已经遇到了我讨厌框架作品的主要原因。
你永远不知道其中包含了什么。 特别是当代码不是面向对象时。 (如果您的函数属于对象,而不是在全局空间中自由浮动,那就更好了。)

假设您的代码已经定义了会话处理程序,则没有什么可以阻止您使用常规会话命令。

例如:
$_SESSION['user_data_array'] = $user->data ;

然后稍后使用会话数据

$data = $_SESSION['user_data_array'];

当写入会话处理程序时,它会替换当前的会话处理程序。 (我假设已经这样做了,以便会话存储在数据库中,而不是服务器上。)

如果它没有被替换,那么您仍然可以使用 PHP 的默认会话处理程序。始终记住会话详细信息保存到当前网络服务器上的文件夹中。 因此,如果您的应用程序跨多个服务器运行,并且用户在后续访问时由不同的服务器提供服务,则会话数据将不可用。 (因此需要编写会话处理程序来保存多个服务器之间的会话数据。)

You have run into the primary reason i hate frame works.
You never know just what is being included. Especially when the code is not object orientated. (much better if your function belong to objects, rather than floating free in a global space.)

Assuming your code has a defined session handler already in place, there is nothing stopping you from using the regular session commands.

eg:
$_SESSION['user_data_array'] = $user->data ;

then later on using teh session data

$data = $_SESSION['user_data_array'];

When a session handler is written, it replaces the current session handler. (I assume that has been done so that the session is stored in the database, rather than on the server.)

If it has not be replaced, then you can still use PHP's the default session handler.. Always bear in mind that the session details are saved to a folder on the current webserver. So if your application is run across multiple servers, the session data will be unavailable if the user is being served by a different server on a subsequent visit. (hence the need for writing session handlers to preserve the session data between multiple servers.)

纵性 2024-07-15 06:03:21

phpBB 将验证数据库中存储的密码的算法从版本 2.x 更改为 3.0。 (它曾经只是一个 MD5 函数。)但是,如果您可以找到他们的半 SDK url(手头没有),那里有关于如何在比您描述的更高的抽象级别上使用他们的用户验证的帖子。

在这种情况下,如果你要利用他们的资源,你需要按照他们的方式去做(在这种情况下比以前更明确)。

我同意无论哪种方式这都是一个冒险的决定; 特别是因为 phpBB 在设计质量方面没有特别令人钦佩的记录。

phpBB changed the algorithm for validating the password stored in the database from version 2.x to 3.0. (It used to be just an MD5 function.) But if you can find their semi-SDK url (don't have it at hand) there are postings there about how to use their user verification at a higher level of abstraction than you describe.

This is a case where, if you're going to tap their resource, you need to do it their way (which in this case is more explicit than it used to be.)

I agree it's a dicey decision either way; especially since phpBB doesn't have a particularly admirable record for design quality.

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