コード例 #1
0
 function CheckTrackingMode()
 {
     global $_NS_TRACK_VARS, $_COOKIE;
     $Db =& $_NS_TRACK_VARS['Db'];
     $Settings =& $_NS_TRACK_VARS['Settings'];
     $CompanyId =& $_NS_TRACK_VARS['CompanyId'];
     $StId =& $_NS_TRACK_VARS['StId'];
     $VisId =& $_NS_TRACK_VARS['VisId'];
     $ClickSubId =& $_NS_TRACK_VARS['ClickSubId'];
     $TM = $Settings['All']->TRACKING_MODE;
     if (!$TM) {
         return false;
     }
     $Mode = "";
     $PaidPoint = "";
     $NaturalPoint = "";
     $NonePoint = "";
     $PriorArr = explode("|", $TM);
     $Mode = NS_TRACK_MISC::ValidVar($PriorArr[0], "NONE");
     if (NS_TRACK_MISC::ValidVar($PriorArr[1])) {
         $EntryArr = explode(";", $PriorArr[1]);
         for ($i = 0; $i < count($EntryArr); $i++) {
             $TmpArr = explode(":", $EntryArr[$i]);
             if (NS_TRACK_MISC::ValidVar($TmpArr[0]) == "NONE") {
                 $NonePoint = NS_TRACK_MISC::ValidVar($TmpArr[1], "LAST");
             }
             if (NS_TRACK_MISC::ValidVar($TmpArr[0]) == "PAID") {
                 $PaidPoint = NS_TRACK_MISC::ValidVar($TmpArr[1], "LAST");
             }
             if (NS_TRACK_MISC::ValidVar($TmpArr[0]) == "NATURAL") {
                 $NaturalPoint = NS_TRACK_MISC::ValidVar($TmpArr[1], "LAST");
             }
         }
     }
     $RequestedMode = $ClickSubId ? "PAID" : "NATURAL";
     if ($Mode == "NONE" && $NonePoint == "LAST") {
         return false;
     }
     if ($Mode == "PAID" && $PaidPoint == "LAST" && $ClickSubId) {
         return false;
     }
     if ($Mode == "NATURAL" && $NaturalPoint == "LAST" && !$ClickSubId) {
         return false;
     }
     if ($Mode == "NONE" && $NonePoint == "FIRST") {
         $NodeId = NS_TRACK_GENERAL::FindSomeNode("ANY", "FIRST");
         if ($NodeId) {
             return NS_TRACK_GENERAL::UpdateCookieLog($NodeId);
         }
         return false;
     }
     $NodeId = NS_TRACK_GENERAL::FindSomeNode($Mode, "FIRST");
     if ($NodeId) {
         return NS_TRACK_GENERAL::UpdateCookieLog($NodeId);
     }
     if ($Mode == $RequestedMode) {
         return false;
     }
     $NodeId = NS_TRACK_GENERAL::FindSomeNode($Mode == "PAID" ? "NATURAL" : "PAID", $Mode == "PAID" ? $NaturalPoint : $PaidPoint);
     if ($NodeId) {
         return NS_TRACK_GENERAL::UpdateCookieLog($NodeId);
     }
     return false;
 }