예제 #1
0
function tryToGetExistingThread()
{
    $threadid = verify_param('thread', "/^\\d{1,8}\$/", '');
    $thread = null;
    if (empty($threadid)) {
        $visitor = GetVisitorFromRequestAndSetCookie();
        $thread = MapperFactory::getMapper('Thread')->getActiveThreadForVisitor($visitor['id']);
    } else {
        $thread = Thread::getInstance()->GetThreadById($threadid);
        $token = verify_param('token', "/^\\d{1,8}\$/");
        if ($token != $thread['token'] || $thread['state'] == STATE_CLOSED) {
            $thread = null;
        }
    }
    if (!empty($thread) && (visitorHasAccess($thread) || empty($threadid))) {
        ThreadProcessor::getInstance()->ProcessThread($thread['threadid'], 'ping_visitor');
        $thread = Thread::getInstance()->GetThreadById($thread['threadid']);
        if (empty($thread) || $thread['state'] == STATE_CLOSED) {
            $thread = null;
        }
    } else {
        $thread = null;
    }
    return $thread;
}
예제 #2
0
$outformat = verify_param("html", "/^on\$/", "off") == 'on' ? "html" : "xml";
$istyping = verify_param("typed", "/^1\$/", "") == '1';
$viewonly = verify_param("viewonly", "/^true\$/", "false") == 'true';
if (!$isvisitor) {
    $o = Operator::getInstance();
    $operator = $o->GetLoggedOperator(false);
    $f = "i" . "s" . "O" . "p" . "er" . "a" . "to" . "rsL" . "im" . "it" . "E" . "x" . "ce" . "ed" . "ed";
    if ($o->{$f}()) {
        die;
    }
}
$thread = Thread::getInstance()->GetThreadById($threadid);
if (empty($thread) || !isset($thread['token']) || $token != $thread['token']) {
    die("wrong thread in thread.php");
}
if ($isvisitor && !visitorHasAccess($thread)) {
    show_error("server: visitor has no access to the thread");
}
if ($isvisitor) {
    ThreadProcessor::getInstance()->ProcessThread($threadid, 'visitor_ping', array('istyping' => !empty($istyping)));
}
if (!$isvisitor && !$viewonly) {
    EventController::getInstance()->dispatchEvent(EventController::EVENT_OPERATOR_PING, array($threadid, 'operator_ping', array('istyping' => !empty($istyping), 'operatorid' => $operator['operatorid'])));
}
$operator = null;
if (!$isvisitor && !$viewonly) {
    $operator = Operator::getInstance()->GetLoggedOperator();
    $viewonly = $thread['operatorid'] != $operator['operatorid'] && !empty($thread['operatorid']);
}
//$visitSession = VisitSession::GetInstance()->GetVisitSessionById($thread['visitsessionid']);
$v = GetVisitorFromRequestAndSetCookie();