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 processWebsitePushs() { if (isset($_POST[POST_INTERN_PROCESS_GUIDES . "_va"])) { $visitors = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_va"]); $asks = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_vb"]); $urls = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_vc"]); $browids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_vd"]); $texts = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_ve"]); $groups = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_vf"]); foreach ($visitors as $key => $visitor) { $guide = new WebsitePush(CALLER_SYSTEM_ID, $groups[$key], $visitors[$key], $browids[$key], $texts[$key], $asks[$key], $urls[$key]); $guide->Save(); } } }
function appendWebsitePushs() { global $INTERNAL; $guides = array(); $visitors = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_va"]); $asks = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_vb"]); $urls = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_GUIDES . "_vc"])); $browids = explode(POST_ACTION_VALUE_SPLITTER, $_POST[POST_INTERN_PROCESS_GUIDES . "_vd"]); $texts = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_GUIDES . "_ve"])); $groups = explode(POST_ACTION_VALUE_SPLITTER, slashesStrip($_POST[POST_INTERN_PROCESS_GUIDES . "_vf"])); foreach ($visitors as $key => $visitor) { $guide = new WebsitePush(CALLER_SYSTEM_ID, $groups[$key], $visitors[$key], $browids[$key], $texts[$key], $asks[$key], $urls[$key]); $guide->Save(); } }
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; }