groupId = $groupid; $thread->userName = $visitor['name']; $thread->remote = $remoteHost; $thread->referer = $referrer; $thread->locale = $current_locale; $thread->userId = $visitor['id']; $thread->userAgent = $userbrowser; $thread->state = Thread::STATE_LOADING; $thread->save(); $_SESSION['threadid'] = $thread->id; $operator = invitation_accept($_SESSION['visitorid'], $thread->id); if ($operator) { $operator = operator_by_id($operator); $operatorName = ($current_locale == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname']; $thread->postMessage( Thread::KIND_FOR_AGENT, getstring2('chat.visitor.invitation.accepted', array($operatorName)) ); } if( $referrer ) { $thread->postMessage( Thread::KIND_FOR_AGENT, getstring2('chat.came.from',array($referrer)) ); } $thread->postMessage(Thread::KIND_INFO, getstring('chat.wait')); if($email) { $thread->postMessage(Thread::KIND_FOR_AGENT, getstring2('chat.visitor.email',array($email))); } if($info) { $thread->postMessage(Thread::KIND_FOR_AGENT, getstring2('chat.visitor.info',array($info))); } if($firstmessage) { $postedid = $thread->postMessage(Thread::KIND_USER, $firstmessage, $visitor['name']); $thread->shownMessageId = $postedid; $thread->save(); } } $threadid = $thread->id; $token = $thread->lastToken; $level = get_remote_level($_SERVER['HTTP_USER_AGENT']); $chatstyle = verifyparam( "style", "/^\w+$/", ""); header("Location: $webimroot/client.php?thread=$threadid&token=$token&level=$level".($chatstyle ? "&style=$chatstyle" : "")); exit; } $token = verifyparam( "token", "/^\d{1,8}$/"); $threadid = verifyparam( "thread", "/^\d{1,8}$/"); $level = verifyparam( "level", "/^(ajaxed|simple|old)$/"); $thread = Thread::load($threadid, $token); if (! $thread) { die("wrong thread"); } setup_chatview_for_user($thread, $level); $pparam = verifyparam( "act", "/^(mailthread)$/", "default"); if( $pparam == "mailthread" ) { expand("styles/dialogs", getchatstyle(), "mail.tpl"); } else if( $level == "ajaxed" ) { // Load JavaScript plugins and JavaScripts, CSS files required by them $page['additional_css'] = get_additional_css('chatWindow'); $page['additional_js'] = get_additional_js('chatWindow'); $page['js_plugins'] = get_js_plugins('chatWindow'); // Expand page expand("styles/dialogs", getchatstyle(), "chat.tpl"); } else if( $level == "simple" ) { expand("styles/dialogs", getchatstyle(), "chatsimple.tpl"); } else if( $level == "old" ) { expand("styles/dialogs", getchatstyle(), "nochat.tpl"); } ?>