示例#1
0
<?php

/* 
 * 
 * Данный файл является частью проекта Веб Мессенджер.
 * 
 * Все права защищены. (c) 2005-2009 ООО "ТОП".
 * Данное программное обеспечение и все сопутствующие материалы
 * предоставляются на условиях лицензии, доступной по адресу
 * http://webim.ru/license.html
 * 
 */
require_once '../classes/functions.php';
require_once '../classes/class.operator.php';
require_once '../classes/class.thread.php';
$operator = Operator::getInstance()->GetLoggedOperator(false);
// папка online в мэмкэш --------------------
//touch_online_file(OPERATOR_VIEW_TRACKER_FILE);
$mem_buff->set('OPERATOR_VIEW_TRACKER_FILE', time(), 1800);
if (!$operator) {
    Browser::SendXmlHeaders();
    echo "<error><descr>" . escape_with_cdata(getstring("agent.not_logged_in")) . "</descr></error>";
    exit;
}
$xml = Thread::getInstance()->BuildVisitorsXml();
Browser::SendXmlHeaders();
echo $xml;
示例#2
0
 function PrintThreadMessages($thread, $token, $lastid, $isvisitor, $format, $viewonly = false)
 {
     $threadid = $thread['threadid'];
     $istyping = abs($thread['current'] - $thread[$isvisitor ? "lpoperator" : "lpvisitor"]) < WEBIM_CONNECTION_TIMEOUT && $thread[$isvisitor ? "agenttyping" : "visitortyping"] == "1" ? "1" : "0";
     $israted = empty($thread['ratedoperatorid']) ? 'false' : 'true';
     $visitSession = $isvisitor ? GetVisitorFromRequestAndSetCookie() : MapperFactory::getMapper("VisitSession")->getById($thread['visitsessionid']);
     $visitorname = $isvisitor ? removeSpecialSymbols($visitSession['name']) : removeSpecialSymbols(htmlspecialchars($visitSession['visitorname']));
     $rate = $thread['rate'];
     if ($format == "xml") {
         $visitorname = "visitorname=\"{$visitorname}\"";
         $operatorfullname = "operatorfullname=\"" . $thread['operatorfullname'] . "\"";
         $fl_login = "******"" . ($isvisitor || empty($visitSession['fl_login']) ? '' : $visitSession['fl_login']) . "\"";
         $threadstate = "state=\"" . $thread['state'] . "\"";
         $isHasMessages = true;
         if ($lastid != 0 && !$viewonly) {
             $isHasMessages = $isvisitor ? $this->isHasMessagesForVisitor($thread['threadid']) : $this->isHasMessagesForOperator($thread['threadid']);
         }
         $haveMessegesToAlert = "needtoalert=\"" . ($isHasMessages ? "true" : "false") . "\"";
         $output = array();
         if ($isHasMessages) {
             $output = $this->GetMessages($threadid, "xml", $isvisitor, $lastid);
             if ($thread['state'] !== STATE_CLOSED) {
                 if ($isvisitor) {
                     $this->unsetThreadHasMessagesForVisitor($thread['threadid']);
                 } else {
                     if (!$viewonly) {
                         $this->unsetThreadHasMessagesForOperator($thread['threadid']);
                     }
                 }
             }
         }
         Browser::SendXmlHeaders();
         print "<thread lastid=\"{$lastid}\" typing=\"" . $istyping . "\" viewonly=\"" . $viewonly . "\" {$visitorname} {$operatorfullname} {$fl_login} {$haveMessegesToAlert} {$threadstate} israted=\"{$israted}\" rate=\"{$rate}\">";
         foreach ($output as $msg) {
             if (!$isvisitor && strpos($msg, "webimFeedbackBtn") !== false) {
                 continue;
             }
             print $msg;
         }
         print "</thread>";
     } elseif ($format == "html") {
         $output = $this->GetMessages($threadid, "html", $isvisitor, $lastid);
         Browser::SendHtmlHeaders();
         $url = WEBIM_ROOT . "/thread.php?act=refresh&thread=" . $threadid . "&token=" . $token . "&html=on&visitor=" . ($isvisitor ? "true" : "false");
         print "<html><head>\n" . "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"" . WEBIM_ROOT . "/css/admin_chat.css?" . WEBIM_VERSION . "\" />\n" . "<meta http-equiv=\"Refresh\" content=\"7; URL={$url}&sn=11\">\n" . "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n" . "</head>" . "<body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400' marginwidth='0' marginheight='0' leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0' onload=\"if (location.hash != '#aend') {location.hash='#aend';}\">" . "<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message'>";
         foreach ($output as $msg) {
             if (!$isvisitor && strpos($msg, "webimFeedbackBtn") !== false) {
                 continue;
             }
             print $msg;
         }
         print "</td></tr></table><a name='aend'>" . "</body></html>";
     }
 }
示例#3
0
 public function GetLoggedOperator($redirect = true)
 {
     if (!isset($_SESSION['operator'])) {
         if (isset($_COOKIE['WEBIM_AUTH'])) {
             list($login, $pwd) = split(',', $_COOKIE['WEBIM_AUTH'], 2);
             $op = MapperFactory::getMapper('Operator')->getByLogin($login);
             if ($op && isset($pwd) && isset($op['password']) && md5($op['password']) == $pwd) {
                 $this->setOperatorToSessionById($op['operatorid']);
                 return $op;
             }
         }
         if ($redirect) {
             header('Location: ' . WEBIM_ROOT . '/operator/login.php?redir=' . urlencode($_SERVER['PHP_SELF']));
             exit;
         } else {
             Browser::SendXmlHeaders();
             Browser::displayAjaxError('agent.not_logged_in');
             exit;
         }
     }
     return SilentGetOperator();
 }
示例#4
0
function show_error($message)
{
    Browser::SendXmlHeaders();
    echo "<error><descr>{$message}</descr></error>";
    exit;
}