static function SendChatTranscripts($_custom = false) { Server::InitDataBlock(array("INTERNAL", "INPUTS")); Chat::CloseChats(); $defmailbox = Mailbox::GetDefaultOutgoing(); $result = DBManager::Execute(false, "SELECT `voucher_id`,`subject`,`customs`,`internal_id`,`transcript_text`,`transcript_html`,`transcript_receiver`,`email`,`chat_id`,`fullname`,`group_id` FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=1 AND `endtime`>0 AND `closed`>0 AND `transcript_sent`=0 LIMIT 1;"); if ($result) { while ($row = DBManager::FetchArray($result)) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` SET `transcript_sent`=1 WHERE `chat_id`='" . DBManager::RealEscape($row["chat_id"]) . "' LIMIT 1;"); if (empty($row["transcript_html"]) && empty($row["transcript_text"])) { continue; } $tData = array($row["transcript_text"], $row["transcript_html"]); for ($i = 0; $i < count($tData); $i++) { if ($i == 1 && empty($tData[$i])) { continue; } $tData[$i] = str_replace(array("%fullname%", "%efullname%"), $row["fullname"], $tData[$i]); $tData[$i] = str_replace(array("%email%", "%eemail%"), $row["email"], $tData[$i]); $tData[$i] = str_replace("%rating%", Feedback::GetRatingAVG($row["chat_id"]), $tData[$i]); $subject = $row["subject"]; $customs = @unserialize($row["customs"]); $fakeSender = ""; foreach (Server::$Inputs as $index => $input) { if ($input->Active && $input->Custom && !isset(Server::$Groups[$row["group_id"]]->TicketInputsHidden[$index])) { $cv = ""; if ($input->Type == "CheckBox") { $cv = !empty($customs[$input->Name]) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->"; } else { if (!empty($customs[$input->Name]) || $input->Type == "ComboBox") { $cv = $input->GetClientValue(@$customs[$input->Name]); } } $tData[$i] = str_replace("%custom" . $index . "%", $cv, $tData[$i]); } } $tData[$i] = Server::Replace($tData[$i]); $tData[$i] = Mailbox::FinalizeEmail($tData[$i], $i == 1); } $mailbox = null; if (!empty($row["group_id"]) && isset(Server::$Groups[$row["group_id"]]) && !empty(Server::$Groups[$row["group_id"]]->ChatEmailOut)) { $mailbox = Mailbox::GetById(Server::$Groups[$row["group_id"]]->ChatEmailOut); } $mailbox = !empty($mailbox) ? $mailbox : $defmailbox; if ($mailbox != null && (!empty(Server::$Configuration->File["gl_soct"]) || $_custom) && !empty($row["transcript_receiver"])) { Communication::SendEmail($mailbox, $row["transcript_receiver"], $mailbox->Email, $tData[0], $tData[1], $subject); } if (!empty(Server::$Configuration->File["gl_scto"]) && !$_custom) { Server::InitDataBlock(array("INTERNAL")); $receivers = array(); $resulti = DBManager::Execute(true, "SELECT `user_id` FROM `" . DB_PREFIX . DATABASE_VISITOR_CHAT_OPERATORS . "` WHERE `chat_id`='" . DBManager::RealEscape($row["chat_id"]) . "' AND `ltime`=0;"); if ($resulti) { while ($rowi = DBManager::FetchArray($resulti)) { if (!empty(Server::$Operators[$rowi["user_id"]]) && !in_array($rowi["user_id"], $receivers)) { $receivers[] = $rowi["user_id"]; } else { continue; } Communication::SendEmail($mailbox, Server::$Operators[$receivers[count($receivers) - 1]]->Email, $mailbox->Email, $tData[0], $tData[1], $subject); } } } if (!empty(Server::$Configuration->File["gl_sctg"]) && !$_custom) { Server::InitDataBlock(array("GROUPS")); Communication::SendEmail($mailbox, Server::$Groups[$row["group_id"]]->Email, $mailbox->Email, $tData[0], $tData[1], $subject); } if (!empty($mailbox) && !empty(Server::$Configuration->File["gl_scct"])) { if (!empty(Server::$Configuration->File["gl_uvec"])) { if (Mailbox::IsValidEmail($row["transcript_receiver"])) { $fakeSender = $row["transcript_receiver"]; } else { if (Mailbox::IsValidEmail($row["email"])) { $fakeSender = $row["email"]; } } } Communication::SendEmail($mailbox, Server::$Configuration->File["gl_scct"], $mailbox->Email, $tData[0], $tData[1], $subject, false, null, $fakeSender); } if (!empty($row["voucher_id"])) { $ticket = new CommercialChatVoucher(null, $row["voucher_id"]); $ticket->Load(); $ticket->SendStatusEmail(); } } } if (!empty(Server::$Configuration->File["gl_rm_chats"]) && Server::$Configuration->File["gl_rm_chats_time"] == 0) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `transcript_sent` = '1';"); } }
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++; } }
$html = str_replace("<!--voucher_id-->", base64UrlEncode($ticket->Id), $html); $html = str_replace("<!--server-->", LIVEZILLA_URL, $html); $ofc = !empty($_POST["form_ofc"]) ? "&ofc=MQ__" : ""; if (!empty($_POST["form_extends"]) && !empty($_POST["form_group"])) { $html = str_replace("<!--co-->", "&co=" . base64UrlEncode($_POST["form_extends"]) . "&intgroup=" . base64UrlEncode($_POST["form_group"]) . $ofc, $html); } else { if (!empty($_POST["form_group"])) { $html = str_replace("<!--co-->", "&intgroup=" . base64UrlEncode($_POST["form_group"]) . $ofc, $html); } else { $html = str_replace("<!--co-->", $ofc, $html); } } exit($html); } else { if (!empty($_GET["confirm"]) && $_GET["confirm"] == "1" && !empty($_GET["vc"]) && strlen(base64UrlDecode($_GET["vc"])) == 16) { require LIVEZILLA_PATH . "_lib/functions.pp.paypal.inc.php"; $voucher = new CommercialChatVoucher("", base64UrlDecode($_GET["vc"])); if ($voucher->Load()) { if (PayProvValidatePayment($voucher->Price)) { languageSelect($voucher->Language); $voucher->SetPaymentDetails(PayProvGetPaymentId(), PayProvGetPayerId(), PayProvGetPaymentDetails()); if (empty($PAYMENTERROR)) { $voucher->SetVoucherParams(!empty($voucher->Voided), true, false, false, false, true, base64UrlDecode($_GET[GET_EXTERN_GROUP])); } else { $voucher->SetVoucherParams(!empty($voucher->Voided), false, false, false, false); } } } } } 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; }
function sendChatTranscripts($_custom = false) { global $CONFIG, $INTERNAL, $GROUPS, $INPUTS; initData(array("INTERNAL", "INPUTS")); closeChats(); $defmailbox = Mailbox::GetDefaultOutgoing(); $result = queryDB(false, "SELECT `voucher_id`,`subject`,`customs`,`internal_id`,`transcript_text`,`transcript_receiver`,`email`,`chat_id`,`fullname`,`group_id` FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=1 AND `endtime`>0 AND `closed`>0 AND `transcript_sent`=0 LIMIT 1;"); if ($result) { while ($row = DBManager::FetchArray($result)) { if (empty($row["transcript_text"])) { continue; } queryDB(true, "UPDATE `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` SET `transcript_sent`=1 WHERE `chat_id`='" . DBManager::RealEscape($row["chat_id"]) . "' LIMIT 1;"); $rcvs = str_replace(array("%fullname%", "%efullname%"), $row["fullname"], $row["transcript_text"]); $rcvs = str_replace(array("%email%", "%eemail%"), $row["email"], $rcvs); $rcvs = str_replace("%rating%", getRatingAVGFromChatId($row["chat_id"]), $rcvs); $subject = $row["subject"]; $customs = @unserialize($row["customs"]); $fakeSender = ""; foreach ($INPUTS as $index => $input) { if ($input->Active && $input->Custom && !isset($GROUPS[$row["group_id"]]->TicketInputsHidden[$index])) { $cv = ""; if ($input->Type == "CheckBox") { $cv = !empty($customs[$input->Name]) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->"; } else { if (!empty($customs[$input->Name]) || $input->Type == "ComboBox") { $cv = $input->GetClientValue(@$customs[$input->Name]); } } $rcvs = str_replace("%custom" . $index . "%", $cv, $rcvs); } } $rcvs = applyReplacements($rcvs); $rcvs = Mailbox::FinalizeEmail($rcvs . "\r\n\r\n<!--lz_ref_link-->"); $mailbox = null; if (!empty($row["group_id"]) && isset($GROUPS[$row["group_id"]]) && !empty($GROUPS[$row["group_id"]]->ChatEmailOut)) { $mailbox = Mailbox::GetById($GROUPS[$row["group_id"]]->ChatEmailOut); } $mailbox = !empty($mailbox) ? $mailbox : $defmailbox; if ((!empty($CONFIG["gl_soct"]) || $_custom) && !empty($row["transcript_receiver"])) { sendMail($mailbox, $row["transcript_receiver"], $mailbox->Email, $rcvs, $subject); } if (!empty($CONFIG["gl_scto"]) && !$_custom) { initData(array("INTERNAL")); $receivers = array(); $resulti = queryDB(true, "SELECT `sender`,`receiver` FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `chat_id`='" . DBManager::RealEscape($row["chat_id"]) . "';"); if ($resulti) { while ($rowi = DBManager::FetchArray($resulti)) { if (!empty($INTERNAL[$rowi["sender"]]) && !in_array($rowi["sender"], $receivers)) { $receivers[] = $rowi["sender"]; } else { if (!empty($INTERNAL[$rowi["receiver"]]) && !in_array($rowi["receiver"], $receivers)) { $receivers[] = $rowi["receiver"]; } else { continue; } } sendMail($mailbox, $INTERNAL[$receivers[count($receivers) - 1]]->Email, $mailbox->Email, $rcvs, $subject); } } } if (!empty($CONFIG["gl_sctg"]) && !$_custom) { initData(array("GROUPS")); sendMail($mailbox, $GROUPS[$row["group_id"]]->Email, $mailbox->Email, $rcvs, $subject); } if (!empty($mailbox) && !empty($CONFIG["gl_scct"])) { if (!empty($CONFIG["gl_uvec"])) { if (Mailbox::IsValidEmail($row["transcript_receiver"])) { $fakeSender = $row["transcript_receiver"]; } else { if (Mailbox::IsValidEmail($row["email"])) { $fakeSender = $row["email"]; } } } sendMail($mailbox, $CONFIG["gl_scct"], $mailbox->Email, $rcvs, $subject, false, null, $fakeSender); } if (!empty($row["voucher_id"])) { $ticket = new CommercialChatVoucher(null, $row["voucher_id"]); $ticket->Load(); $ticket->SendStatusEmail(); } } } if (!empty($CONFIG["gl_rm_chats"]) && $CONFIG["gl_rm_chats_time"] == 0) { queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `transcript_sent` = '1';"); } }
static function GetMatchingVoucher($_groupId, $_voucherid) { Server::InitDataBlock(array("GROUPS", "DBCONFIG")); $ticket = new CommercialChatVoucher("", $_voucherid); $ticket->Load(); $result = DBManager::Execute(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(Server::$Configuration->Database["cct"][$row["tid"]])) { $ticket = new CommercialChatVoucher($row); if (in_array($row["tid"], Server::$Groups[$_groupId]->ChatVouchersRequired)) { return $ticket; } } } return null; }