示例#1
0
 public function insert()
 {
     if (!is_null($this->id)) {
         trigger_error("User::insert(): Attempt to insert a user object that already has its ID property set to {$this->id}.", E_USER_ERROR);
     }
     $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
     $sql = "INSERT INTO " . TABLENAME_CHATREQUESTS . " ( type, sentById, sentToGroupId, sentToUserId, status ) VALUES ( :type, :sentById, :sentToGroupId, :sentToUserId, :status)";
     $st = $conn->prepare($sql);
     $st->bindValue(":type", $this->type, PDO::PARAM_STR);
     $st->bindValue(":sentById", $this->sentById, PDO::PARAM_INT);
     $st->bindValue(":sentToGroupId", $this->sentToGroupId, PDO::PARAM_INT);
     $st->bindValue(":sentToUserId", $this->sentToUserId, PDO::PARAM_INT);
     $st->bindValue(":status", $this->status, PDO::PARAM_STR);
     //	print_r( $st );
     $result = $st->execute();
     $this->id = $conn->lastInsertId();
     $conn = null;
     if (!$result) {
         self::$errorMessage = "User::insert: Insertion Failed, PDO::errorInfo(): " . $st->errorCode() . ": " . $st->errorInfo()[2];
         self::$errorCode = $st->errorCode();
         //echo $errorMessage;
         return false;
     } else {
         self::$successMessage = "User::insert: User successfully inserted with id " . $this->id;
         return true;
     }
 }
 public static function AcceptAll($_userId)
 {
     if ($result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_CHAT_REQUESTS . "` WHERE `receiver_user_id`='" . DBManager::RealEscape($_userId) . "';")) {
         while ($row = DBManager::FetchArray($result)) {
             $request = new ChatRequest($row);
             $request->SetStatus(false, true, false, true);
             $browser = new VisitorBrowser($row["receiver_browser_id"], $_userId, false);
             $browser->ForceUpdate();
         }
     }
 }
 static function TriggerEvents()
 {
     if (count(Server::$Events) == 0) {
         return;
     }
     $actionData = "";
     $url = VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1];
     $previous = count(VisitorMonitoring::$Browser->History) > 1 ? VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 2]->Url->GetAbsoluteUrl() : "";
     foreach (Server::$Events->Events as $event) {
         if (!$event->IsActive || empty($url)) {
             continue;
         }
         $urlor = count($event->FunnelUrls) == 0 && $event->MatchesURLCriterias($url->Url->GetAbsoluteUrl(), $url->Referrer->GetAbsoluteUrl(), $previous, time() - $url->Entrance);
         $urlfunnel = count($event->FunnelUrls) > 0 && $event->MatchesURLFunnelCriterias(VisitorMonitoring::$Browser->History);
         $global = $event->MatchesGlobalCriterias(count(VisitorMonitoring::$Browser->History), VisitorMonitoring::$Visitor->ExitTime - VisitorMonitoring::$Visitor->FirstActive, VisitorMonitoring::$Visitor->HasAcceptedChatRequest, VisitorMonitoring::$Visitor->HasDeclinedChatRequest, VisitorMonitoring::$Visitor->WasInChat(), VisitorMonitoring::$Browser->Query, VisitorMonitoring::$IsMobile || VisitorMonitoring::$IsTablet, VisitorMonitoring::$Visitor->GeoCountryISO2);
         if ($global && ($urlfunnel || $urlor)) {
             foreach (array($event->Goals, $event->Actions) as $elements) {
                 foreach ($elements as $action) {
                     $EventTrigger = new EventTrigger(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Id, time(), 1);
                     $EventTrigger->Load();
                     $aexists = $action->Exists(CALLER_USER_ID, CALLER_BROWSER_ID);
                     if (!$EventTrigger->Exists || $EventTrigger->Exists && $event->MatchesTriggerCriterias($EventTrigger)) {
                         if (!$aexists) {
                             if ($event->SaveInCookie) {
                                 if (!Is::Null(Cookie::Get("ea_" . $action->Id))) {
                                     continue;
                                 } else {
                                     Cookie::Set("ea_" . $action->Id, time());
                                 }
                             }
                             $EventTrigger->Save($event->Id);
                             if ($action->Type < 2) {
                                 foreach ($action->GetInternalReceivers() as $user_id) {
                                     $intaction = new EventActionInternal($user_id, $EventTrigger->Id);
                                     $intaction->Save();
                                 }
                             } else {
                                 if ($action->Type == 2 && !defined("EVENT_INVITATION")) {
                                     $sender = getActionSender($action->Invitation->Senders, true);
                                     Server::InitDataBlock(array("GROUPS"));
                                     if (!empty($sender) && !empty(Server::$Groups[$sender->GroupId]) && Server::$Groups[$sender->GroupId]->IsHumanAvailable(false) && !(VisitorMonitoring::$Browser->ChatRequest != null && !VisitorMonitoring::$Browser->ChatRequest->Closed) && !VisitorMonitoring::$Visitor->IsInChat(false, null, true)) {
                                         define("EVENT_INVITATION", true);
                                         $chatrequest = new ChatRequest($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action));
                                         $chatrequest->EventActionId = $action->Id;
                                         $chatrequest->Save();
                                         if (!$chatrequest->Displayed) {
                                             VisitorMonitoring::$Browser->ForceUpdate();
                                         }
                                         VisitorMonitoring::$Browser->ChatRequest = $chatrequest;
                                     }
                                 } else {
                                     if ($action->Type == 3 && !defined("EVENT_ALERT")) {
                                         define("EVENT_ALERT", true);
                                         $alert = new Alert(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Value);
                                         $alert->EventActionId = $action->Id;
                                         $alert->Save();
                                         VisitorMonitoring::$Browser->LoadAlerts();
                                     } else {
                                         if ($action->Type == 4 && !defined("EVENT_WEBSITE_PUSH")) {
                                             define("EVENT_WEBSITE_PUSH", true);
                                             $sender = getActionSender($action->WebsitePush->Senders, false);
                                             $websitepush = new WebsitePush($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action), $action->WebsitePush->Ask, $action->WebsitePush->TargetURL);
                                             $websitepush->EventActionId = $action->Id;
                                             $websitepush->Save();
                                             VisitorMonitoring::$Browser->LoadWebsitePush();
                                         } else {
                                             if ($action->Type == 5 && !defined("EVENT_OVERLAY_BOX")) {
                                                 define("EVENT_OVERLAY_BOX", true);
                                                 $overlaybox = new OverlayBox(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Value);
                                                 $overlaybox->EventActionId = $action->Id;
                                                 $overlaybox->Save();
                                                 VisitorMonitoring::$Browser->LoadOverlayBoxes();
                                             } else {
                                                 if ($action->Type == 9 && STATS_ACTIVE) {
                                                     Server::$Statistic->ProcessAction(ST_ACTION_GOAL, array(CALLER_USER_ID, $action->Id, VisitorMonitoring::$Visitor->Visits == 1 ? 1 : 0, VisitorMonitoring::$Browser->GetQueryId(Cookie::Get("sp"), null, 255, true)));
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($EventTrigger->Exists && $aexists) {
                         $EventTrigger->Update();
                     }
                 }
             }
         }
     }
     return $actionData;
 }
function appendChatRequests()
{
    global $INTERNAL, $VISITOR;
    $visitors = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_va"]);
    $browids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_vb"]);
    $reqnames = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_REQUESTS . "_vc"]));
    $reqids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_vd"]);
    $reqtexts = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_REQUESTS . "_ve"]));
    $sendergroup = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_REQUESTS . "_vf"]));
    foreach ($reqids as $key => $requestid) {
        if (isset($VISITOR[$visitors[$key]])) {
            $skip = false;
            foreach ($VISITOR[$visitors[$key]]->Browsers as $browser) {
                $browser->LoadChatRequest();
                if (!empty($browser->ChatRequest) && !$browser->ChatRequest->Closed) {
                    $skip = true;
                    continue;
                }
            }
            if ($skip) {
                continue;
            }
            $request = new ChatRequest(CALLER_SYSTEM_ID, $sendergroup[$key], $visitors[$key], $browids[$key], $reqtexts[$key]);
            $request->Save();
        }
    }
}
示例#5
0
function declineDateRequest()
{
    $request = ChatRequest::getById($_GET['id']);
    $request->status = "declined";
    $request->update();
    require TEMPLATE_PATH . "/home.php";
}
 function CreateArchiveEntry($_internalUser, $_visitor, $custom = "", $etpl = "", $_customsInTranscript = true, $pdm = null)
 {
     global $CONFIG, $INPUTS, $GROUPS, $LZLANG;
     if ($this->ArchiveCreated) {
         return;
     }
     if ($INPUTS[111]->Active) {
         $custom .= strip_tags($INPUTS[111]->Caption) . " %efullname%\r\n";
     }
     if ($INPUTS[112]->Active) {
         $custom .= strip_tags($INPUTS[112]->Caption) . " %eemail%\r\n";
     }
     if (!empty($this->Company) && $INPUTS[113]->Active) {
         $custom .= strip_tags($INPUTS[113]->Caption) . " " . trim($this->Company) . "\r\n";
     }
     if (!empty($this->Question) && $INPUTS[114]->Active) {
         $custom .= strip_tags($INPUTS[114]->Caption) . " " . trim($this->Question) . "\r\n";
     }
     if (!empty($this->Phone) && $INPUTS[116]->Active) {
         $custom .= strip_tags($INPUTS[116]->Caption) . " " . trim($this->Phone) . "\r\n";
     }
     if (!empty($this->ChatVoucherId)) {
         $custom .= strip_tags($LZLANG["client_voucher_id"]) . " " . trim($this->ChatVoucherId) . "\r\n";
     }
     $customs = array();
     if (is_array($this->Customs)) {
         foreach ($this->Customs as $cind => $value) {
             if ($INPUTS[$cind]->Active && $INPUTS[$cind]->Custom) {
                 $customs[$INPUTS[$cind]->Name] = $value;
                 if (!isset($GROUPS[$this->DesiredChatGroup]->ChatInputsHidden[$cind]) && $_customsInTranscript) {
                     if ($INPUTS[$cind]->Type == "CheckBox") {
                         $custom .= strip_tags($INPUTS[$cind]->Caption) . " " . (!empty($value) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->") . "\r\n";
                     } else {
                         if ($INPUTS[$cind]->Type == "ComboBox") {
                             $custom .= strip_tags($INPUTS[$cind]->Caption) . " " . $INPUTS[$cind]->GetClientValue($value) . "\r\n";
                         } else {
                             $custom .= strip_tags($INPUTS[$cind]->Caption) . " " . $value . "\r\n";
                         }
                     }
                 }
             }
         }
     }
     if (!empty($GROUPS[$this->DesiredChatGroup]->PredefinedMessages)) {
         $pdm = getPredefinedMessage($GROUPS[$this->DesiredChatGroup]->PredefinedMessages, $_visitor->Language);
         if (!empty($pdm->EmailChatTranscript)) {
             $etpl = $pdm->EmailChatTranscript;
         }
     }
     $etpl = str_replace("%external_ip%", getIP(), $etpl);
     $etpl = str_replace("%chat_id%", $this->ChatId, $etpl);
     $etpl = str_replace("%website_name%", $CONFIG["gl_site_name"], $etpl);
     $etpl = str_replace("%details%", $custom, $etpl);
     $etpl = str_replace("%group_description%", $GROUPS[$this->DesiredChatGroup]->GetDescription($_visitor->Language), $etpl);
     $etpl = str_replace(array("%group_name%", "%group_id%"), $this->DesiredChatGroup, $etpl);
     if ($this->InternalUser) {
         $etpl = str_replace("%operator_name%", $this->InternalUser->Fullname, $etpl);
         $etpl = str_replace("%operator_email%", $this->InternalUser->Email, $etpl);
     }
     $etpl = str_replace("%external_name%", "%efullname%", $etpl);
     $etpl = str_replace("%external_email%", "%eemail%", $etpl);
     $etpl = str_replace("%external_company%", $this->Company, $etpl);
     $etpl = str_replace("%external_phone%", $this->Phone, $etpl);
     $etpl = str_replace("%question%", $this->Question, $etpl);
     $subject = $pdm != null ? $pdm->SubjectChatTranscript : "";
     $subject = getSubject($subject, $this->Email, $this->Fullname, $this->DesiredChatGroup, $this->ChatId, $this->Company, $this->Phone, getIP(), $this->Question, $GROUPS[$this->DesiredChatGroup]->GetDescription($_visitor->Language), $this->Customs);
     $internal = $_internalUser != null && $_internalUser->IsBot ? $_internalUser->SystemId : "";
     $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_id`='" . DBManager::RealEscape($this->ChatId) . "';");
     if ($result && DBManager::GetRowCount($result) == 0) {
         if ($CONFIG["gl_adct"] == 1 || (!empty($CONFIG["gl_rm_chats_time"]) || empty($CONFIG["gl_rm_chats"]))) {
             queryDB(true, "INSERT INTO `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` (`time`,`endtime`,`closed`,`chat_id`,`external_id`,`fullname`,`internal_id`,`group_id`,`area_code`,`html`,`plaintext`,`transcript_text`,`email`,`company`,`iso_language`,`iso_country`,`host`,`ip`,`gzip`,`transcript_sent`,`transcript_receiver`,`question`,`customs`,`subject`,`voucher_id`) VALUES ('" . DBManager::RealEscape($this->FirstActive) . "',0,0,'" . DBManager::RealEscape($this->ChatId) . "','" . DBManager::RealEscape($this->UserId) . "','','" . DBManager::RealEscape($internal) . "','','" . DBManager::RealEscape($this->Code) . "','','','" . DBManager::RealEscape($etpl) . "','','','" . DBManager::RealEscape($_visitor->Language) . "','" . DBManager::RealEscape($_visitor->GeoCountryISO2) . "','" . DBManager::RealEscape($_visitor->Host) . "','" . DBManager::RealEscape($_visitor->IP) . "',0,0,'" . DBManager::RealEscape($this->Email) . "','','" . DBManager::RealEscape(@serialize($customs)) . "','" . DBManager::RealEscape($subject) . "','" . DBManager::RealEscape($this->ChatVoucherId) . "');");
         }
         $this->ArchiveCreated = true;
         ChatRequest::AcceptAll($this->UserId);
     }
 }
function processChatInvitation()
{
    if (isset($_POST[POST_INTERN_PROCESS_REQUESTS . "_va"])) {
        global $VISITOR;
        $visitors = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_va"]);
        $browids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_vb"]);
        $reqids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_vd"]);
        $reqtexts = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_ve"]);
        $sendergroup = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_vf"]);
        foreach ($reqids as $key => $requestid) {
            if (isset($VISITOR[$visitors[$key]])) {
                //$VISITOR[$visitors[$key]]->Load();
                //$VISITOR[$visitors[$key]]->LoadBrowsers();
                $request = new ChatRequest(CALLER_SYSTEM_ID, $sendergroup[$key], $visitors[$key], $browids[$key], base64_decode($reqtexts[$key]));
                $request->Save();
                $VISITOR[$visitors[$key]]->ChatRequests = null;
                $VISITOR[$visitors[$key]]->LoadChatRequests();
            }
        }
    }
}
function triggerEvents($chatRequest = false, $alert = false, $websitePush = false)
{
    global $BROWSER, $CONFIG, $EVENTS, $INTERNAL, $EXTERNALUSER, $STATS, $GROUPS;
    if (count($EVENTS) == 0) {
        return;
    }
    $actionData = "";
    $url = $BROWSER->History[count($BROWSER->History) - 1];
    $previous = count($BROWSER->History) > 1 ? $BROWSER->History[count($BROWSER->History) - 2]->Url->GetAbsoluteUrl() : "";
    $EXTERNALUSER->GetChatRequestResponses();
    foreach ($EVENTS->Events as $event) {
        $match = false;
        if (!$event->IsActive || empty($url)) {
            continue;
        }
        $urlor = count($event->FunnelUrls) == 0 && $event->MatchesURLCriterias($url->Url->GetAbsoluteUrl(), $url->Referrer->GetAbsoluteUrl(), $previous, time() - $url->Entrance);
        $urlfunnel = count($event->FunnelUrls) > 0 && $event->MatchesURLFunnelCriterias($BROWSER->History);
        $global = $event->MatchesGlobalCriterias(count($BROWSER->History), $EXTERNALUSER->ExitTime - $EXTERNALUSER->FirstActive, $EXTERNALUSER->HasAcceptedChatRequest, $EXTERNALUSER->HasDeclinedChatRequest, $EXTERNALUSER->IsInChat() || $EXTERNALUSER->WasInChat(), $BROWSER->Query);
        if ($global && ($urlfunnel || $urlor)) {
            foreach (array($event->Goals, $event->Actions) as $elements) {
                foreach ($elements as $action) {
                    $EventTrigger = new EventTrigger(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Id, time(), 1);
                    $EventTrigger->Load();
                    $aexists = $action->Exists(CALLER_USER_ID, CALLER_BROWSER_ID);
                    if (!$EventTrigger->Exists || $EventTrigger->Exists && $event->MatchesTriggerCriterias($EventTrigger)) {
                        if (!$aexists) {
                            $EventTrigger->Save($event->Id);
                            if ($action->Type < 2) {
                                foreach ($action->GetInternalReceivers() as $user_id) {
                                    $intaction = new EventActionInternal($user_id, $EventTrigger->Id);
                                    $intaction->Save();
                                }
                            } else {
                                if ($action->Type == 2 && !defined("EVENT_INVITATION")) {
                                    $sender = getActionSender($action->Invitation->Senders, true);
                                    initData(false, true);
                                    if (!empty($sender) && $GROUPS[$sender->GroupId]->IsOpeningHour()) {
                                        define("EVENT_INVITATION", true);
                                        $chatrequest = new ChatRequest($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action));
                                        $chatrequest->EventActionId = $action->Id;
                                        $chatrequest->Save();
                                        $BROWSER->LoadChatRequest();
                                        $chatRequest = true;
                                    }
                                } else {
                                    if ($action->Type == 3 && !defined("EVENT_ALERT")) {
                                        define("EVENT_ALERT", true);
                                        $alert = new Alert(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Value);
                                        $alert->EventActionId = $action->Id;
                                        $alert->Save();
                                        $BROWSER->LoadAlerts();
                                    } else {
                                        if ($action->Type == 4 && !defined("EVENT_WEBSITE_PUSH")) {
                                            define("EVENT_WEBSITE_PUSH", true);
                                            $sender = getActionSender($action->WebsitePush->Senders, false);
                                            $websitepush = new WebsitePush($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action), $action->WebsitePush->Ask, $action->WebsitePush->TargetURL);
                                            $websitepush->EventActionId = $action->Id;
                                            $websitepush->Save();
                                            $BROWSER->LoadWebsitePush();
                                        } else {
                                            if ($action->Type == 5 && STATS_ACTIVE) {
                                                $STATS->ProcessAction(ST_ACTION_GOAL, array(CALLER_USER_ID, $action->Id, $EXTERNALUSER->Visits == 1 ? 1 : 0));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($EventTrigger->Exists && $aexists) {
                        $EventTrigger->Update();
                    }
                }
            }
        }
    }
    return $actionData;
}
 function CreateArchiveEntry($_internalUser, $_visitor, $custom = "", $etpl = "", $_customsInTranscript = true, $pdm = null)
 {
     if (!empty($this->ArchiveCreated)) {
         return;
     }
     if (Server::$Inputs[111]->Active) {
         $custom .= strip_tags(Server::$Inputs[111]->Caption) . " %efullname%\r\n";
     }
     if (Server::$Inputs[112]->Active) {
         $custom .= strip_tags(Server::$Inputs[112]->Caption) . " %eemail%\r\n";
     }
     if (!empty($this->Company) && Server::$Inputs[113]->Active) {
         $custom .= strip_tags(Server::$Inputs[113]->Caption) . " " . trim($this->UserData->Company) . "\r\n";
     }
     if (!empty($this->Question) && Server::$Inputs[114]->Active) {
         $custom .= strip_tags(Server::$Inputs[114]->Caption) . " " . trim($this->UserData->Text) . "\r\n";
     }
     if (!empty($this->Phone) && Server::$Inputs[116]->Active) {
         $custom .= strip_tags(Server::$Inputs[116]->Caption) . " " . trim($this->UserData->Phone) . "\r\n";
     }
     if (!empty($this->ChatVoucherId)) {
         $custom .= strip_tags(LocalizationManager::$TranslationStrings["client_voucher_id"]) . " " . trim($this->ChatVoucherId) . "\r\n";
     }
     $customs = array();
     if (is_array($this->UserData->Customs)) {
         foreach ($this->UserData->Customs as $cind => $value) {
             if (Server::$Inputs[$cind]->Active && Server::$Inputs[$cind]->Custom) {
                 $customs[Server::$Inputs[$cind]->Name] = $value;
                 if (!isset(Server::$Groups[$this->DesiredChatGroup]->ChatInputsHidden[$cind]) && $_customsInTranscript) {
                     if (Server::$Inputs[$cind]->Type == "CheckBox") {
                         $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . (!empty($value) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->") . "\r\n";
                     } else {
                         if (Server::$Inputs[$cind]->Type == "ComboBox") {
                             $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . Server::$Inputs[$cind]->GetClientValue($value) . "\r\n";
                         } else {
                             $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . $value . "\r\n";
                         }
                     }
                 }
             }
         }
     }
     $tsData = array("", "");
     if (!empty(Server::$Groups[$this->DesiredChatGroup]->PredefinedMessages)) {
         $pdm = PredefinedMessage::GetByLanguage(Server::$Groups[$this->DesiredChatGroup]->PredefinedMessages, $_visitor->Language);
         if (!empty($pdm->EmailChatTranscriptBodyPlaintext)) {
             $tsData[0] = $pdm->EmailChatTranscriptBodyPlaintext;
         }
         if (!empty($pdm->EmailChatTranscriptBodyHTML)) {
             $tsData[1] = $pdm->EmailChatTranscriptBodyHTML;
         }
     }
     for ($i = 0; $i < count($tsData); $i++) {
         $tsData[$i] = str_replace("%chat_id%", $this->ChatId, $tsData[$i]);
         $tsData[$i] = str_replace("%details%", $custom, $tsData[$i]);
         $tsData[$i] = str_replace("%external_name%", "%efullname%", $tsData[$i]);
         $tsData[$i] = str_replace("%external_email%", "%eemail%", $tsData[$i]);
         $tsData[$i] = str_replace("%external_company%", $this->UserData->Company, $tsData[$i]);
         $tsData[$i] = str_replace("%external_phone%", $this->UserData->Phone, $tsData[$i]);
         $tsData[$i] = str_replace("%question%", $this->UserData->Text, $tsData[$i]);
         $tsData[$i] = str_replace("%feedback_link%", Feedback::GetLink("cid=" . Encoding::Base64UrlEncode($this->ChatId)), $tsData[$i]);
         $tsData[$i] = Server::$Groups[$this->DesiredChatGroup]->TextReplace($tsData[$i], $_visitor->Language);
         if (!empty($this->OperatorId)) {
             $tsData[$i] = Server::$Operators[$this->OperatorId]->TextReplace($tsData[$i]);
         }
         $tsData[$i] = $_visitor->TextReplace($tsData[$i]);
         $tsData[$i] = Configuration::Replace($tsData[$i]);
     }
     $subject = $pdm != null ? $pdm->SubjectChatTranscript : "";
     $subject = Mailbox::GetSubject($subject, $this->UserData->Email, $this->UserData->Fullname, $this->DesiredChatGroup, $this->ChatId, $this->UserData->Company, $this->UserData->Phone, Communication::GetIP(), $this->UserData->Text, Server::$Groups[$this->DesiredChatGroup]->GetDescription($_visitor->Language), $this->UserData->Customs);
     $internal = $_internalUser != null && $_internalUser->IsBot ? $_internalUser->SystemId : "";
     $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_id`='" . DBManager::RealEscape($this->ChatId) . "';");
     if ($result && DBManager::GetRowCount($result) == 0) {
         if (Server::$Configuration->File["gl_adct"] == 1 || (!empty(Server::$Configuration->File["gl_rm_chats_time"]) || empty(Server::$Configuration->File["gl_rm_chats"]))) {
             $url = Visitor::GetLastURLFromVisitor($this->UserId);
             DBManager::Execute(true, "INSERT INTO `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` (`time`,`endtime`,`closed`,`chat_id`,`external_id`,`fullname`,`internal_id`,`group_id`,`area_code`,`html`,`plaintext`,`transcript_text`,`transcript_html`,`email`,`company`,`iso_language`,`iso_country`,`host`,`ip`,`gzip`,`transcript_sent`,`transcript_receiver`,`question`,`customs`,`subject`,`voucher_id`,`ref_url`) VALUES ('" . DBManager::RealEscape($this->FirstActive) . "',0,0,'" . DBManager::RealEscape($this->ChatId) . "','" . DBManager::RealEscape($this->UserId) . "','','" . DBManager::RealEscape($internal) . "','','" . DBManager::RealEscape($this->Code) . "','','','" . DBManager::RealEscape($tsData[0]) . "','" . DBManager::RealEscape($tsData[1]) . "','','','" . DBManager::RealEscape($_visitor->Language) . "','" . DBManager::RealEscape($_visitor->GeoCountryISO2) . "','" . DBManager::RealEscape($_visitor->Host) . "','" . DBManager::RealEscape($_visitor->IP) . "',0,0,'" . DBManager::RealEscape($this->UserData->Email) . "','','" . DBManager::RealEscape(@serialize($customs)) . "','" . DBManager::RealEscape($subject) . "','" . DBManager::RealEscape($this->ChatVoucherId) . "','" . DBManager::RealEscape($url) . "');");
         }
         $this->ArchiveCreated = 1;
         ChatRequest::AcceptAll($this->UserId);
     }
 }
示例#10
0
function chat_req()
{
    if (isset($_SESSION['groupId'])) {
        echo "you are under this group :" . Group::getById($_SESSION['groupId'])->name . "<br>";
        // chat requests for group which has been selected
        echo "chat requests for this group:<br>";
        $chatRequests = ChatRequest::getByUserId($_SESSION['userId'], $_SESSION['groupId']);
        $a = sizeof($chatRequests);
        for ($i = 0; $i < $a; $i++) {
            $group = Group::getById($chatRequests[$i]["sentById"]);
            $html = "<li>chat request from " . $group->name . "<br>";
            $html .= "users: <br>" . User::getById($group->adminId)->name . " , " . User::getById($group->per2Id)->name . "and" . User::getById($group->per3Id)->name . "<br>";
            $html .= "<a href='/backend/main.php?action=acceptChatRequest&id=" . $chatRequests[$i]["id"] . "'>accept</a>&nbsp&nbsp&nbsp&nbsp";
            $html .= "<a href='/backend/main.php?action=declineChatRequest&id=" . $chatRequests[$i]["id"] . "'>decline</a></li><br>";
        }
    }
    echo $html;
}
function appendRequests()
{
    global $INTERNAL, $VISITOR;
    $visitors = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_va"]);
    $browids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_vb"]);
    $reqnames = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_REQUESTS . "_vc"]));
    $reqids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_REQUESTS . "_vd"]);
    $reqtexts = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_REQUESTS . "_ve"]));
    $sendergroup = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_REQUESTS . "_vf"]));
    foreach ($reqids as $key => $requestid) {
        if (isset($VISITOR[$visitors[$key]])) {
            $request = new ChatRequest($INTERNAL[CALLER_SYSTEM_ID]->SessId, $visitors[$key], $browids[$key], REQUEST_STATUS_ACTIVE);
            $request->SenderUserId = $INTERNAL[CALLER_SYSTEM_ID]->UserId;
            $request->SenderGroupId = $sendergroup[$key];
            $request->SenderFullname = $INTERNAL[CALLER_SYSTEM_ID]->Fullname != null ? $INTERNAL[CALLER_SYSTEM_ID]->Fullname : $INTERNAL[CALLER_SYSTEM_ID]->UserId;
            $request->Text = $reqtexts[$key];
            $request->Save();
        }
    }
}
示例#12
0
for ($i = 0; $i < $a; $i++) {
    $group = Group::getById($requests[$i]["sentById"]);
    $user = User::getById($group->adminId);
    if ($_SESSION['userId'] != $group->per2Id) {
        $user1 = User::getById($group->per2Id);
    } else {
        $user1 = User::getById($group->per3Id);
    }
    echo "you got request from " . $user->name . " to join to group " . $group->name . " with " . $user1->name . " <br>";
    echo "<a href='/dating_website/index.php?action=acceptGroupRequest&id=" . $requests[$i]["id"] . "'>accept</a>&nbsp&nbsp&nbsp&nbsp";
    echo "<a href='/dating_website/index.php?action=declineGroupRequest&id=" . $requests[$i]["id"] . "'>decline</a><br>";
}
if (isset($_SESSION['groupId'])) {
    echo "you are under this group :" . Group::getById($_SESSION['groupId'])->name . "<br>";
    echo "chat requests for this group:<br>";
    $chatRequests = ChatRequest::getByUserId($_SESSION['userId'], $_SESSION['groupId']);
    $a = sizeof($chatRequests);
    for ($i = 0; $i < $a; $i++) {
        $group = Group::getById($chatRequests[$i]["sentById"]);
        echo "chat request from " . $group->name . "<br>";
        echo "users: <br>" . User::getById($group->adminId)->name . " , " . User::getById($group->per2Id)->name . "and" . User::getById($group->per3Id)->name . "<br>";
        echo "<a href='/dating_website/index.php?action=acceptChatRequest&id=" . $chatRequests[$i]["id"] . "'>accept</a>&nbsp&nbsp&nbsp&nbsp";
        echo "<a href='/dating_website/index.php?action=declineChatRequest&id=" . $chatRequests[$i]["id"] . "'>decline</a><br>";
    }
    echo "date requests for this group:<br>";
    $dateRequests = DateRequest::getByUserId($_SESSION['userId'], $_SESSION['groupId']);
    $a = sizeof($dateRequests);
    for ($i = 0; $i < $a; $i++) {
        $group = Group::getById($dateRequests[$i]["sentById"]);
        echo "date request from " . $group->name . "<br>";
        echo "users: <br>" . User::getById($group->adminId)->name . " , " . User::getById($group->per2Id)->name . "and" . User::getById($group->per3Id)->name . "<br>";