在PHPBB3和x2B中自动过帐;操作/恢复用户会话

在PHPBB3和x2B中自动过帐;操作/恢复用户会话,php,session,phpbb3,Php,Session,Phpbb3,我遇到了一个我还没有找到完美解决方案的问题。首先让我概述一下情况。 我在一台服务器上有一个PHPBB3论坛,在同一台服务器上还有一个应用程序(由我开发)链接到论坛。该应用程序只有在您登录到论坛时才可访问,并且只有在您属于特定论坛用户组时,才能访问其中的某些部分。 此外,当用户访问脚本/页面时,应用程序还需要能够通过专用用户(我们称之为“Bot”)以编程方式发布论坛线程/帖子。 所以我需要的是: 1.保存当前登录用户(我们称他为“测试用户”) 2.使用用户“Bot”登录 3.贴一条线/一篇文章。

我遇到了一个我还没有找到完美解决方案的问题。首先让我概述一下情况。 我在一台服务器上有一个PHPBB3论坛,在同一台服务器上还有一个应用程序(由我开发)链接到论坛。该应用程序只有在您登录到论坛时才可访问,并且只有在您属于特定论坛用户组时,才能访问其中的某些部分。 此外,当用户访问脚本/页面时,应用程序还需要能够通过专用用户(我们称之为“Bot”)以编程方式发布论坛线程/帖子。 所以我需要的是: 1.保存当前登录用户(我们称他为“测试用户”) 2.使用用户“Bot”登录 3.贴一条线/一篇文章。 4.销毁会话 5.还原登录用户

这种“排序”一开始起作用,但当反复调用/发布时,前1-2篇文章将由“Bot”发布,但以下内容将由“测试用户”发布。 当前代码:

这在setup.php中,它包含在所有相关脚本中

    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
 $phpEx = substr(strrchr(__FILE__, '.'), 1);
 // The common.php file is required.
 include($phpbb_root_path . 'common.' . $phpEx);
 // this is required for auto posting
 include($phpbb_root_path . 'config.' . $phpEx);
 include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
 include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
这是函数本身,在另一个脚本中

require_once 'setup.php';
function create_forum_post($subject, $text, $forumid, $posting_userid, $topic_id=NULL) {

 if(!PHPBB_SESSION_INTEGRATION) return false;

 global $user, $auth;

 $username = BOT_USERNAME;
 $password = BOT_PASSWORD;

 $title = unhtmlentities( $subject );
 $text = unhtmlentities( $text );

 $forumid = $forumid;
 $topicid = $topic_id;

 $original_user_id = $user->data['user_id'];
 $user->session_begin();
 $login = $auth->login($username, $password, false);
 $auth->acl($user->data);
 $user->setup();

 $title = utf8_normalize_nfc($title);
 $text = utf8_normalize_nfc($text);

 $poll = $uid = $bitfield = $options = '';

 generate_text_for_storage($title, $uid, $bitfield, $options, false, false, false);
 generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);

 $data = array(
     'forum_id'      => $forumid, 
     'topic_id'      => $topicid,
     'icon_id'      => false,
     'post_approved' => true,

     'enable_bbcode'   => true,
     'enable_smilies'   => true,
     'enable_urls'      => true,
     'enable_sig'      => true,

     'message'      => $text,
     'message_md5'   => md5($text),

     'bbcode_bitfield'   => $bitfield,
     'bbcode_uid'      => $uid,

     'post_edit_locked'   => 0,
     'topic_title'      => $title,
     'notify_set'      => false,
     'notify'         => false,
     'post_time'       => 0,
     'forum_name'      => '',
     'enable_indexing'   => true,
 );

 if ($topicid == NULL)
    $post_url =  submit_post('post', $title, '', POST_NORMAL, $poll, $data);
 else
    $post_url = submit_post('reply', $title, '', POST_NORMAL, $poll, $data);

 $user->session_kill();
 $user->session_create($original_user_id, false, true);

 return $post_url;

}

如果您能提供任何有用的提示或其他方法,我将不胜感激。

我建议您不要打扰会议等

如果您使用CURL启动“bot”活动,那么它将在幕后进行交互,而不是在当前用户的上下文中进行交互。
例如,所发帖子的IP地址应该是服务器的IP地址,而不是用户的IP地址。

有什么想法吗?在终止或恢复用户会话时,我一定是做错了什么。