function LoadChat($_config, $_internal) { $declined = true; $this->Chat = null; $this->ChatRequestReceiptants = array(); $chatfiles = getDirectory($this->Folder, false); foreach ($chatfiles as $chatfile) { if (strpos($chatfile, "." . EX_CHAT_OPEN) !== false) { if (strpos($chatfile, "." . EX_CHAT_OPEN) !== false && ($_config["gl_alloc_mode"] == ALLOCATION_MODE_ALL || isnull($this->Chat))) { $partnerid = str_replace("." . EX_CHAT_OPEN, "", $chatfile); $chat = new Chat($this->Folder . $chatfile); $activated = $chat->IsActivated($partnerid); if (!$chat->Declined) { $declined = false; if (!$activated) { $this->ChatRequestReceiptants[] = $partnerid; } } if ($activated || isnull($this->Chat) || CALLER_TYPE != CALLER_TYPE_EXTERNAL && !isnull($this->Chat) && ($partnerid == $_internal->SystemId && !$chat->IsActivated(null))) { if (CALLER_TYPE != CALLER_TYPE_EXTERNAL && $chat->Declined) { continue; } $this->Chat = $chat; if (isnull($_internal)) { $_internal = new Operator($partnerid, null); $_internal->Load(); $this->DesiredChatPartnerTyping = $_internal->Typing == $this->SystemId; } $dataSetTime = getDataSetTime($_internal->SessionFile); if ($_internal->Status == CHAT_STATUS_ACTIVE || $dataSetTime < time() - $_config["timeout_clients"]) { $this->Chat->Closed = true; } } } else { unlinkDataSet($this->Folder . $chatfile); } } } if (!isnull($this->Chat)) { $this->Chat->Declined = $declined; } }
} } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_GET_BANNER_LIST) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; getBannerList(); } else { $RESPONSE->SetValidationError(AUTH_RESULT); } } if (LOGOFF) { $INTERNAL[CALLER_SYSTEM_ID]->GetExternalObjects(); foreach ($INTERNAL[CALLER_SYSTEM_ID]->ExternalChats as $chat) { $chat->InternalClose(); } } if (defined("VALIDATED") && !SERVERSETUP) { if (LOGIN || isset($_POST[POST_GLOBAL_SHOUT]) || !isset($_POST[POST_GLOBAL_SHOUT]) && $INTERNAL[CALLER_SYSTEM_ID]->LastActive == getDataSetTime($INTERNAL[CALLER_SYSTEM_ID]->SessionFile, true)) { $INTERNAL[CALLER_SYSTEM_ID]->Save(); } } if (LOGIN && DB_ACCESS_REQUIRED) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; $res = testDataBase($CONFIG["gl_db_host"], $CONFIG["gl_db_user"], $CONFIG["gl_db_pass"], $CONFIG["gl_db_name"], $CONFIG["gl_db_prefix"]); if (!isnull($res)) { $RESPONSE->SetValidationError(LOGIN_REPLY_DB, $res); } } $RESPONSE->GlobalHash = isnull($RESPONSE->Messages) && isnull($RESPONSE->Ratings) && isnull($RESPONSE->Resources) && isnull($RESPONSE->Archive) ? substr(md5($RESPONSE->XML), 0, 5) : ""; $RESPONSE->XML = $_POST[POST_INTERN_SERVER_ACTION] != INTERN_ACTION_LISTEN || isset($_POST[POST_GLOBAL_XMLCLIP_HASH_ALL]) && $_POST[POST_GLOBAL_XMLCLIP_HASH_ALL] != $RESPONSE->GlobalHash ? str_replace("<!--gl_all-->", base64_encode(substr(md5($RESPONSE->XML), 0, 5)), $RESPONSE->XML) : ""; $response = strlen($RESPONSE->XML) > 0 ? $RESPONSE->GetXML() : ""; $response = str_replace("<!--execution_time-->", base64_encode(floor((microtimeFloat(microtime()) - microtimeFloat(ACCESSTIME)) * 1000)), $response);
function GetStaticInfo($found = false) { global $USER; $USER->ExternalStatic = new ExternalStatic($USER->UserId); foreach ($USER->Browsers as $browserId => $BROWSER) { if (isset($this->SessionFileSizes[$USER->UserId][$browserId])) { $found = true; break; } } if ($this->GetAll || isset($this->StaticReload[$USER->UserId]) || !$found || getDataSetTime($this->Caller->SessionFile) <= getDataSetTime($USER->ExternalStatic->SessionFile) && !in_array($USER->UserId, $this->CurrentStatics)) { if (isset($this->StaticReload[$USER->UserId])) { unset($this->StaticReload[$USER->UserId]); } array_push($this->CurrentStatics, $USER->UserId); $USER->ExternalStatic->Load(); } else { $USER->ExternalStatic = null; } }
function buildTracking() { global $VISITOR, $CONFIG, $DATASETS; $VISITOR = array(); $outdatedVisitors = array(); $itarray = array_keys($DATASETS); foreach ($itarray as $file) { $dataset = $DATASETS[$file]; if (strpos($file, PATH_DATA_EXTERNAL) !== false && substr($file, 0, strlen(PATH_DATA_EXTERNAL)) == PATH_DATA_EXTERNAL) { $userid = substr(str_replace(PATH_DATA_EXTERNAL, "", $file), 0, USER_ID_LENGTH); $browsers = getDirectory(PATH_DATA_EXTERNAL . $userid . "/b/", "."); if (count($browsers) > 0) { foreach ($browsers as $browserid) { $browser = new ExternalBrowser($browserid, $userid); $chat = new ExternalChat($userid, $browserid); if (!isset($VISITOR[$userid])) { $VISITOR[$userid] = new UserExternal($userid); } if (($bStime = getDataSetTime($browser->SessionFile)) != -1) { if ($bStime < time() - $CONFIG["timeout_track"]) { $browser->Destroy(); continue; } $VISITOR[$userid]->Browsers[$browserid] = $browser; } else { if (($cStime = getDataSetTime($chat->SessionFile)) != -1) { $chat->Load(); if ($cStime < time() - $CONFIG["timeout_clients"]) { $chat->Destroy(); continue; } if (isnull($chat->FirstActive)) { $chat->FirstActive = time(); } $chat->History[0] = array($chat->FirstActive, LIVEZILLA_URL . FILE_CHAT, $chat->Code, true); $VISITOR[$userid]->Browsers[$browserid] = $chat; } else { $browser->Destroy(); $chat->Destroy(); } } } } else { $outdatedVisitors[] = $userid; } } } foreach ($outdatedVisitors as $folder) { deleteDirectory(PATH_DATA_EXTERNAL . $folder); } }
function removeChats() { global $INTERNAL, $CONFIG; foreach ($INTERNAL[CALLER_SYSTEM_ID]->ExternalChats as $chat) { if (!dataSetExists($chat->ExternalUser->SessionFile) || $chat->Closed && getDataSetTime($chat->ExternalUser->SessionFile) < time() - $CONFIG["timeout_clients"]) { $chat->InternalDestroy(); $chat->ExternalUser->Destroy($CONFIG); } } }