2009-09-09 4 views
0

나는 완벽한 솔루션을 아직 찾지 못했다는 문제점에 봉착했습니다. 먼저 시나리오를 요약 해 보겠습니다. 저는 서버에 PHPBB3 포럼이 있고 포럼에 링크 된 동일한 서버에 (나에 의해 개발 된) 애플리케이션이 있습니다. 응용 프로그램은 사용자가 포럼에 로그인하고 특정 포럼 사용자 그룹에있는 경우에만 액세스 할 수있는 경우에만 액세스 할 수 있습니다. 또한 앱이 스크립트/페이지에 액세스 할 때 포럼 스레드/게시물을 프로그래밍 전용으로 전용 사용자 ('봇'이라고 부름)를 통해 게시 할 수 있어야합니다. 그래서 내가 원하는 것은 다음과 같습니다 : 1. 현재 로그인 한 사용자를 저장하십시오 ('테스트 사용자'라고 부르겠습니다). 2. 'Bot'사용자로 로그인하십시오. 3. 스레드/게시물을 게시하십시오. 4. 세션 삭제 5. 로그인 한 사용자 복원PHPBB3 +에서 자동 게시 사용자 세션 조작/복원

이 '정렬'은 처음에는 작동하지만 반복적으로 호출/게시 할 경우 처음 1-2 게시물은 '봇'에 의해 게시되지만 다음은 'Test User'에 의해 게시 됨. 현재 코드 :

이것은 모든 관련 스크립트에 포함되어있는 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; 

} 

내가 어떤 도움이 조언 다른 방법 고맙겠에서 함수 자체입니다.

+0

아이디어가 있으십니까? 내가 죽이거나 사용자 세션을 복원 할 때 뭔가 잘못하고 있어야합니다. –

답변

0

나는 세션 등을 혼자 두는 것이 좋습니다.

CURL을 사용하여 '봇'활동을 시작하면 현재 사용자의 컨텍스트가 아닌 씬 뒤에서 상호 작용할 수 있습니다. 게시물의 IP 주소는 예를 들어 사용자의 주소가 아닌 서버의 IP 주소입니다.