Ejemplo n.º 1
0
function StoreFile($_visitor, $_browserId, $_partner, $_fullname, $_chatId)
{
    $filename = IOStruct::GetNamebase($_FILES['form_userfile']['name']);
    Logging::GeneralLog($filename);
    if (!IOStruct::IsValidUploadFile($filename)) {
        return false;
    }
    if (empty($_fullname)) {
        $_fullname = Visitor::GetNoName($_visitor->UserId . Communication::GetIP());
    }
    $fileid = md5($filename . $_visitor->UserId . $_browserId);
    $fileurid = EX_FILE_UPLOAD_REQUEST . "_" . $fileid;
    $filemask = $_visitor->UserId . "_" . $fileid;
    $request = new FileUploadRequest($fileurid, $_partner, $_chatId);
    $request->Load();
    if ($request->Permission == PERMISSION_FULL) {
        if (move_uploaded_file($_FILES["form_userfile"]["tmp_name"], PATH_UPLOADS . $request->FileMask)) {
            KnowledgeBase::CreateFolders($_partner, false);
            KnowledgeBase::Process($_partner, $_visitor->UserId, $_fullname, 0, $_fullname, 0, 5, 3);
            KnowledgeBase::Process($_partner, $fileid, $filemask, 4, $_FILES["form_userfile"]["name"], 0, $_visitor->UserId, 4, $_FILES["form_userfile"]["size"]);
            $request->Download = true;
            $request->Save();
            return true;
        } else {
            $request->Error = true;
            $request->Save();
        }
    }
    return false;
}
Ejemplo n.º 2
0
function isChat()
{
    define("SESSION", getSessionId());
    Server::InitDataBlock(array("FILTERS"));
    define("IS_FLOOD", Filter::IsFlood(Communication::GetIP(), null, true));
    define("IS_FILTERED", DataManager::$Filters->Match(Communication::GetIP(), LocalizationManager::ImplodeLanguages(!empty($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : ""), SESSION));
    $parameters = Communication::GetTargetParameters();
    if (operatorsAvailable(0, $parameters["exclude"], $parameters["include_group"], $parameters["include_user"]) > 0) {
        return true;
    }
    return false;
}
 function ProcessPosts()
 {
     global $USER;
     $pc = 0;
     if (!empty($USER->Browsers[0]->QueuedPosts)) {
         if (!$USER->Browsers[0]->Waiting) {
             while (!empty($_GET["mi" . $pc])) {
                 $pc++;
             }
             foreach ($USER->Browsers[0]->QueuedPosts as $id => $postar) {
                 $_GET["mp" . $pc] = $postar[0];
                 $_GET["mrid" . $pc] = $_GET["mi" . $pc] = Encoding::Base64UrlEncode($id);
                 $_GET["mc" . $pc++] = Encoding::Base64UrlEncode($postar[1]);
                 DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `id`='" . DBManager::RealEscape($id) . "' LIMIT 1;");
             }
             $pc = 0;
             $USER->Browsers[0]->QueuedPosts = array();
         }
     }
     $this->OverlayHTML = "";
     if (!empty($_GET["mi" . $pc]) || $USER->Browsers[0]->Waiting || !empty($USER->Browsers[0]->InitChatWith) || !empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) {
         if ($USER->Browsers[0]->Waiting && $this->Botmode && !empty($USER->Browsers[0]->QueuedPosts)) {
             $USER->Browsers[0]->QueuedPosts = array();
         } else {
             if (!Visitor::$OpenChatExternal) {
                 $this->Init();
             }
         }
         if (!empty($USER->Browsers[0]->Forward) && !$USER->Browsers[0]->Forward->Received && $USER->Browsers[0]->Forward->Processed) {
             $USER->Browsers[0]->Forward->Save(true, true);
             Visitor::$IsActiveOverlayChat = !$USER->Browsers[0]->Declined;
         }
     }
     if (!empty($USER->Browsers[0]->ChatId)) {
         $USER->AddFunctionCall("lz_chat_id='" . $USER->Browsers[0]->ChatId . "';", false);
     }
     $USER->Browsers[0]->VisitId = $USER->VisitId;
     while (!empty($_GET["mi" . $pc])) {
         $id = Communication::ReadParameter("mrid" . $pc, md5($USER->Browsers[0]->SystemId . $USER->Browsers[0]->ChatId . $_GET["mi" . $pc]));
         $senderName = !empty($USER->Browsers[0]->UserData->Fullname) ? $USER->Browsers[0]->UserData->Fullname : LocalizationManager::$TranslationStrings["client_guest"] . " " . Visitor::GetNoName($USER->UserId . Communication::GetIP());
         $post = new Post($id, $USER->Browsers[0]->SystemId, "", Encoding::Base64UrlDecode($_GET["mp" . $pc]), Communication::ReadParameter("mc" . $pc, time()), $USER->Browsers[0]->ChatId, $senderName);
         $post->BrowserId = VisitorMonitoring::$Browser->BrowserId;
         if (!empty($_GET["mpti" . $pc])) {
             $post->Translation = Encoding::Base64UrlDecode($_GET["mpt" . $pc]);
             $post->TranslationISO = Encoding::Base64UrlDecode($_GET["mpti" . $pc]);
         }
         $saved = false;
         if (!$USER->Browsers[0]->Waiting) {
             foreach (Server::$Groups as $groupid => $group) {
                 if ($group->IsDynamic && $USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE && isset($group->Members[$USER->Browsers[0]->SystemId])) {
                     foreach ($group->Members as $member => $persistent) {
                         if ($member != $USER->Browsers[0]->SystemId) {
                             if (!empty(Server::$Operators[$member])) {
                                 processPost($id, $post, $member, $pc, $groupid, $USER->Browsers[0]->ChatId);
                             } else {
                                 processPost($id, $post, $member, $pc, $groupid, CacheManager::GetValueBySystemId($member, "chat_id", ""));
                             }
                             $saved = true;
                         }
                     }
                     $pGroup = $group;
                 }
             }
             foreach ($USER->Browsers[0]->Members as $systemid => $member) {
                 if (!empty($member->Declined)) {
                     continue;
                 }
                 if (!empty(Server::$Operators[$systemid]) && !empty($pGroup) && isset($pGroup->Members[$systemid])) {
                     continue;
                 }
                 if (!(!empty($pGroup) && !empty(Server::$Operators[$systemid]))) {
                     $saved = processPost($id, $post, $systemid, $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, Server::$Operators[$systemid]->IsBot);
                 }
             }
             if (!empty($USER->Browsers[0]->OperatorId) && (Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot || $USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE)) {
                 $rpost = new Post($id = getId(32), Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId, $USER->Browsers[0]->SystemId, $answer = Server::$Operators[$USER->Browsers[0]->OperatorId]->GetAutoReplies($post->Text . " " . $post->Translation, $USER->Browsers[0]), time(), $USER->Browsers[0]->ChatId, Server::$Operators[$USER->Browsers[0]->OperatorId]->Fullname);
                 if (!empty($answer)) {
                     if (Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
                         sleep(1);
                         $USER->AddFunctionCall("lz_chat_input_bot_state(true,false);", false);
                     }
                     $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                     $rpost->Save();
                     $saved = true;
                     foreach ($USER->Browsers[0]->Members as $opsysid => $member) {
                         if ($opsysid != Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId || !Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
                             $rpost = new Post($id, Server::$Operators[$USER->Browsers[0]->OperatorId]->SystemId, $opsysid, $answer, time(), $USER->Browsers[0]->ChatId, Server::$Operators[$opsysid]->Fullname);
                             $rpost->ReceiverOriginal = $rpost->ReceiverGroup = $USER->Browsers[0]->SystemId;
                             $rpost->Save();
                         }
                     }
                 }
             }
             if ($saved) {
                 $USER->AddFunctionCall("lz_chat_release_post('" . Encoding::Base64UrlDecode($_GET["mi" . $pc]) . "');", false);
             }
         } else {
             processPost($id, $post, "", $pc, $USER->Browsers[0]->SystemId, $USER->Browsers[0]->ChatId, false);
             $USER->Browsers[0]->QueuedPosts[$id] = array(0 => $_GET["mp" . $pc], 1 => time(), 2 => VisitorMonitoring::$Browser->BrowserId);
             $USER->AddFunctionCall("lz_chat_release_post('" . Encoding::Base64UrlDecode($_GET["mi" . $pc]) . "');", false);
         }
         $pc++;
     }
     if (!empty($USER->Browsers[0]->OperatorId) && empty($pc) && !Server::$Operators[$USER->Browsers[0]->OperatorId]->IsBot) {
         $autoReply = Server::$Operators[$USER->Browsers[0]->OperatorId]->GetAutoReplies("", $USER->Browsers[0]);
         if (!empty($autoReply)) {
             ChatAutoReply::SendAutoReply($autoReply, $USER, $USER->Browsers[0]->OperatorId);
         }
     }
 }
Ejemplo n.º 4
0
        $groupbuilder = new GroupBuilder();
        $groupbuilder->Generate();
        if (!$groupbuilder->GroupAvailable) {
            exit("<html><script language=\"JavaScript\">if(typeof(window.opener != null) != 'undefined')window.opener.location = \"" . Server::$Configuration->File["gl_om_http"] . "\";window.close();</script></html>");
        }
    } else {
        Server::InitDataBlock(array("FILTERS"));
    }
    if (isset($_POST["company"]) && !empty($_POST["company"]) || isset($_POST["email"]) && !empty($_POST["email"]) || isset($_POST["name"]) && !empty($_POST["name"]) || isset($_POST["text"]) && !empty($_POST["text"])) {
        exit(Filter::CreateFloodFilter(Communication::GetIP(), null));
    }
}
header("Content-Type: text/html; charset=utf-8");
if (!isset($_GET[GET_EXTERN_TEMPLATE])) {
    define("IS_FLOOD", Filter::IsFlood(Communication::GetIP(), null, true));
    define("IS_FILTERED", DataManager::$Filters->Match(Communication::GetIP(), LocalizationManager::ImplodeLanguages(!empty($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : ""), SESSION));
    require LIVEZILLA_PATH . "_lib/trdp/mobde.php";
    $MobileDetect = new Mobile_Detect();
    Server::InitDataBlock(array("INTERNAL", "DBCONFIG"));
    VisitorChat::ApplyDynamicGroup();
    $html = IOStruct::GetFile(TEMPLATE_HTML_CHAT);
    $html = str_replace("<!--extern_script-->", IOStruct::GetFile(TEMPLATE_SCRIPT_EXTERN) . IOStruct::GetFile(TEMPLATE_SCRIPT_DATA) . IOStruct::GetFile(TEMPLATE_SCRIPT_CHAT) . IOStruct::GetFile(TEMPLATE_SCRIPT_FRAME), $html);
    $html = str_replace("<!--server_id-->", substr(md5(Server::$Configuration->File["gl_lzid"]), 5, 5), $html);
    $html = str_replace("<!--connector_script-->", IOStruct::GetFile(TEMPLATE_SCRIPT_CONNECTOR), $html);
    $html = str_replace("<!--group_script-->", IOStruct::GetFile(TEMPLATE_SCRIPT_GROUPS), $html);
    $html = str_replace("<!--global_script-->", IOStruct::GetFile(TEMPLATE_SCRIPT_GLOBAL), $html);
    $html = str_replace("<!--browser_id-->", $browserId, $html);
    $html = str_replace("<!--extern_timeout-->", min(Server::$Configuration->File["timeout_chats"], Server::$Configuration->File["timeout_track"]), $html);
    $html = str_replace("<!--show_oib-->", To::BoolString(!empty(Server::$Configuration->File["gl_soib"]) && empty($_GET[GET_EXTERN_DYNAMIC_GROUP])), $html);
    $html = str_replace("<!--window_width-->", Server::$Configuration->File["wcl_window_width"], $html);
    $html = str_replace("<!--window_height-->", Server::$Configuration->File["wcl_window_height"], $html);
 static function Replace($_toReplace, $jsa = "")
 {
     $_toReplace = str_replace("<!--geo_url-->", GeoTracking::GetURL() . "?aid=" . Server::$Configuration->File["wcl_geo_tracking"] . "&sid=" . base64_encode(Server::$Configuration->File["gl_lzid"]) . "&dbp=" . Server::$Configuration->File["gl_gtdb"], $_toReplace);
     if (!empty(Server::$Configuration->File["gl_use_ngl"])) {
         if (!Is::Null(trim(Server::$Configuration->File["gl_pr_ngl"]))) {
             $gkey = Server::$Configuration->File["gl_pr_ngl"];
         }
         if (!empty($gkey)) {
             $jsc = "var chars = new Array(";
             $jso = "var order = new Array(";
             $chars = str_split(sha1($gkey . date("d"), false));
             $keys = array_keys($chars);
             shuffle($keys);
             foreach ($keys as $key) {
                 $jsc .= "'" . $chars[$key] . "',";
                 $jso .= $key . ",";
             }
             $jsa .= $jsc . "0);\r\n";
             $jsa .= $jso . "0);\r\n";
             $jsa .= "while(lz_oak.length < (chars.length-1))for(var f in order)if(order[f] == lz_oak.length)lz_oak += chars[f];\r\n";
         }
     }
     $_toReplace = str_replace("<!--calcoak-->", $jsa, $_toReplace);
     $_toReplace = str_replace("<!--mip-->", Communication::GetIP(false, true), $_toReplace);
     return $_toReplace;
 }
Ejemplo n.º 6
0
 Visitor::$PollCount = Communication::ReadParameter("pc", 0);
 VisitorMonitoring::$Response = "lz_tracking_set_sessid(\"" . base64_encode(CALLER_USER_ID) . "\",\"" . base64_encode(CALLER_BROWSER_ID) . "\");";
 if (BaseURL::IsInputURL() && strpos(BaseURL::GetInputURL(), "lzmobile") !== false && Visitor::$PollCount == 1) {
     exit("eval(lz_global_base64_decode('" . base64_encode(IOStruct::GetFile(PATH_TEMPLATES . "jscript/jstrack.mob.tpl")) . "'));lz_tracking_stop_tracking(75);");
 }
 if (BaseURL::IsInputURL() && strpos(BaseURL::GetInputURL(), GET_INTERN_COBROWSE) !== false) {
     VisitorMonitoring::Abort(1);
 }
 VisitorMonitoring::$Browser = new VisitorBrowser(CALLER_BROWSER_ID, CALLER_USER_ID);
 VisitorMonitoring::$Visitor->AddBrowser(VisitorMonitoring::$Browser);
 if (VisitorMonitoring::$Visitor->FirstCall && !VisitorMonitoring::$Browser->GetFirstCall()) {
     VisitorMonitoring::$Visitor->FirstCall = false;
 }
 Server::InitDataBlock(array("FILTERS", "EVENTS"));
 define("IS_FILTERED", DataManager::$Filters->Match(Communication::GetIP(), LocalizationManager::ImplodeLanguages(!empty($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : ""), CALLER_USER_ID, VisitorMonitoring::$Visitor->GeoCountryISO2));
 define("IS_FLOOD", VisitorMonitoring::$Browser->GetFirstCall() && Filter::IsFlood(Communication::GetIP(), CALLER_USER_ID));
 Server::InitDataBlock(array("INTERNAL"));
 $deactp = Communication::ReadParameter("deactr", 0);
 if (IS_FILTERED && !FILTER_ALLOW_TRACKING || IS_FLOOD || !empty($deactp) || Cookie::Get(OO_TRACKING_FILTER_NAME) != null) {
     if (!IS_FILTERED) {
         Filter::Create($_SERVER["REMOTE_ADDR"], CALLER_USER_ID, OO_TRACKING_FILTER_NAME, !empty($deactp) ? $deactp : 365, true, true);
     }
     VisitorMonitoring::LoadOverlayChat();
     VisitorMonitoring::$IsActive = false;
     VisitorMonitoring::Abort(556);
 }
 VisitorMonitoring::$Browser->UserData->LoadFromPassThru();
 if (JAVASCRIPT) {
     if (Visitor::$PollCount <= 3) {
         if (!BaseURL::IsInputURL()) {
             VisitorMonitoring::Abort(3);
Ejemplo n.º 7
0
if (!defined("IN_LIVEZILLA")) {
    die;
}
require LIVEZILLA_PATH . "_lib/objects.external.inc.php";
require LIVEZILLA_PATH . "_lib/functions.external.inc.php";
if (isset($_POST[POST_EXTERN_SERVER_ACTION])) {
    LocalizationManager::AutoLoad();
    Server::InitDataBlock(array("FILTERS", "INPUTS"));
    VisitorChat::$Router = new ChatRouter();
    $externalUser = new Visitor(Encoding::Base64UrlDecode($_POST[POST_EXTERN_USER_USERID]));
    $externalUser->ExtendSession = true;
    $externalUser->Load();
    array_push($externalUser->Browsers, new VisitorChat($externalUser->UserId, Encoding::Base64UrlDecode($_POST[POST_EXTERN_USER_BROWSERID])));
    array_push($externalUser->Browsers, new VisitorBrowser($externalUser->Browsers[0]->BrowserId, $externalUser->Browsers[0]->UserId));
    define("IS_FILTERED", DataManager::$Filters->Match(Communication::GetIP(), LocalizationManager::ImplodeLanguages(!empty($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : ""), Encoding::Base64UrlDecode($_POST[POST_EXTERN_USER_USERID]), $externalUser->GeoCountryISO2));
    define("IS_FLOOD", $externalUser->Browsers[0]->FirstCall && Filter::IsFlood(Communication::GetIP(), @$_POST[POST_EXTERN_USER_USERID], true));
    Server::InitDataBlock(array("INTERNAL", "GROUPS"));
    VisitorChat::ApplyDynamicGroup($externalUser->Browsers[0]);
    $externalUser->Browsers[0]->Load();
    if ($externalUser->Browsers[0]->Status == CHAT_STATUS_OPEN && IS_FILTERED && !FILTER_ALLOW_CHATS && !FILTER_ALLOW_TICKETS) {
        $error = buildLoginErrorField();
        $externalUser->AddFunctionCall("lz_chat_release(true,'" . $error . "');", false);
    } else {
        if ($_POST[POST_EXTERN_SERVER_ACTION] == "search_kb") {
            $query = Communication::ReadParameter("p_q", "");
            $color = ExternalChat::ReadTextColor();
            $catcount = 0;
            $main = $result = $navcats = "";
            if ($query == "%ALL%") {
                $matches = KnowledgeBase::GetEntries(Visitor::$BrowserLanguage);
                if (count($matches) == 0) {
 function CreateArchiveEntry($_internalUser, $_visitor, $custom = "", $etpl = "", $_customsInTranscript = true, $pdm = null)
 {
     if (!empty($this->ArchiveCreated)) {
         return;
     }
     if (Server::$Inputs[111]->Active) {
         $custom .= strip_tags(Server::$Inputs[111]->Caption) . " %efullname%\r\n";
     }
     if (Server::$Inputs[112]->Active) {
         $custom .= strip_tags(Server::$Inputs[112]->Caption) . " %eemail%\r\n";
     }
     if (!empty($this->Company) && Server::$Inputs[113]->Active) {
         $custom .= strip_tags(Server::$Inputs[113]->Caption) . " " . trim($this->UserData->Company) . "\r\n";
     }
     if (!empty($this->Question) && Server::$Inputs[114]->Active) {
         $custom .= strip_tags(Server::$Inputs[114]->Caption) . " " . trim($this->UserData->Text) . "\r\n";
     }
     if (!empty($this->Phone) && Server::$Inputs[116]->Active) {
         $custom .= strip_tags(Server::$Inputs[116]->Caption) . " " . trim($this->UserData->Phone) . "\r\n";
     }
     if (!empty($this->ChatVoucherId)) {
         $custom .= strip_tags(LocalizationManager::$TranslationStrings["client_voucher_id"]) . " " . trim($this->ChatVoucherId) . "\r\n";
     }
     $customs = array();
     if (is_array($this->UserData->Customs)) {
         foreach ($this->UserData->Customs as $cind => $value) {
             if (Server::$Inputs[$cind]->Active && Server::$Inputs[$cind]->Custom) {
                 $customs[Server::$Inputs[$cind]->Name] = $value;
                 if (!isset(Server::$Groups[$this->DesiredChatGroup]->ChatInputsHidden[$cind]) && $_customsInTranscript) {
                     if (Server::$Inputs[$cind]->Type == "CheckBox") {
                         $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . (!empty($value) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->") . "\r\n";
                     } else {
                         if (Server::$Inputs[$cind]->Type == "ComboBox") {
                             $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . Server::$Inputs[$cind]->GetClientValue($value) . "\r\n";
                         } else {
                             $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . $value . "\r\n";
                         }
                     }
                 }
             }
         }
     }
     $tsData = array("", "");
     if (!empty(Server::$Groups[$this->DesiredChatGroup]->PredefinedMessages)) {
         $pdm = PredefinedMessage::GetByLanguage(Server::$Groups[$this->DesiredChatGroup]->PredefinedMessages, $_visitor->Language);
         if (!empty($pdm->EmailChatTranscriptBodyPlaintext)) {
             $tsData[0] = $pdm->EmailChatTranscriptBodyPlaintext;
         }
         if (!empty($pdm->EmailChatTranscriptBodyHTML)) {
             $tsData[1] = $pdm->EmailChatTranscriptBodyHTML;
         }
     }
     for ($i = 0; $i < count($tsData); $i++) {
         $tsData[$i] = str_replace("%chat_id%", $this->ChatId, $tsData[$i]);
         $tsData[$i] = str_replace("%details%", $custom, $tsData[$i]);
         $tsData[$i] = str_replace("%external_name%", "%efullname%", $tsData[$i]);
         $tsData[$i] = str_replace("%external_email%", "%eemail%", $tsData[$i]);
         $tsData[$i] = str_replace("%external_company%", $this->UserData->Company, $tsData[$i]);
         $tsData[$i] = str_replace("%external_phone%", $this->UserData->Phone, $tsData[$i]);
         $tsData[$i] = str_replace("%question%", $this->UserData->Text, $tsData[$i]);
         $tsData[$i] = str_replace("%feedback_link%", Feedback::GetLink("cid=" . Encoding::Base64UrlEncode($this->ChatId)), $tsData[$i]);
         $tsData[$i] = Server::$Groups[$this->DesiredChatGroup]->TextReplace($tsData[$i], $_visitor->Language);
         if (!empty($this->OperatorId)) {
             $tsData[$i] = Server::$Operators[$this->OperatorId]->TextReplace($tsData[$i]);
         }
         $tsData[$i] = $_visitor->TextReplace($tsData[$i]);
         $tsData[$i] = Configuration::Replace($tsData[$i]);
     }
     $subject = $pdm != null ? $pdm->SubjectChatTranscript : "";
     $subject = Mailbox::GetSubject($subject, $this->UserData->Email, $this->UserData->Fullname, $this->DesiredChatGroup, $this->ChatId, $this->UserData->Company, $this->UserData->Phone, Communication::GetIP(), $this->UserData->Text, Server::$Groups[$this->DesiredChatGroup]->GetDescription($_visitor->Language), $this->UserData->Customs);
     $internal = $_internalUser != null && $_internalUser->IsBot ? $_internalUser->SystemId : "";
     $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_id`='" . DBManager::RealEscape($this->ChatId) . "';");
     if ($result && DBManager::GetRowCount($result) == 0) {
         if (Server::$Configuration->File["gl_adct"] == 1 || (!empty(Server::$Configuration->File["gl_rm_chats_time"]) || empty(Server::$Configuration->File["gl_rm_chats"]))) {
             $url = Visitor::GetLastURLFromVisitor($this->UserId);
             DBManager::Execute(true, "INSERT INTO `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` (`time`,`endtime`,`closed`,`chat_id`,`external_id`,`fullname`,`internal_id`,`group_id`,`area_code`,`html`,`plaintext`,`transcript_text`,`transcript_html`,`email`,`company`,`iso_language`,`iso_country`,`host`,`ip`,`gzip`,`transcript_sent`,`transcript_receiver`,`question`,`customs`,`subject`,`voucher_id`,`ref_url`) VALUES ('" . DBManager::RealEscape($this->FirstActive) . "',0,0,'" . DBManager::RealEscape($this->ChatId) . "','" . DBManager::RealEscape($this->UserId) . "','','" . DBManager::RealEscape($internal) . "','','" . DBManager::RealEscape($this->Code) . "','','','" . DBManager::RealEscape($tsData[0]) . "','" . DBManager::RealEscape($tsData[1]) . "','','','" . DBManager::RealEscape($_visitor->Language) . "','" . DBManager::RealEscape($_visitor->GeoCountryISO2) . "','" . DBManager::RealEscape($_visitor->Host) . "','" . DBManager::RealEscape($_visitor->IP) . "',0,0,'" . DBManager::RealEscape($this->UserData->Email) . "','','" . DBManager::RealEscape(@serialize($customs)) . "','" . DBManager::RealEscape($subject) . "','" . DBManager::RealEscape($this->ChatVoucherId) . "','" . DBManager::RealEscape($url) . "');");
         }
         $this->ArchiveCreated = 1;
         ChatRequest::AcceptAll($this->UserId);
     }
 }
 static function Validate($_basic = false)
 {
     if (!empty(Server::$Configuration->File["gl_rhts"]) && Communication::GetScheme() != SCHEME_HTTP_SECURE) {
         define("AUTH_RESULT", LOGIN_REPLY_HTTPS);
     } else {
         if (DB_CONNECTION || SERVERSETUP) {
             if (!empty($_POST[POST_INTERN_AUTHENTICATION_USER])) {
                 foreach (Server::$Operators as $sysId => $operator) {
                     if (strtolower($operator->UserId) == strtolower($_POST[POST_INTERN_AUTHENTICATION_USER])) {
                         if (!$operator->IsBot && $operator->ValidateLoginAttempt()) {
                             if (!empty(CacheManager::$ActiveManager)) {
                                 $operator->LoadUnCacheables();
                             }
                             if ($operator->ValidateLoginAuthentication()) {
                                 define("CALLER_SYSTEM_ID", $sysId);
                                 if ($_basic) {
                                     define("VALIDATED", true);
                                     return;
                                 }
                                 if (!empty($_POST[POST_INTERN_AUTHENTICATION_CLIENT_SYSTEM_ID])) {
                                     if (empty($_POST["p_db_no_req"]) && !DB_CONNECTION) {
                                         define("AUTH_RESULT", LOGIN_REPLY_DB);
                                         break;
                                     }
                                     if (!LOGIN && !SERVERSETUP) {
                                         if ($operator->Deactivated) {
                                             define("AUTH_RESULT", LOGIN_REPLY_ACCOUNT_DEACTIVATED);
                                             break;
                                         }
                                         if (!$operator->ClientWeb && $operator->LastActive < time() - Server::$Configuration->File["timeout_clients"] && $_POST[POST_INTERN_AUTHENTICATION_CLIENT_SYSTEM_ID] == $operator->ClientSystemId) {
                                             define("AUTH_RESULT", LOGIN_REPLY_SESSION_TIMEOUT);
                                             break;
                                         }
                                         if ($operator->SignOffRequest || !empty($_POST["p_app_device_id"]) && $operator->AppDeviceId != "LOGIN" && $operator->AppDeviceId != $_POST["p_app_device_id"]) {
                                             $operator->SignOff(false);
                                             define("AUTH_RESULT", LOGIN_REPLY_SIGN_OFF_REQUEST);
                                             break;
                                         }
                                         if (!empty($operator->ClientSystemId) && !empty($_POST[POST_INTERN_AUTHENTICATION_CLIENT_SYSTEM_ID]) && $_POST[POST_INTERN_AUTHENTICATION_CLIENT_SYSTEM_ID] != $operator->ClientSystemId) {
                                             define("AUTH_RESULT", LOGIN_REPLY_BAD_COMBINATION);
                                             break;
                                         }
                                     } else {
                                         if (LOGIN && !SERVERSETUP) {
                                             $operator->AppClient = !empty($_POST["p_app"]);
                                             $operator->ClientWeb = !empty($_POST["p_web"]);
                                             if ($operator->ClientWeb) {
                                                 UserGroup::RemoveFromAllDynamicGroups($sysId);
                                             }
                                             if (($operator->AppClient || $operator->ClientWeb) && $operator->GetPermission(45, PERMISSION_FULL) == PERMISSION_NONE) {
                                                 define("AUTH_RESULT", LOGIN_REPLY_NO_MOBILE_ACCESS);
                                                 break;
                                             } else {
                                                 if ($operator->Deactivated) {
                                                     define("AUTH_RESULT", LOGIN_REPLY_ACCOUNT_DEACTIVATED);
                                                     break;
                                                 } else {
                                                     if ($operator->SignOffRequest) {
                                                         $operator->SignOff(false);
                                                         define("AUTH_RESULT", LOGIN_REPLY_SIGN_OFF_REQUEST);
                                                         break;
                                                     } else {
                                                         if (empty($_POST[POST_INTERN_IGNORE_SIGNED_ON]) && $operator->LastActive > time() - Server::$Configuration->File["timeout_clients"] && !empty($operator->ClientSystemId) && $_POST[POST_INTERN_AUTHENTICATION_CLIENT_SYSTEM_ID] != $operator->ClientSystemId) {
                                                             define("AUTH_RESULT", LOGIN_REPLY_ALREADY_ONLINE);
                                                             break;
                                                         } else {
                                                             if ($operator->PasswordChangeRequest && empty($_POST[POST_INTERN_NEW_PASSWORD])) {
                                                                 define("AUTH_RESULT", LOGIN_REPLY_CHANGE_PASS);
                                                                 break;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         } else {
                                             if (SERVERSETUP && $operator->Level != USER_LEVEL_ADMIN) {
                                                 if (!(in_array(Server::$Configuration->File["gl_host"], $operator->WebsitesUsers) && !empty($_POST[POST_INTERN_GET_MANAGEMENT])) && !(in_array(Server::$Configuration->File["gl_host"], $operator->WebsitesConfig) && empty($_POST[POST_INTERN_GET_MANAGEMENT]))) {
                                                     define("AUTH_RESULT", LOGIN_REPLY_NOADMIN);
                                                     break;
                                                 }
                                             }
                                         }
                                     }
                                     define("VALIDATED", true);
                                     if (isset($_POST[POST_INTERN_NEW_PASSWORD])) {
                                         $operator->ChangePassword($_POST[POST_INTERN_NEW_PASSWORD]);
                                         Server::$Response->Authentications = "<val userid=\"" . base64_encode(CALLER_SYSTEM_ID) . "\" />\r\n";
                                     }
                                     if (Is::Defined("VALIDATED_FULL_LOGIN") && Is::Defined("LOGIN") && !Is::Defined("SERVERSETUP") && !Is::Defined("MANAGEMENT")) {
                                         $operator->ValidateUpdateSession(getId(32), $_POST[POST_INTERN_AUTHENTICATION_CLIENT_SYSTEM_ID]);
                                     } else {
                                         if (LOGOFF) {
                                             $operator->ValidateUpdateSession("", "");
                                         }
                                     }
                                     define("AUTH_RESULT", LOGIN_REPLY_SUCCEEDED);
                                     break;
                                 }
                             } else {
                                 $operator->DeleteLoginAttempts();
                                 if (!empty($_POST[POST_INTERN_AUTHENTICATION_PASSWORD])) {
                                     $operator->SaveLoginAttempt(md5($_POST[POST_INTERN_AUTHENTICATION_PASSWORD]));
                                 }
                                 break;
                             }
                         }
                     }
                 }
             }
         } else {
             define("AUTH_RESULT", LOGIN_REPLY_DB);
         }
     }
     if (OperatorRequest::IsValidated() && LOGIN) {
         Server::$Operators[CALLER_SYSTEM_ID]->IP = Communication::GetIP();
         Server::$Operators[CALLER_SYSTEM_ID]->FirstActive = time();
         Server::$Operators[CALLER_SYSTEM_ID]->VisitorFileSizes = array();
         Server::$Operators[CALLER_SYSTEM_ID]->VisitorStaticReload = array();
         $isex = !empty(Server::$Operators[CALLER_SYSTEM_ID]->Groups) && Server::$Groups[Server::$Operators[CALLER_SYSTEM_ID]->Groups[0]]->IsExternal;
         Server::$Response->Login = Server::$Operators[CALLER_SYSTEM_ID]->GetLoginReply($isex, SystemTime::GetTimeDifference($_POST[POST_INTERN_CLIENT_TIME]));
     }
     if (!defined("AUTH_RESULT")) {
         define("AUTH_RESULT", LOGIN_REPLY_BAD_COMBINATION);
     }
 }