public function __construct($file, $roomId) { // get file $this->name = Fari_Escape::file($file['name'], TRUE); $this->mime = $file['type']; // db instance $db = Fari_Db::getConnection(); $type = explode('/', $this->mime); $type = count($type) > 1 ? $type[1] : $type[0]; // set generic filetype for files we don't have icons for :) if (!in_array($type, $this->fileTypes)) { $type = 'generic'; } $stream = fopen($file['tmp_name'], 'rb'); $code = $this->randomCode($db); $date = SystemTime::timestampToDate(); // let's associate the file with a transcript (there better be a transcript...) $transcript = $db->selectRow('room_transcripts', 'key', array('date' => $date, 'room' => $roomId)); // insert the file $db->query("INSERT INTO files (mime, data, code, room, filename, type, date, transcript)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)", array($this->mime, $stream, $this->code = $code, $roomId, $this->name, $this->type = $type, $date, $transcript['key'])); fclose($stream); // create a thumbnail if required $thumbnail = new UploadThumbnail($file); if ($thumbnail->isCreated()) { // yes we do have one $this->thumbnail = TRUE; $thumb = fopen($thumbnail->getPath(), 'rb'); // insert the thumbnail $db->query("INSERT INTO thumbs (data, code) VALUES (?, ?)", array($thumb, $this->code)); fclose($thumb); //$thumbnail->destroy(); } }
/** * Delete the transcript. */ public function delete($date, $shortName) { // transcript users are not needed anymore $this->db->delete('transcript_users', array('transcript' => $this->details['key'])); // files $files = $this->db->selectRow('files', 'group_concat(code) as codes', array('transcript' => $this->details['key'])); $this->db->delete('files', array('transcript' => $this->details['key'])); // thumbnails aka silly quoting $codes = explode(',', $files['codes']); foreach ($codes as &$code) { $code = "'{$code}'"; } $codes = implode(', ', $codes); $this->db->delete('thumbs', "code IN ({$codes})"); // finaly ourselves $this->db->delete('room_transcripts', array('key' => $this->details['key'])); // reset the last activity for the room so a new transcript can be created $this->db->update('rooms', array('activity' => 0), array('id' => $this->details['room'])); // delete all messages for the day $this->db->delete('messages', array('room' => $this->details['room'], 'date' => $this->details['date'])); // has this happened today? if ($date == SystemTime::timestampToDate()) { $message = new MessageSpeak($this->details['room'], mktime()); $message->transcript($this->details['room'], $shortName, $date); } }
/** * Say that a topic has been set/cleared * * @param integer $roomId Id of the room * @param string $shortName Short version of the user's name * @param string $topic Topic that has been set * @return void */ public function topic($roomId, $shortName, $topic) { $text = empty($topic) ? 'cleared the topic ' : "changed the room's topic to <em>{$topic}</em>"; $this->db->insert('messages', array('room' => $roomId, 'user' => $shortName, 'type' => 'topic', 'text' => $text, 'date' => SystemTime::timestampToDate(), 'locked' => $this->lockedRoom)); }
function getChangeVoucherHTML($_vouchers) { global $VOUCHER; $voucherHTML = IOStruct::GetFile(PATH_TEMPLATES . "chat_voucher_change_item.tpl"); $tableHTML = IOStruct::GetFile(PATH_TEMPLATES . "chat_voucher_change_table.tpl"); $vouchersHTML = ""; foreach ($_vouchers as $voucher) { $vouchersHTML .= $voucherHTML; $vouchersHTML = str_replace("<!--id-->", $voucher->Id == $VOUCHER->Id ? "<b>" . $voucher->Id . "</b>" : $voucher->Id, $vouchersHTML); $vouchersHTML = str_replace("<!--selected-->", $voucher->Id == $VOUCHER->Id ? "CHECKED" : "", $vouchersHTML); if ($voucher->ChatSessionsMax > -1) { $vouchersHTML = str_replace("<!--sessions-->", $voucher->ChatSessions . " / " . $voucher->ChatSessionsMax, $vouchersHTML); } else { $vouchersHTML = str_replace("<!--display_sessions-->", "none", $vouchersHTML); } if ($voucher->ChatTimeMax > -1) { $vouchersHTML = str_replace("<!--time-->", SystemTime::FormatTimeSpan($voucher->ChatTimeRemaining), $vouchersHTML); } else { $vouchersHTML = str_replace("<!--display_time-->", "none", $vouchersHTML); } if ($voucher->VoucherAutoExpire > -1) { $parts = explode(date("Y", $voucher->VoucherAutoExpire), date("r", $voucher->VoucherAutoExpire)); $vouchersHTML = str_replace("<!--expires-->", $parts[0] . date("Y", $voucher->VoucherAutoExpire), $vouchersHTML); } else { $vouchersHTML = str_replace("<!--display_expires-->", "none", $vouchersHTML); } if ($voucher->ChatSessionsMax - $voucher->ChatSessions > 0) { $vouchersHTML = str_replace("<!--class_sessions-->", "lz_chat_com_chat_panel_value", $vouchersHTML); } else { if ($voucher->ChatSessionsMax - $voucher->ChatSessions <= 0) { $vouchersHTML = str_replace("<!--class_sessions-->", "lz_chat_com_chat_panel_value_over", $vouchersHTML); } } if ($voucher->ChatTimeRemaining > 0) { $vouchersHTML = str_replace("<!--class_time-->", "lz_chat_com_chat_panel_value", $vouchersHTML); } else { if ($voucher->ChatTimeRemaining <= 0) { $vouchersHTML = str_replace("<!--class_time-->", "lz_chat_com_chat_panel_value_over", $vouchersHTML); } } if ($voucher->VoucherAutoExpire > time()) { $vouchersHTML = str_replace("<!--class_expires-->", "lz_chat_com_chat_panel_value", $vouchersHTML); } else { if ($voucher->VoucherAutoExpire > 0) { $vouchersHTML = str_replace("<!--class_expires-->", "lz_chat_com_chat_panel_value_over", $vouchersHTML); } } $vouchersHTML = str_replace("<!--display_sessions-->", "''", $vouchersHTML); $vouchersHTML = str_replace("<!--display_time-->", "''", $vouchersHTML); $vouchersHTML = str_replace("<!--display_expires-->", "''", $vouchersHTML); } $tableHTML = str_replace("<!--vouchers-->", $vouchersHTML, $tableHTML); $tableHTML = str_replace("<!--server-->", LIVEZILLA_URL, $tableHTML); $tableHTML = str_replace("<!--vouchers-->", $vouchersHTML, $tableHTML); return Server::Replace($tableHTML, true, false); }
static function Execute($_log, $_sql, $_serversetup = false, &$_errorCode = -1) { if (!DB_CONNECTION && !(Server::IsServerSetup() && !empty(DBManager::$Provider))) { Logging::DatabaseLog("Query without connection: " . $_sql . " " . serialize(debug_backtrace())); return false; } SystemTime::GetExecutionTime(); $result = DBManager::$Connector->Query($_log, $_sql, $_errorCode); return $result; }
function Save() { $time = SystemTime::GetMicroTime(); DBManager::Execute(true, "INSERT IGNORE INTO `" . DB_PREFIX . DATABASE_STATS_AGGS . "` (`year`,`month`,`day`,`time`,`mtime`) VALUES (" . $this->GetSQLDateValues() . "," . $time[1] . "," . $time[0] . ");"); }
function processTicketActions($count = 0) { $temporaryIds = array(); $updateRequiredTickets = $updateRequiredEmails = false; while (isset($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vc"])) { $type = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vc"]; if ($type == "SetTicketStatus") { $Ticket = new Ticket(); $Ticket->Id = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"]; if ($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]) { $Ticket->Log(0, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]); } if (!empty($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"]) && $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]) { $Ticket->Log(2, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]); } if ($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]) { $Ticket->Log(3, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]); } $TicketEditor = new TicketEditor($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"]); if (!empty($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"])) { $TicketEditor->Editor = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"]; } $TicketEditor->Status = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]; $TicketEditor->GroupId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]; $TicketEditor->Save(); if ($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]) { $Ticket->SetGroup($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]); } $Ticket->Editor = $TicketEditor; $Ticket->LoadMessages(); $time = SystemTime::GetUniqueMessageTime(DATABASE_TICKETS, "last_update"); $Ticket->SetLastUpdate($time); $updateRequiredTickets = true; } else { if ($type == "AddTicketEditorReply") { $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]); $Ticket->Load(false, false); $Ticket->Group = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]; $Ticket->Messages[0]->Id = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_7"]; $Ticket->Messages[0]->ChannelId = getId(32); $Ticket->Messages[0]->Hash = $Ticket->GetHash(false); $Ticket->Messages[0]->SenderUserId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"]; $Ticket->Messages[0]->Type = 1; $Ticket->Messages[0]->Email = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]; $Ticket->Messages[0]->Text = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]; if ($Ticket->CreationType >= 6 && !empty($Ticket->ChannelId)) { $twchannel = SocialMediaChannel::GetChannelById($Ticket->ChannelId); if ($Ticket->CreationType == 7 && $twchannel->StreamType == 1) { $Ticket->Messages[0]->Text = $twchannel->AddScreenName($Ticket->Messages[0]->Text, $Ticket->Messages[0]->Email); } else { if ($Ticket->CreationType == 6) { $Ticket->Messages[0]->Email = $twchannel->PageId; } } } $Ticket->Messages[0]->Subject = cutString($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_5"], 255, false); $Ticket->Messages[0]->Save($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"], time()); $acount = 8; while (isset($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $acount])) { $Ticket->Messages[0]->ApplyAttachment($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $acount++]); } $Ticket->SendEditorReply($Ticket->Messages[0]->Id, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_6"]); if (!empty(Server::$Configuration->File["gl_ctor"])) { $Ticket->LoadStatus(); $Ticket->Editor->Status = TICKET_STATUS_CLOSED; $Ticket->Editor->Save(); } $Ticket->SetLastUpdate(time()); $updateRequiredTickets = true; } else { if ($type == "SetTicketLanguage") { $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]); $Ticket->SetLanguage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]); $Ticket->Log(1, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]); $Ticket->SetLastUpdate(time()); $updateRequiredTickets = true; } else { if ($type == "DeleteTicketFromServer") { $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], ""); $Ticket->Destroy(); $Ticket->Log(7, CALLER_SYSTEM_ID, 0, 1); $Ticket->SetLastUpdate(time()); $updateRequiredTickets = true; } else { if ($type == "AddComment") { $Ticket = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], ""); $Ticket->AddComment(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]); $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"], ""); $Ticket->SetLastUpdate(time()); $updateRequiredTickets = true; } else { if ($type == "LinkChat") { if (!empty($temporaryIds[$_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]])) { $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"] = $temporaryIds[$_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]]; } $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], ""); $Ticket->LinkChat($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], getId(32)); $Ticket->Log(5, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]); $Ticket->SetLastUpdate(time()); $updateRequiredTickets = true; } else { if ($type == "LinkTicket") { $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], ""); $TicketSub = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], ""); $counts[$Ticket->Id] = Ticket::GetMessageCount($Ticket->Id); $counts[$TicketSub->Id] = Ticket::GetMessageCount($TicketSub->Id); if ($counts[$Ticket->Id] > $counts[$TicketSub->Id]) { $Ticket->LinkTicket($TicketSub->Id, getId(32)); } else { $TicketSub->LinkTicket($Ticket->Id, getId(32)); } $Ticket->SetLastUpdate(time()); $updateRequiredTickets = true; } else { if ($type == "EditMessage") { $ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], ""); $ticket->LoadStatus(); $message = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], ""); $message->Load(); $message->ChangeValue($ticket, 10, CALLER_SYSTEM_ID, $message->Fullname, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]); $message->ChangeValue($ticket, 11, CALLER_SYSTEM_ID, $message->Email, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]); $message->ChangeValue($ticket, 12, CALLER_SYSTEM_ID, $message->Company, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]); $message->ChangeValue($ticket, 13, CALLER_SYSTEM_ID, $message->Phone, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_5"]); $message->ChangeValue($ticket, 14, CALLER_SYSTEM_ID, $message->Subject, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_6"]); $message->ChangeValue($ticket, 15, CALLER_SYSTEM_ID, $message->Text, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_7"]); $message->ApplyCustomFromPost($count, true, $ticket, CALLER_SYSTEM_ID); $message->Save($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], true); $ticket->SetLastUpdate(time(), false); $updateRequiredTickets = true; if ($ticket->Editor != null) { $ticket->Editor->Save(); } } else { if ($type == "CreateTicket") { $Ticket = new Ticket(CacheManager::GetObjectId("ticket_id", DATABASE_TICKETS), ""); $temporaryIds[$_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_11"]] = $Ticket->Id; $Ticket->Messages[0]->Id = $Ticket->Id; $Ticket->Messages[0]->ChannelId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]; $Ticket->CreationType = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]; $Ticket->Group = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_6"]; $Ticket->Language = strtoupper(trim($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_10"])); $Ticket->Messages[0]->Fullname = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]; $Ticket->Messages[0]->Email = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]; $Ticket->Messages[0]->Text = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]; $Ticket->Messages[0]->Company = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_7"]; $Ticket->Messages[0]->Phone = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_8"]; $Ticket->Messages[0]->Type = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_9"]; $Ticket->Messages[0]->Subject = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_15"]; $Ticket->Messages[0]->ApplyCustomFromPost($count); $cid = 0; while (isset($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $cid])) { $value = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $cid++]; if (strpos($value, "[att]") === 0) { $Ticket->Messages[0]->ApplyAttachment(base64_decode(str_replace("[att]", "", $value))); } else { if (strpos($value, "[com]") === 0) { $Ticket->Messages[0]->AddComment(CALLER_SYSTEM_ID, $Ticket->Id, base64_decode(str_replace("[com]", "", $value))); } } } $Ticket->Messages[0]->LoadAttachments(); if (!empty($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"])) { $email = new TicketEmail($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"], false, ""); $email->Load(); $email->LoadAttachments(); foreach ($email->Attachments as $rid => $res) { if (empty($Ticket->Messages[0]->Attachments[$rid])) { KnowledgeBase::Process(CALLER_SYSTEM_ID, $rid, "", RESOURCE_TYPE_FILE_INTERNAL, "", true, 100, 1, 0); } } $email->Destroy(); if (!empty($email->Created)) { $Ticket->Messages[0]->Created = $email->Created; } } $Ticket->Save(); $TicketEditor = new TicketEditor($Ticket->Id); $TicketEditor->Editor = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_13"]; $TicketEditor->Status = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_12"]; $TicketEditor->GroupId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_14"]; $TicketEditor->Save(); $Ticket->Log(6, CALLER_SYSTEM_ID, $Ticket->Id, ""); $Ticket->SetLastUpdate(time()); $updateRequiredTickets = true; } else { if ($type == "SetEmailStatus") { $Email = new TicketEmail($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]); $Email->SetStatus(); $updateRequiredEmails = true; } else { if ($type == "ForwardMessage") { $message = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], ""); $message->Load(); $message->Forward($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]); $ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_5"], ""); $ticket->Log(9, CALLER_SYSTEM_ID, $message->Id, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]); } else { if ($type == "MoveMessageIntoTicket") { $message = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], ""); $message->Load(true); $message->ChannelId = getId(32); $ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], ""); $ticket->Load(); $ticket->Id = $message->Id = CacheManager::GetObjectId("ticket_id", DATABASE_TICKETS); $ticket->Messages = array(); $ticket->Messages[0] = $message; $ticket->Save(); $ticket->Log(8, CALLER_SYSTEM_ID, $ticket->Id, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]); $message->SaveAttachments(); $message->SaveComments($ticket->Id); $updateRequiredTickets = true; } else { if ($type == "DeleteAttachment") { KnowledgeBase::Process(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "", RESOURCE_TYPE_FILE_INTERNAL, "", true, "100", "1"); } } } } } } } } } } } } } $count++; } if ($updateRequiredTickets) { CacheManager::SetDataUpdateTime(DATA_UPDATE_KEY_TICKETS); } if ($updateRequiredEmails) { CacheManager::SetDataUpdateTime(DATA_UPDATE_KEY_EMAILS); } }
function Save($_resolution, $_color, $_timezone, $_lat, $_long, $_countryiso2, $_city, $_region, $_geotimezone, $_isp, $_geosspan, $_grid, $_js = true, $_fromCookie = false) { if (!$this->FirstCall) { $this->KeepAlive(); } else { if (!Is::Null(Cookie::Get("visits")) && $this->Visits == 1) { $this->Visits = Cookie::Get("visits") + 1; } Cookie::Set("visits", $this->Visits); if (!Is::Null(Cookie::Get("last_visit"))) { $this->VisitLast = Cookie::Get("last_visit"); } Cookie::Set("last_visit", time()); $this->IP = Communication::GetIP(); $this->SystemInfo = !empty($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : ""; $localization = LocalizationManager::GetBrowserLocalization(); $this->Language = $localization[0]; if (!empty($localization[1])) { $this->GeoCountryISO2 = $localization[1]; } $this->Resolution = !empty($_resolution) && count($_resolution) == 2 && !empty($_resolution[0]) && !empty($_resolution[1]) ? $_resolution[0] . " x " . $_resolution[1] : ""; $this->Resolution .= !empty($_color) ? " (" . $_color . " Bit)" : ""; $this->GeoTimezoneOffset = SystemTime::GetLocalTimezone($_timezone); $this->GeoResult = 0; if (!empty($_geosspan)) { GeoTracking::SpanCreate($_geosspan); } if (!empty(Server::$Configuration->File["gl_use_ngl"]) && $_js) { if (!Is::Null(Cookie::Get("geo_data")) && !Is::Null(Cookie::Get(GEO_LATITUDE))) { $this->GeoLatitude = Cookie::Get(GEO_LATITUDE); $this->GeoLongitude = Cookie::Get(GEO_LONGITUDE); $this->GeoCountryISO2 = Cookie::Get(GEO_COUNTRY_ISO_2); $this->GeoCity = Cookie::Get(GEO_CITY); $this->GeoRegion = Cookie::Get(GEO_REGION); $this->GeoTimezoneOffset = Cookie::Get(GEO_TIMEZONE); $this->GeoISP = Cookie::Get(GEO_ISP); $_fromCookie = true; } else { if (!empty($_lat) && $_lat > -180) { Cookie::Set(GEO_LATITUDE, $this->GeoLatitude = $_lat); Cookie::Set(GEO_LONGITUDE, $this->GeoLongitude = $_long); Cookie::Set(GEO_COUNTRY_ISO_2, $this->GeoCountryISO2 = $_countryiso2); Cookie::Set(GEO_CITY, $this->GeoCity = $_city); Cookie::Set(GEO_REGION, $this->GeoRegion = $_region); Cookie::Set(GEO_TIMEZONE, $this->GeoTimezoneOffset = $_geotimezone); Cookie::Set(GEO_ISP, $this->GeoISP = $_isp); Cookie::Set("geo_data", time()); } else { if (!empty($_lat)) { $this->GeoLatitude = $_lat; $this->GeoLongitude = $_long; } } } GeoTracking::SpanRemove(false); if ($_fromCookie) { $this->GeoResultId = 6; } else { if (!Is::Null($span = GeoTracking::SpanExists())) { if ($span > time() + CONNECTION_ERROR_SPAN) { $this->GeoResultId = 5; } else { $this->GeoResultId = 4; } } else { if ($_lat == -777) { $this->GeoResultId = 5; } else { if ($_lat == -522) { $this->GeoResultId = 2; } else { if ($_grid != 4) { $this->GeoResultId = 3; } else { $this->GeoResultId = $_grid; } } } } } } else { $this->GeoResultId = 7; } Server::InitDataBlock(array("COUNTRIES")); if (isset(Server::$CountryAliases[$this->GeoCountryISO2])) { $this->GeoCountryISO2 = Server::$CountryAliases[$this->GeoCountryISO2]; } $detector = new DeviceDetector(); $detector->DetectBrowser($this->Host); if ($detector->AgentType == AGENT_TYPE_BROWSER || $detector->AgentType == AGENT_TYPE_UNKNOWN) { $detector->DetectOperatingSystem($this->Host); $bid = $this->GetBrowserId($detector->Browser, $detector->AgentType); $oid = $this->GetOSId($detector->OperatingSystem); $this->CreateSignature(); DBManager::Execute(true, "INSERT IGNORE INTO `" . DB_PREFIX . DATABASE_VISITORS . "` (`id`, `entrance`,`last_active`, `host`,`ip`,`system`,`browser`, `visits`,`visit_id`,`visit_last`,`resolution`, `language`, `country`, `city`, `region`, `isp`, `timezone`, `latitude`, `longitude`, `geo_result`, `js`, `signature`) VALUES ('" . DBManager::RealEscape($this->UserId) . "', '" . DBManager::RealEscape(time()) . "','" . DBManager::RealEscape(time()) . "', '" . DBManager::RealEscape($this->Host) . "', '" . DBManager::RealEscape($this->IP) . "', '" . DBManager::RealEscape($oid) . "','" . DBManager::RealEscape($bid) . "', '" . DBManager::RealEscape($this->Visits) . "', '" . DBManager::RealEscape($this->VisitId) . "','" . DBManager::RealEscape($this->VisitLast) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_RESOLUTIONS, "resolution", $this->Resolution, false, 32)) . "', '" . DBManager::RealEscape(substr(strtoupper($this->Language), 0, 5)) . "','" . DBManager::RealEscape($this->GeoCountryISO2) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_CITIES, "city", $this->GeoCity, false)) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_REGIONS, "region", $this->GeoRegion, false)) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_ISPS, "isp", utf8_encode($this->GeoISP), false)) . "', '" . DBManager::RealEscape($this->GeoTimezoneOffset) . "', '" . DBManager::RealEscape($this->GeoLatitude) . "', '" . DBManager::RealEscape($this->GeoLongitude) . "', '" . DBManager::RealEscape($this->GeoResultId) . "', '" . DBManager::RealEscape($_js ? 1 : 0) . "', '" . DBManager::RealEscape($this->Signature) . "');"); if ($this->VisitsDay > 1 && DBManager::GetAffectedRowCount() == 1) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_VISITORS . "` SET `visit_latest`=0 WHERE `id`='" . DBManager::RealEscape($this->UserId) . "' AND `visit_id`!='" . DBManager::RealEscape($this->VisitId) . "';"); } } else { if (STATS_ACTIVE) { $this->IsCrawler = true; Server::$Statistic->ProcessAction(ST_ACTION_LOG_CRAWLER_ACCESS, array($this->GetCrawlerId($detector->Browser), null)); } } } }
* * Copyright 2015 LiveZilla GmbH * All rights reserved. * LiveZilla is a registered trademark. * * Improper changes to this file may cause critical errors. ***************************************************************************************/ define("IN_LIVEZILLA", true); define("SAFE_MODE", @ini_get('safe_mode')); define("LIVEZILLA_PATH", "./"); @error_reporting(E_ALL); require LIVEZILLA_PATH . "_definitions/definitions.inc.php"; require LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php"; require LIVEZILLA_PATH . "_lib/functions.global.inc.php"; require LIVEZILLA_PATH . "_lib/objects.devices.inc.php"; define("ACCESSTIME", SystemTime::GetRuntime()); if (Server::IsServerSetup()) { CacheManager::Flush(); } Server::DefineURL(FILE_SERVER_FILE); Operator::PrepareConnection(); require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php"; Server::InitDataProvider(); Server::SetTimeLimit(Server::$Configuration->File["timeout_clients"]); @ini_set('session.use_cookies', '0'); if (DEBUG_MODE) { @ini_set('display_errors', '1'); } @set_error_handler("handleError"); header("Access-Control-Allow-Origin: *"); $getRequest = Communication::GetParameterAlias("rqst");
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); } }