function demandTickets($xml = "", $q_filter = "", $q_searchw = "", $q_searchf = "", $c_total = 0, $c_totalread = 0, $c_totalquery = 0, $c_lmc = 0, $c_name = "", $c_text = "", $loads = 0) { $permission = Server::$Operators[CALLER_SYSTEM_ID]->GetPermission(PERMISSION_TICKETS); if ($permission != PERMISSION_NONE) { if (!CacheManager::IsDataUpdate(POST_INTERN_DUT_TICKETS, DATA_UPDATE_KEY_TICKETS) && CacheManager::$DataUpdateTimes[DATA_UPDATE_KEY_TICKETS] != 0) { return; } if (!isset($_POST["p_dt_c_id"])) { $_POST["p_dt_c_id"] = $_POST["p_dt_u_id"] = ""; } if (!empty($_POST["p_dt_q"])) { unset($_POST["p_dt_f"], $_POST["p_dt_fc"], $_POST["p_dt_fp"], $_POST["p_dt_fg"]); } if (!isset($_POST["p_dt_f"])) { $_POST["p_dt_f"] = "0123"; } else { if ($_POST["p_dt_f"] == "") { $_POST["p_dt_f"] = "9"; } } if (!isset($_POST["p_dt_fc"])) { $_POST["p_dt_fc"] = "01234567"; } else { if ($_POST["p_dt_fc"] == "") { $_POST["p_dt_fc"] = "9"; } } $loads = !empty($_POST["p_dt_l"]) && is_numeric($_POST["p_dt_l"]) ? $_POST["p_dt_l"] : DATA_DEMAND_LOADS; $limit = !empty($_POST["p_dt_p"]) && is_numeric($_POST["p_dt_p"]) && $_POST["p_dt_p"] > 1 ? ($_POST["p_dt_p"] - 1) * $loads : 0; $q_sort = array(); $q_sort["id"] = " AND `deleted`=0 GROUP BY `" . DB_PREFIX . DATABASE_TICKETS . "`.`id` ORDER BY `" . DB_PREFIX . DATABASE_TICKETS . "`.`id` " . (!empty($_POST["p_dt_s_d"]) ? $_POST["p_dt_s_d"] : "DESC"); $q_sort["update"] = " AND `deleted`=0 GROUP BY `" . DB_PREFIX . DATABASE_TICKETS . "`.`id` ORDER BY `" . DB_PREFIX . DATABASE_TICKETS . "`.`last_update` " . (!empty($_POST["p_dt_s_d"]) ? $_POST["p_dt_s_d"] : "DESC"); $q_sort["wait"] = " AND `deleted`=0 GROUP BY `" . DB_PREFIX . DATABASE_TICKETS . "`.`id` ORDER BY `" . DB_PREFIX . DATABASE_TICKETS . "`.`wait_begin` " . (!empty($_POST["p_dt_s_d"]) ? $_POST["p_dt_s_d"] : "ASC"); $sort_index = !empty($_POST["p_dt_s"]) && !empty($q_sort[$_POST["p_dt_s"]]) ? $_POST["p_dt_s"] : "id"; if (!(!empty($_POST["p_dt_mr"]) && is_numeric($_POST["p_dt_mr"]))) { $max_last_update_read = time() - 14 * 86400; } else { $max_last_update_read = $_POST["p_dt_mr"]; } $fchars = str_split($_POST["p_dt_f"]); foreach ($fchars as $fchar) { if (is_numeric($fchar)) { if (!empty($fchar)) { $q_filter .= empty($q_filter) ? " `te`.`status`=" . $fchar : " OR `te`.`status`=" . $fchar; } else { $q_filter .= empty($q_filter) ? " `te`.`status` IS NULL OR `te`.`status`=0" : " OR `te`.`status` IS NULL OR `te`.`status`=0"; } } } $fchars = str_split($_POST["p_dt_fc"]); $q_filter_channel = ""; foreach ($fchars as $fchar) { if (is_numeric($fchar)) { if (!empty($fchar)) { $q_filter_channel .= empty($q_filter_channel) ? "`creation_type`=" . $fchar : " OR `creation_type`=" . $fchar; } else { $q_filter_channel .= empty($q_filter_channel) ? "`creation_type` IS NULL OR `creation_type`=0" : " OR `creation_type` IS NULL OR `creation_type`=0"; } } } $q_filter = empty($q_filter) ? $q_filter_channel : "(" . $q_filter . ") AND ( " . $q_filter_channel . ")"; if (!empty($_POST["p_dt_fp"])) { if (empty($q_filter)) { $q_filter .= "`te`.`editor_id`='" . DBManager::RealEscape(CALLER_SYSTEM_ID) . "'"; } else { $q_filter = "(" . $q_filter . ") AND `te`.`editor_id`='" . DBManager::RealEscape(CALLER_SYSTEM_ID) . "'"; } } if (!empty($_POST["p_dt_fg"]) && $permission == PERMISSION_FULL) { if (empty($q_filter)) { $q_filter .= "`target_group_id` IN ('" . implode("','", Server::$Operators[CALLER_SYSTEM_ID]->Groups) . "')"; } else { $q_filter = "(" . $q_filter . ") AND `target_group_id` IN ('" . implode("','", Server::$Operators[CALLER_SYSTEM_ID]->Groups) . "')"; } } if (!empty($_POST["p_dt_q"])) { $q = DBManager::RealEscape(strtolower($_POST["p_dt_q"]), true); $q_searchf = " LEFT JOIN `" . DB_PREFIX . DATABASE_TICKET_CUSTOMS . "` AS `tc` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`tc`.`ticket_id`"; $q_searchf .= " LEFT JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` AS `tm` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`tm`.`ticket_id` "; $q_searchf .= " LEFT JOIN `" . DB_PREFIX . DATABASE_OPERATORS . "` AS `do` ON `te`.`editor_id`=`do`.`system_id` "; $q_searchw = "LOWER(`" . DB_PREFIX . DATABASE_TICKETS . "`.`hash`) LIKE '%" . $q . "%' OR LOWER(`do`.`fullname`) LIKE '%" . $q . "%' OR `tm`.`sender_id` LIKE '%" . $q . "%' OR `tm`.`ticket_id` LIKE '%" . $q . "%' OR LOWER(`tc`.`value`) LIKE '%" . $q . "%' OR LOWER(`tm`.`text`) LIKE '%" . $q . "%' OR LOWER(`tm`.`fullname`) LIKE '%" . $q . "%' OR LOWER(`tm`.`email`) LIKE '%" . $q . "%' OR LOWER(`tm`.`company`) LIKE '%" . $q . "%' OR LOWER(`tm`.`phone`) LIKE '%" . $q . "%' OR LOWER(`tm`.`subject`) LIKE '%" . $q . "%'"; if (!empty($_POST["p_dt_q_e"])) { $q_e = DBManager::RealEscape(strtolower($_POST["p_dt_q_e"])); $emails = explode(",", $q_e); foreach ($emails as $email) { $q_searchw .= " OR LOWER(`tm`.`email`) LIKE '%" . DBManager::RealEscape(trim($email), true) . "%'"; } } $q_searchw = " AND (" . $q_searchw . ")"; } Server::InitDataBlock(array("INPUTS")); $q_grperm = $permission == PERMISSION_FULL ? "" : "`target_group_id` IN ('" . implode("','", Server::$Operators[CALLER_SYSTEM_ID]->Groups) . "') AND "; $q_inner = "FROM `" . DB_PREFIX . DATABASE_TICKETS . "` LEFT JOIN `" . DB_PREFIX . DATABASE_TICKET_EDITORS . "` AS `te` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`te`.`ticket_id` " . $q_searchf . "WHERE " . $q_grperm . "`deleted`=0 AND (" . $q_filter . ")" . $q_searchw . $q_sort[$sort_index]; $result = DBManager::Execute(true, $d = "SELECT * " . $q_inner . " LIMIT " . $limit . "," . DBManager::RealEscape($loads) . ";"); if ($result) { while ($row = DBManager::FetchArray($result)) { $ticket = new Ticket($row, null, null); $ticket->LoadLogs(); if (count($ticket->Messages) > 0) { $xml .= $ticket->GetXML(true, true); } } } $q_grperm = $permission == PERMISSION_FULL ? "" : " WHERE `target_group_id` IN ('" . implode("','", Server::$Operators[CALLER_SYSTEM_ID]->Groups) . "')"; $q_count["total"] = "SELECT COUNT(*) AS `total`"; $q_count["totalperm"] = "(SELECT COUNT(*) FROM (SELECT `" . DB_PREFIX . DATABASE_TICKETS . "`.`id` FROM `" . DB_PREFIX . DATABASE_TICKETS . "`" . $q_grperm . ") AS `sta`) AS `totalperm`"; $q_count["totalquery"] = "(SELECT COUNT(*) FROM (SELECT `" . DB_PREFIX . DATABASE_TICKETS . "`.`id` " . $q_inner . ") AS `stb`) AS `totalquery`"; $q_count["totalread"] = Server::$Operators[CALLER_SYSTEM_ID]->ClientWeb ? ",(SELECT COUNT(*) FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `deleted`=0 AND `last_update`>" . DBManager::RealEscape($max_last_update_read) . ") AS `totalread`" : ""; $result = DBManager::Execute(true, $q_count["total"] . "," . $q_count["totalperm"] . "," . $q_count["totalquery"] . $q_count["totalread"] . " FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `deleted`=0;"); $row = DBManager::FetchArray($result); if (!isset($row["totalread"])) { $row["totalread"] = 0; } $c_total = min($row["total"], $row["totalperm"]); $c_totalread = min($row["totalread"], $row["totalperm"]); $c_totalquery = min($row["totalquery"], $row["totalperm"]); $q_grperm = $permission == PERMISSION_FULL ? "" : "`target_group_id` IN ('" . implode("','", Server::$Operators[CALLER_SYSTEM_ID]->Groups) . "') AND "; $result = DBManager::Execute(true, "SELECT `t1`.`last_update` AS `lmc`,`fullname`,`text` FROM `" . DB_PREFIX . DATABASE_TICKETS . "` AS `t1` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` AS `t2` ON `t1`.`id`=`t2`.`ticket_id` WHERE " . $q_grperm . "(`t2`.`type`=0 OR `t2`.`type`=3) ORDER BY `t1`.`last_update` DESC LIMIT 1;"); if ($result && ($row = DBManager::FetchArray($result))) { $c_lmc = $row["lmc"]; $c_name = cutString($row["fullname"], 90); $c_text = cutString($row["text"], 90); } } Server::$Response->Messages .= "<dt u=\"" . base64_encode($_POST["p_dt_u_id"]) . "\" c=\"" . base64_encode($_POST["p_dt_c_id"]) . "\" dut=\"" . base64_encode(CacheManager::$DataUpdateTimes[DATA_UPDATE_KEY_TICKETS]) . "\" lmc=\"" . base64_encode($c_lmc) . "\" lmn=\"" . base64_encode($c_name) . "\" lmt=\"" . base64_encode($c_text) . "\" p=\"" . base64_encode($loads) . "\" t=\"" . base64_encode($c_total) . "\" r=\"" . base64_encode($c_totalread) . "\" q=\"" . base64_encode($c_totalquery) . "\">\r\n" . $xml . "\r\n</dt>"; }
function GetForwards() { $list = array(); $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_CHAT_FORWARDS . "` WHERE `target_group_id`='" . DBManager::RealEscape($this->DesiredChatGroup) . "' AND `visitor_id`='" . DBManager::RealEscape($this->UserId) . "' AND `browser_id`='" . DBManager::RealEscape($this->BrowserId) . "' ORDER BY `created` ASC;"); while ($row = DBManager::FetchArray($result)) { $list[] = new Forward($row); } return $list; }
function processChatActions() { global $INTERNAL, $RVISITOR; $count = 0; while (isset($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"])) { $type = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vd"]; if ($type == "OperatorSignOff") { $op = $INTERNAL[$_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]]; $op->SignOff(); } else { if ($type == "SendChatTranscriptTo") { $value = 1; while (!empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_" . $value])) { queryDB(true, "UPDATE `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` SET `transcript_sent`=0,`transcript_receiver`='" . DBManager::RealEscape($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]) . "' WHERE `transcript_sent`=1 AND `chat_id`='" . DBManager::RealEscape($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_" . $value]) . "' LIMIT 1;"); $value++; } sendChatTranscripts(true); } else { if ($type == "CreatePublicGroup") { $room = new UserGroup(); $room->IsDynamic = true; $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]; $room->Descriptions["EN"] = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]; $room->Owner = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]; $room->Save(); $room->AddMember($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"], !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_3"])); } else { if ($type == "DeletePublicGroup") { $room = new UserGroup(); $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]; $room->Destroy(); } else { if ($type == "JoinPublicGroup") { $room = new UserGroup(); $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]; $room->AddMember($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"], !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_3"])); } else { if ($type == "QuitPublicGroup") { $room = new UserGroup(); $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]; $room->RemoveMember($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]); } else { if ($type == "StartOverlayChat") { $chat = new VisitorChat($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]); $chat->RequestInitChat(CALLER_SYSTEM_ID); } else { if ($type == "AddVisitorComment") { $visitor = new Visitor($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); $visitor->SaveComment(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]); } else { if ($type == "DownloadRecentHistory") { $RVISITOR = new Visitor($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); $RVISITOR->LoadRecentVisits(true, $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]); } else { if ($type == "SetTranslation") { $chat = new VisitorChat($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]); $chat->ChatId = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]; $chat->SetTranslation($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]); } else { if ($type == "SetChatTicketParam") { $ticket = new CommercialChatVoucher("", $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); $ticket->Load(); $ticket->SetVoucherParams(!empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_3"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_4"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_5"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_6"])); } else { if (strlen($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]) > 0 && strlen($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"]) > 0) { $chat = new VisitorChat($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]); $chat->ChatId = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vc"]; $chat->Load(); if ($type == "SetCallMeBackStatus") { $chat->SetCallMeBackStatus($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); } else { if ($type == "JoinChatInvisible") { $chat->JoinChat(CALLER_SYSTEM_ID, true, !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"])); } else { if ($type == "JoinChat") { $chat->JoinChat(CALLER_SYSTEM_ID, false, !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"])); } else { if ($type == "SetPriority") { $chat->SetPriority($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); } else { if ($type == "SetTargetOperator") { $chat->SetTargetOperator($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); } else { if ($type == "SetTargetGroup") { $chat->SetTargetGroup($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); } else { if ($type == "AcceptChat") { $chat->InternalActivate(); } else { if ($type == "CloseChat") { $chat->InternalClose(CALLER_SYSTEM_ID); } else { if ($type == "TakeChat") { $chat->TakeChat(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]); } else { if ($type == "DeclineChat") { $chat->InternalDecline(CALLER_SYSTEM_ID); } else { if ($type == "LeaveChat") { $chat->LeaveChat(CALLER_SYSTEM_ID); } } } } } } } } } } } } } } } } } } } } } } } $count++; } }
} require LIVEZILLA_PATH . "_definitions/definitions.inc.php"; require LIVEZILLA_PATH . "_lib/functions.global.inc.php"; require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php"; require LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php"; require LIVEZILLA_PATH . "_lib/functions.external.inc.php"; @set_error_handler("handleError"); @error_reporting(E_ALL); header("Pragma: no-cache"); header("Cache-Control: no-cache, must-revalidate"); header("Keep-Alive: timeout=5, max=100"); Server::InitDataProvider(); if (!empty($_GET["value"]) && strlen($_GET["value"]) == 16) { $ticket = VisitorChat::GetMatchingVoucher($_GET[GET_EXTERN_GROUP], $_GET["value"]); if (!empty($ticket) && !$ticket->CheckForVoid() && $ticket->Paid) { $ticket->UpdateVoucherChatTime(0, empty($ticket->FirstUsed)); $sessions = $ticket->ChatSessionsMax < 0 ? 0 : $ticket->ChatSessionsMax; if ($result = DBManager::Execute(true, "SELECT `exit` FROM `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` WHERE `chat_ticket_id`='" . DBManager::RealEscape($ticket->Id) . "' AND `exit`=0 LIMIT 1;")) { if ($row = DBManager::FetchArray($result)) { exit("lz_validate_com_chat_input_result(false,true,1,'',0,0,0,false,false,false);"); } } exit("lz_validate_com_chat_input_result(true,false,1,'" . $ticket->Id . "'," . $ticket->ChatTime . "," . $ticket->ChatTimeMax . "," . $ticket->ChatSessions . "," . $ticket->ChatSessionsMax . "," . $ticket->VoucherAutoExpire . "," . To::BoolString($ticket->VoucherAutoExpire < time()) . ");"); } else { if (!empty($ticket)) { exit("lz_validate_com_chat_input_result(false,false,1,'',0,0,0,false,false,false);"); } } } exit("lz_validate_com_chat_input_result(false,false,0,'',0,0,0,false,false,false);"); Server::UnloadDataProvider();
public static function GetMatchingVoucher($_groupId, $_voucherid) { global $CONFIG, $GROUPS; initData(array("GROUPS")); $ticket = new CommercialChatVoucher("", $_voucherid); $ticket->Load(); $result = queryDB(true, $d = "SELECT *,`t1`.`id` AS `voucherid`, SUM(`chat_time_max`) AS `chat_time_max`, SUM(`chat_time`) AS `chat_time`, SUM(`chat_sessions`) AS `chat_sessions`, SUM(`chat_sessions_max`) AS `chat_sessions_max`, MAX(`expires`) AS `expires` FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_VOUCHERS . "` AS `t1` INNER JOIN `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` AS `t2` ON `t1`.`tid`=`t2`.`id` WHERE `t1`.`id`='" . DBManager::RealEscape($_voucherid) . "' ORDER BY `created` ASC;"); while ($row = @DBManager::FetchArray($result)) { if (!empty($CONFIG["db"]["cct"][$row["tid"]])) { $ticket = new CommercialChatVoucher($row); if (in_array($row["tid"], $GROUPS[$_groupId]->ChatVouchersRequired)) { return $ticket; } } } return null; }
static function Maintain($_randStandard, $_timeouts) { if (!Is::Defined("NO_DB_LOG")) { define("NO_DB_LOG", true); } if ($_randStandard == 1) { if (!STATS_ACTIVE) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `last_active`<" . DBManager::RealEscape(time() - Server::$Configuration->File["gl_dvhd"] * 86400) . ";"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_OPERATOR_STATUS . "` WHERE `" . DB_PREFIX . DATABASE_OPERATOR_STATUS . "`.`confirmed`<" . DBManager::RealEscape(time() - Server::$Configuration->File["gl_dvhd"] * 86400) . ";"); } else { StatisticProvider::DeleteHTMLReports(); } DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_EVENT_TRIGGERS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_EVENT_TRIGGERS . "`.`receiver_user_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE (`html` = '0' OR `html` = '') AND `time` < " . DBManager::RealEscape(time() - $_timeouts[3])); DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` SET `closed`='" . time() . "' WHERE `chat_type`<>1 AND `closed`<`endtime` AND `endtime`<" . (time() - 1800) . ";"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `closed`=0 AND `chat_type`=1 AND NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` WHERE `chat_id` = `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "`.`chat_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `time` < " . DBManager::RealEscape(time() - $_timeouts[3])); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `persistent` = '0' AND `time` < " . DBManager::RealEscape(time() - $_timeouts[1])); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `repost` = '1' AND `time` < " . DBManager::RealEscape(time() - $_timeouts[0])); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_OPERATOR_LOGINS . "` WHERE `time` < " . DBManager::RealEscape(time() - $_timeouts[1])); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_EVENT_ACTION_INTERNALS . "` WHERE `created` < " . DBManager::RealEscape(time() - $_timeouts[0])); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_PROFILE_PICTURES . "` WHERE `webcam`=1 AND `time` < " . DBManager::RealEscape(time() - $_timeouts[0])); $clr = ""; if (!empty(Server::$Configuration->File["gl_colt"])) { $clr = "`create` < " . intval(time() - Server::$Configuration->File["gl_colt"] * 86400) . " AND "; } DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_USER_DATA . "` WHERE " . $clr . "NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE `data_id` = `" . DB_PREFIX . DATABASE_USER_DATA . "`.`id`) AND NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_FEEDBACKS . "` WHERE `data_id` = `" . DB_PREFIX . DATABASE_USER_DATA . "`.`id`);"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_FEEDBACKS . "` WHERE `resource_id` != '' AND NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_RESOURCES . "` WHERE `id` = `" . DB_PREFIX . DATABASE_FEEDBACKS . "`.`resource_id`);"); } else { if ($_randStandard == 2) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_ALERTS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_ALERTS . "`.`receiver_user_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_FILES . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_CHAT_FILES . "`.`visitor_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_FORWARDS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` WHERE `chat_id` = `" . DB_PREFIX . DATABASE_CHAT_FORWARDS . "`.`chat_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_REQUESTS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_CHAT_REQUESTS . "`.`receiver_browser_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_STATS_AGGS_GOALS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_GOALS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_STATS_AGGS_GOALS . "`.`goal`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_STATS_AGGS_PAGES . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_DATA_PAGES . "` WHERE `id` = `" . DB_PREFIX . DATABASE_STATS_AGGS_PAGES . "`.`url`)"); DBManager::Execute(true, "DELETE `" . DB_PREFIX . DATABASE_TICKETS . "` FROM `" . DB_PREFIX . DATABASE_TICKETS . "` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`ticket_id` WHERE `deleted`=1 AND `time` < " . DBManager::RealEscape(time() - $_timeouts[3]) . ";"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKET_CUSTOMS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_TICKET_CUSTOMS . "`.`ticket_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKET_EDITORS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_TICKET_EDITORS . "`.`ticket_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKET_LOGS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_TICKET_LOGS . "`.`ticket_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKET_COMMENTS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_TICKET_COMMENTS . "`.`ticket_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`ticket_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKETS . "` WHERE `last_update` < " . DBManager::RealEscape(time() - $_timeouts[1]) . " AND NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` WHERE `ticket_id` = `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKET_ATTACHMENTS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` WHERE `id` = `" . DB_PREFIX . DATABASE_TICKET_ATTACHMENTS . "`.`parent_id`) AND NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_TICKET_EMAILS . "` WHERE `email_id` = `" . DB_PREFIX . DATABASE_TICKET_ATTACHMENTS . "`.`parent_id`)"); } else { if ($_randStandard == 3) { if (empty(Server::$Configuration->File["gl_vmac"]) && !Is::Defined("STATS_ACTIVE")) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `last_active`<" . (time() - Server::$Configuration->File["timeout_track"]) . " LIMIT 250;"); } DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "`.`visitor_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_VISITOR_BROWSER_URLS . "`.`browser_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "`.`visitor_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITOR_CHAT_OPERATORS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` WHERE `chat_id` = `" . DB_PREFIX . DATABASE_VISITOR_CHAT_OPERATORS . "`.`chat_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITOR_GOALS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_VISITOR_GOALS . "`.`visitor_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_WEBSITE_PUSHS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_WEBSITE_PUSHS . "`.`receiver_browser_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_OVERLAY_BOXES . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_OVERLAY_BOXES . "`.`receiver_browser_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_GROUP_MEMBERS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_GROUPS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_GROUP_MEMBERS . "`.`group_id`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_LOCALIZATIONS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` WHERE `id` = `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_LOCALIZATIONS . "`.`tid`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_VOUCHERS . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` WHERE `id` = `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_VOUCHERS . "`.`tid`)"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_TICKET_EMAILS . "` WHERE `deleted`=1 AND `edited` < " . DBManager::RealEscape(time() - $_timeouts[3])); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITOR_COMMENTS . "` WHERE `created` < " . DBManager::RealEscape(time() - max(1, Server::$Configuration->File["gl_colt"]) * 86400)); } else { if ($_randStandard == 4) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_RESOURCES . "` SET `discarded`=1,`edited`=UNIX_TIMESTAMP() WHERE NOT EXISTS(SELECT * FROM `" . DB_PREFIX . DATABASE_TICKET_ATTACHMENTS . "` WHERE `res_id` = `" . DB_PREFIX . DATABASE_RESOURCES . "`.`id`) AND `created` < " . intval(time() - 7 * 86400) . " AND `discarded`=0 AND `type`=3 AND `parentid`=100 LIMIT 10;"); if (Server::$Configuration->File["gl_adct"] != 1) { if (!empty(Server::$Configuration->File["gl_rm_chats"])) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=1 AND `time` < " . intval(time() - Server::$Configuration->File["gl_rm_chats_time"])); } if (!empty(Server::$Configuration->File["gl_rm_oc"])) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=0 AND `time` < " . intval(time() - Server::$Configuration->File["gl_rm_oc_time"])); } if (!empty(Server::$Configuration->File["gl_rm_gc"])) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=2 AND `time` < " . intval(time() - Server::$Configuration->File["gl_rm_gc_time"])); } if (!empty(Server::$Configuration->File["gl_rm_rt"])) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_FEEDBACKS . "` WHERE `created` < " . intval(time() - Server::$Configuration->File["gl_rm_rt_time"])); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_FEEDBACK_CRITERIA . "` WHERE NOT EXISTS (SELECT * FROM `" . DB_PREFIX . DATABASE_FEEDBACKS . "` WHERE `id` = `" . DB_PREFIX . DATABASE_FEEDBACK_CRITERIA . "`.`fid`)"); } if (!empty(Server::$Configuration->File["gl_rm_cf"])) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_RESOURCES . "` SET `discarded`=1,`edited`=UNIX_TIMESTAMP() WHERE `discarded`=0 AND `type`=4 AND `created` < " . intval(time() - Server::$Configuration->File["gl_rm_cf_time"]) . " ORDER BY `created` ASC LIMIT 5;"); if (!empty(Server::$Operators)) { foreach (Server::$Operators as $sid => $operator) { if (!$operator->IsBot) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_RESOURCES . "` SET `discarded`=1,`edited`=UNIX_TIMESTAMP() WHERE `discarded`=0 AND `type`=3 AND `parentid`='" . DBManager::RealEscape($sid) . "' AND `created` < " . intval(time() - Server::$Configuration->File["gl_rm_cf_time"]) . " ORDER BY `created` ASC LIMIT 5;"); } } } DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_RESOURCES . "` SET `discarded`=1,`edited`=UNIX_TIMESTAMP() WHERE `discarded`=0 AND `type`=0 AND `parentid`=5 AND `created` < " . intval(time() - Server::$Configuration->File["gl_rm_cf_time"]) . " ORDER BY `created` ASC LIMIT 5;"); } if (!empty(Server::$Configuration->File["gl_rm_tf"])) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_RESOURCES . "` SET `discarded`=1,`edited`=UNIX_TIMESTAMP() WHERE `discarded`=0 AND `type`=3 AND `created` < " . intval(time() - Server::$Configuration->File["gl_rm_tf_time"]) . " ORDER BY `created` ASC LIMIT 5;"); } if (!empty(Server::$Configuration->File["gl_rm_om"])) { DBManager::Execute(true, "DELETE `" . DB_PREFIX . DATABASE_TICKETS . "` FROM `" . DB_PREFIX . DATABASE_TICKETS . "` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`ticket_id` WHERE `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`time` < " . DBManager::RealEscape(time() - Server::$Configuration->File["gl_rm_om_time"])); } if (!empty(Server::$Configuration->File["gl_rm_tid"])) { DBManager::Execute(true, "DELETE `" . DB_PREFIX . DATABASE_TICKETS . "` FROM `" . DB_PREFIX . DATABASE_TICKETS . "` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`ticket_id` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_EDITORS . "` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`" . DB_PREFIX . DATABASE_TICKET_EDITORS . "`.`ticket_id` WHERE `" . DB_PREFIX . DATABASE_TICKET_EDITORS . "`.`status`=3 AND `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`time` < " . DBManager::RealEscape(time() - Server::$Configuration->File["gl_rm_tid_time"])); } if (!empty(Server::$Operators) && !empty(Server::$Configuration->File["gl_rm_bc"])) { foreach (Server::$Operators as $sid => $operator) { if ($operator->IsBot) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=1 AND `internal_id`='" . DBManager::RealEscape($sid) . "' AND `time` < " . DBManager::RealEscape(time() - Server::$Configuration->File["gl_rm_bc_time"])); } } } } if ($result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_RESOURCES . "` WHERE `discarded`=1 AND `type` > 2")) { while ($result && ($row = DBManager::FetchArray($result))) { $resultb = DBManager::Execute(true, "SELECT count(value) as `linked` FROM `" . DB_PREFIX . DATABASE_RESOURCES . "` WHERE `value`='" . DBManager::RealEscape($row["value"]) . "';"); $rowb = DBManager::FetchArray($resultb); if ($rowb["linked"] == 1) { @unlink(PATH_UPLOADS . $row["value"]); } } } DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_RESOURCES . "` WHERE `discarded`='1' AND `edited` < " . DBManager::RealEscape(time() - $_timeouts[3])); } } } } }
function Listen() { global $USER; $isOp = false; if ($USER->Browsers[0]->Status == CHAT_STATUS_ACTIVE) { $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_CHAT_OPERATORS . "` WHERE `chat_id`='" . DBManager::RealEscape($USER->Browsers[0]->ChatId) . "' ORDER BY `status` DESC, `dtime` DESC;"); while ($row = DBManager::FetchArray($result)) { if (isset(Server::$Operators[$row["user_id"]])) { $ChatMember = new ChatMember($row["user_id"], $row["status"], !empty($row["declined"]), $row["jtime"], $row["ltime"]); if ($ChatMember->Status == 1 && $ChatMember->Joined >= $USER->Browsers[0]->LastActive) { $isOp = true; $this->AddHTML(str_replace("<!--message-->", str_replace("<!--intern_name-->", Server::$Operators[$ChatMember->SystemId]->Fullname, LocalizationManager::$TranslationStrings["client_intern_arrives"]), IOStruct::GetFile(TEMPLATE_HTML_MESSAGE_OVERLAY_CHAT_STATUS)), "sys", "LMMJ" . $ChatMember->SystemId); } else { if (($ChatMember->Status == 9 || $ChatMember->Status == 2) && $ChatMember->Left >= $USER->Browsers[0]->LastActive && $ChatMember->Joined > 0) { $this->AddHTML($this->GetLeaveChatHTML(false, Server::$Operators[$ChatMember->SystemId]->Fullname), "sys", "LCM01" . $ChatMember->SystemId); } } if ($ChatMember->Status == 0) { $isOp = true; } } } } else { $isOp = true; } if (Communication::ReadParameter("ovlif")) { $this->InitFeedback(); } $USER->Browsers[0]->Typing = isset($_GET["typ"]); if (!$USER->Browsers[0]->Declined) { $USER->Browsers[0]->Save(); } $USER->Browsers[0]->ValidateOperator(); $this->CurrentOperatorId = Communication::GetParameter("op", "", $c, FILTER_SANITIZE_SPECIAL_CHARS, null, 32); if ($USER->Browsers[0]->Waiting && $this->Botmode || empty($USER->Browsers[0]->OperatorId) && !empty($this->CurrentOperatorId) && isset(Server::$Operators[$this->CurrentOperatorId]) && !Server::$Operators[$this->CurrentOperatorId]->IsBot || !empty($this->CurrentOperatorId) && empty($USER->Browsers[0]->ChatId) && !$this->Botmode || !$isOp || $USER->Browsers[0]->Closed) { if (!$USER->Browsers[0]->ExternalClosed) { $USER->Browsers[0]->ExternalClose(); $USER->Browsers[0]->Save(); $USER->Browsers[0]->Load(); } $USER->Browsers[0]->Members = array(); if (!empty($this->CurrentOperatorId) && !empty(Server::$Operators[$this->CurrentOperatorId]) && $isOp) { $this->AddHTML($this->GetLeaveChatHTML(true, Server::$Operators[$this->CurrentOperatorId]->Fullname), "sys", "LCM01" . $this->CurrentOperatorId); if (!empty(Server::$Configuration->File["gl_fboe"]) && Communication::ReadParameter("po", 0) == 0 && !Server::$Operators[$this->CurrentOperatorId]->IsBot) { if (!empty(Server::$Groups[$USER->Browsers[0]->DesiredChatGroup]->ChatFunctions[3])) { $this->InitFeedback(false); } } $this->Flags["LMR"] = "null"; $USER->Browsers[0]->OperatorId = null; $this->CurrentOperatorId = ""; $this->RepollRequired = true; } } }
static function UpdateConfiguration($id = 0) { if (OperatorRequest::IsValidated() && Is::Defined("VALIDATED_FULL_LOGIN") && OperatorRequest::IsAdministrator(true)) { Logging::SecurityLog("ServerManager::UpdateConfiguration", "", CALLER_SYSTEM_ID); if (Is::Defined("STATS_ACTIVE") && !empty($_POST["p_reset_stats"])) { Server::$Statistic->ResetAll(); } $int = 0; if (DB_CONNECTION) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` SET `delete`='1';"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_LOCALIZATIONS . "`;"); while (!empty($_POST["p_cfg_cct_id_" . $int])) { $cct = new CommercialChatBillingType($_POST["p_cfg_cct_id_" . $int], $_POST["p_cfg_cct_mnoc_" . $int], $_POST["p_cfg_cct_mtloc_" . $int], $_POST["p_cfg_cct_tae_" . $int], $_POST["p_cfg_cct_tvbo_" . $int], $_POST["p_cfg_cct_svbo_" . $int], $_POST["p_cfg_cct_evbo_" . $int], $_POST["p_cfg_cct_citl_" . $int], $_POST["p_cfg_cct_p_" . $int]); $cct->Save(); $iint = 0; while (!empty($_POST["p_cfg_cctli_id_" . $int . "_" . $iint])) { $cctl = new CommercialChatVoucherLocalization($_POST["p_cfg_cctli_id_" . $int . "_" . $iint], $_POST["p_cfg_cctli_itl_" . $int . "_" . $iint], $_POST["p_cfg_cctli_t_" . $int . "_" . $iint], $_POST["p_cfg_cctli_d_" . $int . "_" . $iint], $_POST["p_cfg_cctli_terms_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvc_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvp_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvu_" . $int . "_" . $iint], $_POST["p_cfg_cctli_exr_" . $int . "_" . $iint]); $cctl->Save($_POST["p_cfg_cct_id_" . $int]); $iint++; } $int++; } $int = 0; DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_PROVIDERS . "`;"); while (!empty($_POST["p_cfg_ccpp_id_" . $int])) { $ccpp = new CommercialChatPaymentProvider($_POST["p_cfg_ccpp_id_" . $int], $_POST["p_cfg_ccpp_n_" . $int], $_POST["p_cfg_ccpp_a_" . $int], $_POST["p_cfg_ccpp_u_" . $int], $_POST["p_cfg_ccpp_l_" . $int]); $ccpp->Save(); $int++; } $int = 0; DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_MAILBOXES . "`;"); while (!empty($_POST["p_cfg_es_i_" . $int])) { $acc = new Mailbox($int, true); $acc->Save(); $int++; } $int = 0; DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_FEEDBACK_CRITERIA_CONFIG . "`;"); while (isset($_POST["p_cfg_fc_i_" . $int])) { $fc = new FeedbackCriteria($int, true); $fc->Save(); $int++; } DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` WHERE `delete`='1';"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CONFIG . "`;"); foreach ($_POST as $key => $value) { if (strpos($key, "p_cfg_g_") === 0) { $skey = str_replace("p_cfg_g_", "", $key); $value = base64_decode($value); DBManager::Execute(true, "REPLACE INTO `" . DB_PREFIX . DATABASE_CONFIG . "` (`key`,`value`) VALUES ('" . DBManager::RealEscape($skey) . "','" . DBManager::RealEscape($value) . "');"); } } CacheManager::Flush(); } if (isset($_POST["p_available"])) { ServerManager::UpdateAvailability(!empty($_POST["p_available"])); } //$id = IOStruct::CreateFile($file,base64_decode($_POST["p_upload_value"]),true); } GeoTracking::SpanRemove(true); CacheManager::Flush(); Server::$Response->SetStandardResponse($id, ""); }
function getChatVoucherTemplate($html = "") { global $CONFIG, $COUNTRIES, $LZLANG; if (!is("DB_CONNECTION") || !empty($CONFIG["db"]["ccpp"]["Custom"])) { return ""; } if (!empty($CONFIG["gl_ccac"])) { foreach ($CONFIG["db"]["cct"] as $type) { $html .= $type->GetTemplate(); } } $cchtml = getFile(PATH_TEMPLATES . "chat_voucher_checkout.tpl"); $mycountry = ""; $replacements = array("<!--lp_company-->" => "", "<!--lp_firstname-->" => "", "<!--lp_email-->" => "", "<!--lp_lastname-->" => "", "<!--lp_taxid-->" => "", "<!--lp_business_type-->" => "", "<!--lp_address_1-->" => "", "<!--lp_address_2-->" => "", "<!--lp_city-->" => "", "<!--lp_state-->" => "", "<!--lp_country-->" => "", "<!--lp_phone-->" => "", "<!--lp_zip-->" => ""); $prefillco = !empty($_GET["co"]) ? " OR id='" . DBManager::RealEscape(base64URLDecode($_GET["co"])) . "'" : ""; if (!isnull(getCookieValue("userid")) || !empty($prefillco)) { $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_VOUCHERS . "` WHERE `visitor_id`='" . DBManager::RealEscape(getCookieValue("userid")) . "'" . $prefillco . " ORDER BY `created` DESC LIMIT 1;"); if ($result) { if ($row = DBManager::FetchArray($result)) { $replacements = array("<!--lp_company-->" => $row["company"], "<!--lp_firstname-->" => $row["firstname"], "<!--lp_lastname-->" => $row["lastname"], "<!--lp_taxid-->" => $row["tax_id"], "<!--lp_email-->" => $row["email"], "<!--lp_business_type-->" => $row["business_type"], "<!--lp_address_1-->" => $row["address_1"], "<!--lp_address_2-->" => $row["address_2"], "<!--lp_city-->" => $row["city"], "<!--lp_state-->" => $row["state"], "<!--lp_country-->" => $row["country"], "<!--lp_phone-->" => $row["phone"], "<!--lp_zip-->" => $row["zip"]); $mycountry = $row["country"]; } } } $clist = $COUNTRIES; asort($clist); $countrieshtml = ""; foreach ($clist as $isokey => $value) { if (!empty($isokey)) { $countrieshtml .= $isokey == $mycountry ? "<option value=\"" . $isokey . "\" SELECTED>" . utf8_encode($value) . "</option>" : "<option value=\"" . $isokey . "\">" . utf8_encode($value) . "</option>"; } } $cchtml = str_replace("<!--countries-->", $countrieshtml, $cchtml); foreach ($replacements as $key => $value) { $cchtml = str_replace($key, $value, $cchtml); } $cchtml = str_replace("<!--show_VAT-->", !empty($CONFIG["gl_ccsv"]) ? "''" : "none", $cchtml); $cchtml = str_replace("<!--voucher_form-->", $html, $cchtml); if (!empty($CONFIG["db"]["ccpp"]["PayPal"]->LogoURL)) { $cchtml = str_replace("<!--pp_logo_url-->", " src=\"" . $CONFIG["db"]["ccpp"]["PayPal"]->LogoURL . "\"", $cchtml); } else { $cchtml = str_replace("<!--pp_logo_url-->", "", $cchtml); } $cchtml = str_replace("<!--extends_voucher-->", !empty($_GET["co"]) && strlen(base64UrlDecode($_GET["co"])) == 16 ? base64UrlDecode($_GET["co"]) : "", $cchtml); $cchtml = str_replace("<!--ofc-->", !empty($_GET["ofc"]) ? "MQ__" : "", $cchtml); $cchtml = str_replace("<!--VAT-->", str_replace("<!--VAT-->", $CONFIG["gl_ccva"], $LZLANG["client_voucher_include_vat"]), $cchtml); return $cchtml; }
function InitConnection() { if (DBManager::$Extension == "mysql") { DBManager::$Provider = @mysql_connect($this->Host, $this->Username, $this->Password); } else { if (DBManager::$Extension == "mysqli") { DBManager::$Provider = @mysqli_connect($this->Host, $this->Username, $this->Password); } } if (DBManager::$Provider && !empty($this->Database)) { $this->Query(false, "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"); if ($this->SelectDatabase(DBManager::RealEscape($this->Database))) { DBManager::$Connected = true; } } return DBManager::$Connected; }
function testDataBase($_host, $_user, $_pass, $_dbname, $_prefix, $_extension = "", $_intense = false) { global $DB_CONNECTOR; $connection = new DBManager($_user, $_pass, $_host, "", $_prefix); if (!empty($_extension)) { DBManager::$Extension = $_extension; } if (DBManager::$Extension == "mysql" && !function_exists("mysql_connect")) { return "PHP MySQL extension is missing (php_mysql.dll)"; } else { if (DBManager::$Extension == "mysqli" && !function_exists("mysqli_connect")) { return "PHP/MySQLi extension is missing (php_mysqli.dll)"; } } $connection->InitConnection(); $connection->Query(false, "SET NAMES 'utf8'"); if (!DBManager::$Provider) { $error = DBManager::GetError(); return "Can't connect to database. Invalid host or login! (" . DBManager::GetErrorCode() . (!empty($error) ? ": " . $error : "") . ")"; } else { $db_selected = $connection->SelectDatabase(DBManager::RealEscape($_dbname)); if (!$db_selected) { return DBManager::GetErrorCode() . ": " . DBManager::GetError(); } else { $resultv = $connection->Query(false, "SELECT VERSION() as `mysql_version`"); if (!$resultv) { return DBManager::GetErrorCode() . ": " . DBManager::GetError(); } else { $mrow = @DBManager::FetchArray($resultv); $mversion = explode(".", $mrow["mysql_version"]); if (count($mversion) > 0 && $mversion[0] < MYSQL_NEEDED_MAJOR) { return "LiveZilla requires MySQL version " . MYSQL_NEEDED_MAJOR . " or greater. The MySQL version installed on your server is " . $mrow["mysql_version"] . "."; } } $result = $connection->Query(false, "SELECT `version`,`chat_id`,`ticket_id` FROM `" . DBManager::RealEscape($_prefix) . DATABASE_INFO . "` ORDER BY `version` DESC LIMIT 1"); $row = @DBManager::FetchArray($result); $version = $row["version"]; if (!$result || empty($version)) { return "Cannot read the LiveZilla Database version. Please try to recreate the table structure. If you experience this message during installation process, please try to setup a prefix (for example lz_)."; } if ($version != VERSION && defined("SERVERSETUP") && SERVERSETUP) { $upres = initUpdateDatabase($version, $connection, $_prefix); if ($upres !== true) { return "Cannot update database structure from [" . $version . "] to [" . VERSION . "]. Please make sure that the user " . $_user . " has the MySQL permission to ALTER tables in " . $_dbname . ".\r\n\r\nError: " . $upres; } } else { if ($version != VERSION && empty($_GET["iv"])) { return "Invalid database version: " . $version . " (required: " . VERSION . "). Please validate the database in the server administration panel first.\r\n\r\n"; } } $DB_CONNECTOR = $connection; $result = $connection->Query(false, "SELECT * FROM `" . DBManager::RealEscape($_prefix) . DATABASE_OPERATORS . "`"); if (DBManager::GetRowCount($result) == 0) { setManagement($_prefix, false, true); } if ($_intense && empty($_GET["iv"])) { foreach (get_defined_constants() as $constant => $val) { if (substr($constant, 0, 9) == "DATABASE_") { if (!$connection->Query(false, "SELECT * FROM `" . DBManager::RealEscape($_prefix) . $val . "` LIMIT 1;")) { $code = DBManager::GetErrorCode(); $error = DBManager::GetError(); if ($code == 144 || $code == 145 || $code == 1194) { $connection->Query(true, "REPAIR TABLE `" . DBManager::RealEscape($_prefix) . $val . "`;"); $error .= " - (trying to repair ...)"; } return $code . ": " . $error; } } } } return null; } } }
function KnowledgebaseEntriesList() { $sql_limit = ""; if (!empty($_POST["p_limit"])) { if (is_int($_POST["p_limit"])) { $sql_limit = " LIMIT " . intval($_POST["p_limit"]); } else { $this->ErrorFilter = "Limit"; return; } if (!empty($_POST["p_offset"])) { if (is_int($_POST["p_offset"])) { $sql_limit .= " OFFSET " . intval($_POST["p_offset"]); } else { $this->ErrorFilter = "Offset"; exit("dsf"); return; } } } $sql_where = "WHERE `discarded`=0 AND `parentid`<>100"; if (!empty($_POST["p_id"])) { $sql_where .= " AND `id`='" . DBManager::RealEscape($_POST["p_id"]) . "'"; } if (empty($_POST["p_show_private"])) { $sql_where .= " AND `kb_public`=1"; } $results = array("KnowledgeBaseEntries" => array()); $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_RESOURCES . "` " . $sql_where . " ORDER BY `title` ASC " . $sql_limit . ";"); while ($row = DBManager::FetchArray($result)) { $kbe = new KnowledgeBaseEntry($row); $results["KnowledgeBaseEntries"][] = array("KnowledgeBaseEntry" => ApiV2::ClearObject(ApiV2::GetObjectFields("KnowledgeBaseEntry"), $kbe)); } $this->JSONOutput = APIV2::Encode($results, $this->JSONParams); }
$USER->Browsers[1]->ChatRequest->SetStatus(true, true, false, true); $USER->Browsers[1]->ForceUpdate(); } } } $tymes = !empty($USER->Browsers[0]->InternalUser) && $USER->Browsers[0]->InternalUser->Typing == $USER->Browsers[0]->SystemId ? "'" . base64_encode(str_replace("<!--operator_name-->", $USER->Browsers[0]->InternalUser->Fullname, $LZLANG["client_representative_is_typing"])) . "'" : "null"; $USER->AddFunctionCall("lz_chat_set_typing(" . $tymes . ",false);", false); $maxposts = 30; $spkthtml = speakingToHTML(); $posthtml = ""; $pstrchngreq = $psound = $spkt = false; $oppostcount = 0; $LASTPOST = ""; $lppflag = $LASTPOSTER; $rand = rand(); if (!$USER->Browsers[0]->Declined && ($result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `chat_id`='" . DBManager::RealEscape($USER->Browsers[0]->ChatId) . "' AND `chat_id`!='' AND `chat_id`!='0' AND (`receiver`='" . DBManager::RealEscape($USER->Browsers[0]->SystemId) . "' OR (`sender`='" . DBManager::RealEscape($USER->Browsers[0]->SystemId) . "' AND `repost`=0)) GROUP BY `id` ORDER BY `time` ASC, `micro` ASC;"))) { $all = DBManager::GetRowCount($result); $toshow = min($maxposts, $all); if ($all > 0) { $count = $maxposts - $all; while ($row = DBManager::FetchArray($result)) { if ($count++ >= 0) { $postobj = new Post($row); if (empty($INTERNAL[$postobj->Sender])) { $postobj->Text = htmlentities($postobj->Text, ENT_QUOTES, 'UTF-8'); $postobj->Translation = htmlentities($postobj->Translation, ENT_QUOTES, 'UTF-8'); } if ($USER->Browsers[0]->AllocatedTime > 0 && $USER->Browsers[0]->AllocatedTime && !$spkt) { $lppflag = "sys"; $posthtml .= $spkthtml; $spkt = true;
function TicketsList() { $sql_limit = ""; if (!empty($_POST["p_limit"])) { if (is_numeric($_POST["p_limit"])) { $sql_limit = " LIMIT " . $_POST["p_limit"]; } else { $this->ErrorFilter = "Limit"; return; } } $sql_where = "WHERE `t1`.`id`>0 "; if (!empty($_POST["p_id"])) { $sql_where .= " AND `t1`.`id`='" . DBManager::RealEscape($_POST["p_id"]) . "'"; } else { if (!empty($_POST["p_group"])) { $sql_where .= " AND `group_id`='" . DBManager::RealEscape($_POST["p_group"]) . "'"; } if (!empty($_POST["p_operator"])) { $opsid = Operator::GetSystemId($_POST["p_operator"]); if ($opsid != null) { $sql_where .= " AND `internal_id`='" . DBManager::RealEscape($opsid) . "'"; } else { $this->ErrorFilter = "Operator"; return; } } if (!empty($_POST["p_created_after"])) { if (is_numeric($_POST["p_created_after"]) && !empty($_POST["p_created_after"])) { $sql_where .= " AND `time` > " . $_POST["p_created_after"]; } else { $this->ErrorFilter = "Created After"; return; } } if (!empty($_POST["p_created_before"])) { if (is_numeric($_POST["p_created_before"]) && !empty($_POST["p_created_before"])) { $sql_where .= " AND `time` < " . $_POST["p_created_before"]; } else { $this->ErrorFilter = "Created Before"; return; } } } $results = array("Tickets" => array()); $result = queryDB(true, $d = "SELECT * FROM `" . DB_PREFIX . DATABASE_TICKETS . "` as `t1` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` as `t2` ON `t1`.`id`=`t2`.`id` " . $sql_where . " ORDER BY `t1`.`id` ASC " . $sql_limit . ";"); while ($row = DBManager::FetchArray($result)) { $ticket = new Ticket($row, true, true); $results["Tickets"][] = array("Ticket" => ApiV2::ClearObject(ApiV2::GetObjectFields("Ticket"), $ticket)); } $this->JSONOutput = APIV2::Encode($results, $this->JSONParams); }
function CleanDatabases($_days) { queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `last_active`<" . (time() - $_days * 86400) . ";"); queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_OPERATOR_STATUS . "` WHERE `" . DB_PREFIX . DATABASE_OPERATOR_STATUS . "`.`confirmed`<" . DBManager::RealEscape(time() - $_days * 86400) . ";"); }
function GetQueuePosition($_targetGroup, $_startTime = 0, $_position = 1) { global $USER; $USER->Browsers[0]->SetStatus(CHAT_STATUS_OPEN); DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` SET `qpenalty`=`qpenalty`+60 WHERE `last_active`>" . (time() - Server::$Configuration->File["timeout_chats"]) . " AND `status`=0 AND `exit`=0 AND `last_active`<" . DBManager::RealEscape(time() - max(20, Server::$Configuration->File["poll_frequency_clients"] * 2))); $result = DBManager::Execute(true, "SELECT `priority`,`request_operator`,`request_group`,`chat_id`,`first_active`,`qpenalty`+`first_active` as `sfirst` FROM `" . DB_PREFIX . DATABASE_VISITOR_CHATS . "` WHERE `status`='0' AND `exit`='0' AND `chat_id`>0 AND `last_active`>" . (time() - Server::$Configuration->File["timeout_chats"]) . " ORDER BY `priority` DESC,`sfirst` ASC;"); if ($result) { while ($row = DBManager::FetchArray($result)) { if ($row["chat_id"] == $USER->Browsers[0]->ChatId) { $_startTime = $row["sfirst"]; break; } else { if ($row["request_group"] == $_targetGroup && $row["request_operator"] == $USER->Browsers[0]->DesiredChatPartner) { $_position++; } else { if ($row["request_group"] == $_targetGroup && ($row["request_operator"] != $USER->Browsers[0]->DesiredChatPartner && empty($row["request_operator"]))) { $_position++; } else { if (!empty($USER->Browsers[0]->DesiredChatPartner) && $USER->Browsers[0]->DesiredChatPartner == $row["request_operator"]) { $_position++; } } } } } } define("CHAT_START_TIME", $_startTime); return $_position; }
function buildTickets($xml = "", $dle_xml = "", $ticketCount = 0, $itemCount = 0) { global $RESPONSE, $INTERNAL, $DUT; if (empty($_POST[POST_INTERN_XMLCLIP_TICKETS_END_TIME])) { return; } if (!isDataUpdate(POST_INTERN_DUT_TICKETS, DATA_UPDATE_KEY_TICKETS) && !isDataUpdate(POST_INTERN_DUT_EMAILS, DATA_UPDATE_KEY_EMAILS)) { return; } initData(array("INPUTS")); $permission = $INTERNAL[CALLER_SYSTEM_ID]->GetPermission(PERMISSION_MESSAGES); if ($_POST[POST_INTERN_XMLCLIP_TICKETS_END_TIME] == XML_CLIP_NULL || !is_numeric($_POST[POST_INTERN_XMLCLIP_TICKETS_END_TIME])) { $_POST[POST_INTERN_XMLCLIP_TICKETS_END_TIME] = 0; } if ($_POST[POST_INTERN_XMLCLIP_TICKETS_STATUS_END_TIME] == XML_CLIP_NULL || !is_numeric($_POST[POST_INTERN_XMLCLIP_TICKETS_STATUS_END_TIME])) { $_POST[POST_INTERN_XMLCLIP_TICKETS_STATUS_END_TIME] = 0; } if ($_POST[POST_INTERN_XMLCLIP_EMAILS_END_TIME] == XML_CLIP_NULL || !is_numeric($_POST[POST_INTERN_XMLCLIP_EMAILS_END_TIME])) { $_POST[POST_INTERN_XMLCLIP_EMAILS_END_TIME] = 0; } if ($_POST[POST_INTERN_XMLCLIP_TICKETS_LOG_END_TIME] == XML_CLIP_NULL || !is_numeric($_POST[POST_INTERN_XMLCLIP_TICKETS_LOG_END_TIME])) { $_POST[POST_INTERN_XMLCLIP_TICKETS_LOG_END_TIME] = 0; } if ($_POST[POST_INTERN_XMLCLIP_TICKETS_COMMENTS_END_TIME] == XML_CLIP_NULL || !is_numeric($_POST[POST_INTERN_XMLCLIP_TICKETS_COMMENTS_END_TIME])) { $_POST[POST_INTERN_XMLCLIP_TICKETS_COMMENTS_END_TIME] = 0; } $queries["messages"] = "FROM `" . DB_PREFIX . DATABASE_TICKETS . "` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`ticket_id` WHERE `time` >" . DBManager::RealEscape($_POST[POST_INTERN_XMLCLIP_TICKETS_END_TIME]) . " ORDER BY `time` ASC"; $queries["mails"] = "FROM `" . DB_PREFIX . DATABASE_TICKET_EMAILS . "` AS `t1` INNER JOIN `" . DB_PREFIX . DATABASE_MAILBOXES . "` AS `t2` ON `t1`.`mailbox_id`=`t2`.`id` WHERE `edited` >" . DBManager::RealEscape($_POST[POST_INTERN_XMLCLIP_EMAILS_END_TIME]) . " ORDER BY `edited` ASC"; $queries["status"] = "FROM `" . DB_PREFIX . DATABASE_TICKETS . "` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_EDITORS . "` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`" . DB_PREFIX . DATABASE_TICKET_EDITORS . "`.`ticket_id` WHERE `time` >" . DBManager::RealEscape($_POST[POST_INTERN_XMLCLIP_TICKETS_STATUS_END_TIME]) . " ORDER BY `time` ASC;"; $queries["log"] = "FROM `" . DB_PREFIX . DATABASE_TICKET_LOGS . "` WHERE `time` >" . DBManager::RealEscape($_POST[POST_INTERN_XMLCLIP_TICKETS_LOG_END_TIME]) . " ORDER BY `time` ASC;"; $queries["comments"] = "FROM `" . DB_PREFIX . DATABASE_TICKET_COMMENTS . "` WHERE `time` >" . DBManager::RealEscape($_POST[POST_INTERN_XMLCLIP_TICKETS_COMMENTS_END_TIME]) . " ORDER BY `time` ASC;"; $result = queryDB(true, "SELECT * " . $queries["messages"] . " LIMIT " . DBManager::RealEscape(DATA_ITEM_LOADS) . ";"); if ($result) { while ($row = DBManager::FetchArray($result)) { $ticket = new Ticket($row); $full = in_array($ticket->Group, $INTERNAL[CALLER_SYSTEM_ID]->Groups) && $permission != PERMISSION_NONE || $permission == PERMISSION_FULL; if ($full) { $ticket->Messages[0]->LoadCustoms(); $ticket->Messages[0]->LoadAttachments(); } $xml .= $ticket->GetXML($full); $itemCount++; $ticketCount++; } } if ($ticketCount != DATA_ITEM_LOADS) { $mailcount = $last = 0; $result = queryDB(true, "SELECT `t1`.*,`t2`.`email` AS `receiver_mail` " . $queries["mails"] . " LIMIT " . DBManager::RealEscape(DATA_ITEM_LOADS * 5) . ";"); if ($result) { while ($row = DBManager::FetchArray($result)) { $permissione = $INTERNAL[CALLER_SYSTEM_ID]->GetPermission(22); $full = $permissione != PERMISSION_NONE && (in_array($row["group_id"], $INTERNAL[CALLER_SYSTEM_ID]->Groups) && $permission != PERMISSION_NONE || $permission == PERMISSION_FULL); $email = new TicketEmail($row); $email->LoadAttachments(); $xml .= $email->GetXML($full); $itemCount++; if ($last != $row["edited"] && ++$mailcount >= DATA_ITEM_LOADS) { break; } $last = $row["edited"]; } } $statuscount = $last = 0; $result = queryDB(true, "SELECT * " . $queries["status"]); if ($result) { while ($row = DBManager::FetchArray($result)) { if ($statuscount++ >= DATA_ITEM_LOADS && $last != $row["time"]) { break; } $ticket = new TicketEditor($row["ticket_id"], $row); $xml .= $ticket->GetXML(@$row["wait_begin"], @$row["last_update"]); $itemCount++; $last = $row["time"]; } } $logcount = $last = 0; $result = queryDB(true, "SELECT * " . $queries["log"]); if ($result) { while ($row = DBManager::FetchArray($result)) { if ($logcount++ >= DATA_ITEM_LOADS && $last != $row["time"]) { break; } $xml .= "<lo c=\"" . base64_encode($row["created"]) . "\" ti=\"" . base64_encode($row["time"]) . "\" t=\"" . base64_encode($row["ticket_id"]) . "\" a=\"" . base64_encode($row["action"]) . "\" o=\"" . base64_encode($row["operator_id"]) . "\" v=\"" . base64_encode($row["value_old"]) . "\">" . base64_encode($row["value_new"]) . "</lo>\r\n"; $last = $row["time"]; $itemCount++; } } $commentscount = $last = 0; $result = queryDB(true, "SELECT * " . $queries["comments"]); if ($result) { while ($row = DBManager::FetchArray($result)) { if ($commentscount++ >= DATA_ITEM_LOADS && $last != $row["time"]) { break; } $xml .= "<c i=\"" . base64_encode($row["id"]) . "\" c=\"" . base64_encode($row["created"]) . "\" ti=\"" . base64_encode($row["time"]) . "\" t=\"" . base64_encode($row["ticket_id"]) . "\" m=\"" . base64_encode($row["message_id"]) . "\" o=\"" . base64_encode($row["operator_id"]) . "\">" . base64_encode($row["comment"]) . "</c>\r\n"; $last = $row["time"]; $itemCount++; } } } $count = 0; foreach ($queries as $query) { if ($result = queryDB(true, "SELECT count(*) as `total` " . $query)) { while ($row = DBManager::FetchArray($result)) { if (!empty($row["total"])) { $count += $row["total"]; } } } } if (!empty($count)) { $DUT[DATA_UPDATE_KEY_TICKETS] = 0; $xml = "<l l=\"" . base64_encode($count) . "\">" . base64_encode($itemCount) . "</l>\r\n" . $xml; } $RESPONSE->Messages = "<t dutt=\"" . base64_encode($DUT[DATA_UPDATE_KEY_TICKETS]) . "\" dute=\"" . base64_encode($DUT[DATA_UPDATE_KEY_EMAILS]) . "\">\r\n" . $xml . $dle_xml . "</t>"; }
function GetUniqueMessageTime($_database, $_column) { $time = time(); while (true) { $result = queryDB(true, "SELECT `" . $_column . "` FROM `" . DB_PREFIX . $_database . "` WHERE `" . $_column . "`=" . DBManager::RealEscape($time) . ";"); if (DBManager::GetRowCount($result) > 0) { $time++; } else { break; } } return $time; }
static function FromSystemId($_systemId) { $d = new UserData(); $browserid = explode("~", $_systemId); $browserid = $browserid[1]; $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` AS `tb` INNER JOIN `" . DB_PREFIX . DATABASE_USER_DATA . "` AS `td` ON `tb`.`data_id`=`td`.`id` WHERE `tb`.`id`='" . DBManager::RealEscape($browserid) . "' LIMIT 1;"); if ($result) { if ($row = DBManager::FetchArray($result)) { $d->SetDetails($row); } } return $d; }
function DeleteGroup($_groupId) { queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_GROUPS . "` WHERE `id`='" . DBManager::RealEscape($_groupId) . "' LIMIT 1;"); queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_PREDEFINED . "` WHERE `group_id`='" . DBManager::RealEscape($_groupId) . "';"); }
function getFileById($_id, $_online, $_type) { $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_IMAGES . "` WHERE `id`='" . DBManager::RealEscape($_id) . "' AND `button_type`='" . DBManager::RealEscape($_type) . "' AND `online`='" . DBManager::RealEscape($_online ? "1" : "0") . "' LIMIT 1;"); if ($row = DBManager::FetchArray($result)) { header("Content-Type: image/" . $row["image_type"] . ";"); return base64_decode($row["data"]); } else { header("Content-Type: image/gif;"); return file_get_contents(PATH_IMAGES . "chat_blank.gif"); } }
function CleanDatabases($_days) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_VISITORS . "` WHERE `entrance`<" . (time() - max(1, $_days) * 86400) . ";"); DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_OPERATOR_STATUS . "` WHERE `" . DB_PREFIX . DATABASE_OPERATOR_STATUS . "`.`confirmed`<" . DBManager::RealEscape(time() - max(1, $_days) * 86400) . ";"); }
function up_3186_3200($_prefix, $_link) { $commands = array(); $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "alerts` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `created` int(10) unsigned NOT NULL DEFAULT '0', `receiver_user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_browser_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `event_action_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `text` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `displayed` tinyint(1) unsigned NOT NULL DEFAULT '0', `accepted` tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "predefined` ADD `invitation_auto` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL AFTER `invitation`"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "predefined` CHANGE `invitation` `invitation_manual` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "predefined` CHANGE `website_push` `website_push_manual` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "predefined` ADD `website_push_auto` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL AFTER `website_push_manual`"; $commands[] = "UPDATE `" . DBManager::RealEscape($_prefix) . "predefined` SET `invitation_auto`=`invitation_manual`"; $commands[] = "UPDATE `" . DBManager::RealEscape($_prefix) . "predefined` SET `website_push_auto`=`website_push_manual`"; $commands[] = "RENAME TABLE `" . DBManager::RealEscape($_prefix) . "rooms` TO `" . DBManager::RealEscape($_prefix) . "chat_rooms`;"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "chat_rooms` ADD `creator` varchar(32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ''"; $commands[] = "RENAME TABLE `" . DBManager::RealEscape($_prefix) . "posts` TO `" . DBManager::RealEscape($_prefix) . "chat_posts`;"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "chat_posts` ADD `chat_id` varchar(32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `id` "; $commands[] = "RENAME TABLE `" . DBManager::RealEscape($_prefix) . "res` TO `" . DBManager::RealEscape($_prefix) . "resources`;"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "chats` ADD `group_id` varchar(32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `internal_id`"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "logins` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',`user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',`ip` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',`time` int(11) unsigned NOT NULL DEFAULT '0', `password` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "chat_requests` ( `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `created` int(10) unsigned NOT NULL DEFAULT '0', `sender_system_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `sender_group_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_browser_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `event_action_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `text` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `displayed` tinyint(1) unsigned NOT NULL DEFAULT '0', `accepted` tinyint(1) unsigned NOT NULL DEFAULT '0', `declined` tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "events` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',`name` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',`created` int(10) unsigned NOT NULL DEFAULT '0', `creator` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `edited` int(10) unsigned NOT NULL DEFAULT '0', `editor` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `pages_visited` int(10) unsigned NOT NULL DEFAULT '0', `time_on_site` int(10) unsigned NOT NULL DEFAULT '0', `max_trigger_amount` int(10) unsigned NOT NULL DEFAULT '0', `trigger_again_after` int(10) unsigned NOT NULL DEFAULT '0', `not_declined` tinyint(1) unsigned NOT NULL DEFAULT '0', `not_accepted` tinyint(1) unsigned NOT NULL DEFAULT '0', `not_in_chat` tinyint(1) unsigned NOT NULL DEFAULT '0', `priority` int(10) unsigned NOT NULL DEFAULT '0', `is_active` tinyint(1) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_actions` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `eid` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `type` tinyint(2) unsigned NOT NULL DEFAULT '0', `value` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_action_internals` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',`created` int(10) unsigned NOT NULL DEFAULT '0',`trigger_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',`receiver_user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_action_invitations` ( `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `action_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `position` varchar(2) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `speed` tinyint(1) NOT NULL DEFAULT '1', `slide` tinyint(1) NOT NULL DEFAULT '1', `margin_left` int(11) NOT NULL DEFAULT '0', `margin_top` int(11) NOT NULL DEFAULT '0', `margin_right` int(11) NOT NULL DEFAULT '0', `margin_bottom` int(11) NOT NULL DEFAULT '0', `style` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `close_on_click` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_action_receivers` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `action_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_action_senders` ( `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `group_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `priority` tinyint(2) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_action_website_pushs` ( `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `action_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `target_url` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `ask` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_triggers` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_browser_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `action_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `time` int(10) unsigned NOT NULL DEFAULT '0', `triggered` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "event_urls` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `eid` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `url` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `referrer` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `time_on_site` int(10) unsigned NOT NULL DEFAULT '0', `blacklist` tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "website_pushs` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `created` int(10) unsigned NOT NULL DEFAULT '0', `sender_system_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `receiver_browser_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `text` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `ask` tinyint(1) unsigned NOT NULL DEFAULT '0', `target_url` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `displayed` tinyint(1) unsigned NOT NULL DEFAULT '0', `accepted` tinyint(1) unsigned NOT NULL DEFAULT '0', `declined` tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "predefined` ADD `editable` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"; $commands[] = "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "chats` ADD `area_code` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `group_id`;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "profiles` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `edited` int(11) NOT NULL DEFAULT '0', `first_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `last_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `company` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `fax` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `street` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `zip` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `department` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `city` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `country` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `gender` tinyint(1) NOT NULL DEFAULT '0', `languages` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `comments` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `public` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $commands[] = "CREATE TABLE `" . DBManager::RealEscape($_prefix) . "profile_pictures` (`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `internal_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `time` int(11) NOT NULL DEFAULT '0', `webcam` tinyint(1) NOT NULL DEFAULT '0', `data` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;"; $allowedecs = array(1050, 1054, 1054, 1054, 1060, 1060, 1060, 1050, 1060, 1050, 1060, 1050, 1060, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1060, 1060, 1050, 1050); foreach ($commands as $key => $command) { $result = $_link->Query(false, $command); if (!$result && DBManager::GetErrorCode() != $allowedecs[$key]) { return DBManager::GetErrorCode() . ": " . DBManager::GetError() . "\r\n\r\nMySQL Query: " . $commands[$key]; } } return true; }
static function IsChatBrowserIdAvailable($_browserId, $_allowExisting = true) { if (empty($_browserId)) { return false; } $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_VISITOR_BROWSERS . "` WHERE `id`='" . DBManager::RealEscape($_browserId) . "';"); if ($result) { if ($row = DBManager::FetchArray($result)) { if (!$_allowExisting) { return false; } if (!empty($row["overlay_container"]) || empty($row["is_chat"])) { return false; } } } return true; }