Example #1
0
function RemindPassword($Email)
{
    global $Db, $Logs, $nsProduct, $nsLang, $LangConfig, $Lang;
    $Query = "SELECT * FROM " . PFX . "_system_user WHERE EMAIL = ?";
    $User = $Db->Select($Query, false, $Email);
    if (!ValidId($User->ID)) {
        $Logs->Err($Lang['NoEmail']);
        return false;
    }
    $NewPass = substr(md5(uniqid(rand())), 0, 10);
    $Query = "UPDATE " . PFX . "_system_user SET PWD= '" . md5($NewPass) . "' WHERE ID = " . $User->ID;
    $Db->Query($Query);
    $Query = "SELECT LANG FROM " . PFX . "_system_user2lang WHERE PROD_ID=" . $nsProduct->ID . " AND UID = " . $User->ID;
    $ULang = $Db->ReturnValue($Query);
    if ($ULang && $ULang != $nsLang->CurrentLang) {
        $LConfig = $nsLang->ReturnConfig($ULang);
        $nsLang->TplInc("admin.remind", $ULang);
    } else {
        $LConfig = $LangConfig;
    }
    $Query = "SELECT FROM_EMAIL FROM " . PFX . "_tracker_config WHERE COMPANY_ID=0";
    $FromEmail = $Db->ReturnValue($Query);
    $FromEmail = $FromEmail ? $FromEmail : $Email;
    $Message = $Lang['MsgBody'];
    $Message = str_replace("{LOGIN}", $User->LOGIN, $Message);
    $Message = str_replace("{PASS}", $NewPass, $Message);
    $Message = str_replace("{LINK}", getURL("login", "", "admin"), $Message);
    $Subject = $Lang['MsgSubject'];
    $Headers = "From: {$FromEmail}\n";
    $Headers .= "Content-Type: text/plain; charset=" . $LConfig['charset'] . "\n";
    mail($Email, $Subject, $Message, $Headers);
    $Logs->Msg(str_replace("{EMAIL}", $Email, $Lang['PasswordSent']));
}
Example #2
0
function GetCampTree($ParentId = 0, $CompId = false)
{
    if (!ValidId($ParentId)) {
        return false;
    }
    global $Db, $Lang, $nsUser;
    if ($CompId) {
        $Where = " AND COMPANY_ID={$CompId} ";
    } else {
        $Where = "";
    }
    $Query = "SELECT * FROM " . PFX . "_tracker_campaign WHERE PARENT_ID = {$ParentId} AND COMPANY_ID={$CompId} ORDER BY NAME ASC";
    $Sql = new Query($Query);
    $Sql->ReadSkinConfig();
    $CampArr = array();
    while ($Row = $Sql->Row()) {
        if ($Sql->Position > 0) {
            $Row->_UP = true;
        } else {
            $Row->_UP = false;
        }
        $Row->_DOWN = true;
        $Row->NAME = stripslashes($Row->NAME);
        $Row->DESCRIPTION = stripslashes($Row->DESCRIPTION);
        $Row->_STYLE = $Sql->_STYLE;
        $SubCnt = $Db->CNT(PFX . "_tracker_campaign", "PARENT_ID=" . $Row->ID);
        $Row->CHILD_COUNT = $SubCnt > 0 ? $SubCnt : 0;
        $Row->_UPLINK = getURL("campaign", "SortId=" . $Row->ID . "&SortTo=Up&ParentId=" . $Row->PARENT_ID);
        $Row->_DOWNLINK = getURL("campaign", "SortId=" . $Row->ID . "&SortTo=Down&ParentId=" . $Row->PARENT_ID);
        if ($nsUser->Columns->ROI || $nsUser->Columns->CONVERSIONS) {
            $Row->Report = new Paid_v2();
            $Row->Report->GrpId = $Row->ID;
            $Row->Report->CpId = $Row->COMPANY_ID;
            $Row->Report->ShowPerClick = true;
            $Row->Report->ShowTotalCost = true;
            $Row->Report->DisableAll();
            if ($nsUser->Columns->ROI) {
                $Row->Report->ShowROI = true;
            }
            if ($nsUser->Columns->CONVERSIONS) {
                $Row->Report->ShowActionConv = true;
            }
            if ($nsUser->Columns->CONVERSIONS) {
                $Row->Report->ShowSaleConv = true;
            }
            $Row->Report->Calculate();
            //Dump($Row->Report);
            $Row->CampStat =& $Row->Report->CampStat;
        }
        $Row->_MOVE = true;
        $CampArr[$Sql->Position] = $Row;
        $PrevRow =& $CampArr[$Sql->Position];
    }
    $PrevRow->_DOWN = false;
    if (count($CampArr) < 1) {
        return false;
    }
    //if (count($CampArr)==1) $PrevRow->_MOVE=false;
    return $CampArr;
}
Example #3
0
function GetActions($PageId = false, $HostId = false)
{
    if (!ValidId($PageId) || !ValidId($HostId)) {
        return false;
    }
    $Actions = array();
    $Query = "SELECT * FROM " . PFX . "_tracker_visitor_action WHERE PAGE_ID = {$PageId} AND SITE_ID={$HostId}";
    $Sql = new Query($Query);
    while ($Row = $Sql->Row()) {
        $Actions[] = $Row;
    }
    if (count($Actions) > 0) {
        return $Actions;
    } else {
        return false;
    }
}
 function GetStat()
 {
     global $Logs;
     $StatArr = array();
     $GrpItems = array();
     $GrpList = "";
     $SelectStr = "";
     $JoinStr = "";
     $OrderStr = "";
     $GroupStr = "";
     $WhereStr = "";
     $StraightStr = "";
     $LimitStr = "";
     if (count($this->SelectArr) > 0) {
         $SelectStr = implode(", ", $this->SelectArr) . ", ";
     }
     if (count($this->JoinArr) > 0) {
         $JoinStr = implode(" \n", $this->JoinArr);
     }
     if (count($this->OrderArr) > 0) {
         $OrderStr = "ORDER BY " . implode(", ", $this->OrderArr);
     }
     if (count($this->GroupArr) > 0) {
         $GroupStr = "GROUP BY " . implode(", ", $this->GroupArr);
     }
     if (count($this->WhereArr) > 0) {
         $WhereStr = "WHERE " . implode(" AND ", $this->WhereArr);
     }
     if ($this->UseStraight) {
         $StraightStr = "STRAIGHT_JOIN";
     }
     ///////////////////////////////////////////
     if ($this->ShowVisitors) {
         $Query = "\n\t\t\t\tSELECT  {$StraightStr}\n\t\t\t\t\t{$SelectStr}\n\t\t\t\t\tCOUNT(S_LOG.ID) CNT,\n\t\t\t\t\tCOUNT(DISTINCT S_LOG.VISITOR_ID) UNI\n\t\t\t\t\t# выбираем точки входа из лога\n\t\t\t\t\tFROM " . PFX . "_tracker_" . $this->CpId . "_stat_log S_LOG\n\t\t\t\t\t# точки входа определяются путями по сайту\n\t\t\t\t\t# вероятно, с наличием referer set \n\t\t\t\t\t#JOIN " . PFX . "_tracker_stat_path S_PATH\n\t\t\t\t\t#\tON S_PATH.LOG_ID=S_LOG.ID\n\t\t\t\t\tINNER JOIN " . PFX . "_tracker_" . $this->CpId . "_stat_split S_SPLIT\n\t\t\t\t\t\tON S_SPLIT.LOG_ID=S_LOG.ID\n\t\t\t\t{$JoinStr}\n\t\t\t\t{$WhereStr}\n\t\t\t\t{$GroupStr}\n\t\t\t\t{$OrderStr}\n\t\t\t\t{$LimitStr}\n\t\t\t";
         //echo HLSQL($Query);
         $Sql = new Query($Query);
         while ($Row = $Sql->Row()) {
             if ($this->GrpFld) {
                 $Tmp = $this->GrpFld;
                 $Grp = $Row->{$Tmp};
             } else {
                 $Grp = $Sql->Position;
             }
             if ($this->GrpName) {
                 $Name = $this->GrpName;
                 $StatArr[$Grp]['Name'] = $Row->{$Name};
             }
             $StatArr[$Grp]['CntClick'] = $Row->CNT;
             $StatArr[$Grp]['UniClick'] = $Row->UNI;
             $StatArr[$Grp]['CntAction'] = 0;
             $StatArr[$Grp]['UniAction'] = 0;
             $StatArr[$Grp]['CntSale'] = 0;
             $StatArr[$Grp]['UniSale'] = 0;
             $StatArr[$Grp]['Income'] = 0;
             $StatArr[$Grp]['Obj'] = $Row;
             if (count($this->GroupArr)) {
                 $GrpItems[] = $Grp;
             }
         }
         if (count($GrpItems) > 0 && !ValidId($this->GroupArr[0])) {
             $GrpList = "AND " . $this->GroupArr[0] . " IN (" . implode(",", $GrpItems) . ")";
         }
     }
     ///////////////////////////////////////////
     if ($this->ShowActions) {
         $Query = "\n\t\t\t\tSELECT  {$StraightStr}\n\t\t\t\t\t{$SelectStr}\n\t\t\t\t\tCOUNT(S_LOG.ID) CNT,\n\t\t\t\t\tCOUNT(DISTINCT S_LOG.VISITOR_ID) UNI\n\t\t\t\t\t# выбираем точки входа из лога\n\t\t\t\t\tFROM " . PFX . "_tracker_" . $this->CpId . "_stat_log S_LOG\n\t\t\t\t\t# присоединяем ту ветку, которая произошла от S_LOG.ID\n\t\t\t\t\t# по принципу, что в COOKIE_LOG хранится этот самый ID\n\t\t\t\t\tINNER JOIN " . PFX . "_tracker_" . $this->CpId . "_stat_log NODE\n\t\t\t\t\t\tON NODE.COOKIE_LOG=S_LOG.ID\n\t\t\t\t\t# присоединяем таблицу действий\n\t\t\t\t\t# только к выбранным веткам\n\t\t\t\t\tINNER JOIN " . PFX . "_tracker_" . $this->CpId . "_stat_action S_ACTION\n\t\t\t\t\t\tON S_ACTION.LOG_ID=NODE.ID\n\t\t\t\t\t# точки входа определяются путями по сайту\n\t\t\t\t\t# вероятно, с наличием referer set \n\t\t\t\t\t#JOIN " . PFX . "_tracker_stat_path S_PATH\n\t\t\t\t\t#\tON S_PATH.LOG_ID=S_LOG.ID\n\t\t\t\t\tINNER JOIN " . PFX . "_tracker_" . $this->CpId . "_stat_split S_SPLIT\n\t\t\t\t\t\tON S_SPLIT.LOG_ID=S_LOG.ID\n\t\t\t\t{$JoinStr}\n\t\t\t\t{$WhereStr}\n\t\t\t\t{$GrpList}\n\t\t\t\t{$GroupStr}\n\t\t\t\t{$OrderStr}\n\t\t\t\t{$LimitStr}\n\t\t\t";
         //echo HLSQL($Query);
         $Sql = new Query($Query);
         while ($Row = $Sql->Row()) {
             if ($this->GrpFld) {
                 $Tmp = $this->GrpFld;
                 $Grp = $Row->{$Tmp};
             } else {
                 $Grp = $Sql->Position;
             }
             if (!isset($StatArr[$Grp]) && $this->ShowVisitors) {
                 continue;
             }
             if (!$this->ShowVisitors) {
                 if ($this->GrpName) {
                     $Name = $this->GrpName;
                     $StatArr[$Grp]['Name'] = $Row->{$Name};
                 }
             }
             $StatArr[$Grp]['CntAction'] = $Row->CNT;
             $StatArr[$Grp]['UniAction'] = $Row->UNI;
             $StatArr[$Grp]['Obj'] = $Row;
         }
     }
     ///////////////////////////////////////////
     if ($this->ShowSales) {
         $Query = "\n\t\t\t\tSELECT  {$StraightStr}\n\t\t\t\t\t{$SelectStr}\n\t\t\t\t\tCOUNT(S_LOG.ID) CNT,\n\t\t\t\t\tCOUNT(DISTINCT S_LOG.VISITOR_ID) UNI,\n\t\t\t\t\tSUM(S_SALE.COST) AS SALE_SUM\n\t\t\t\t\tFROM " . PFX . "_tracker_" . $this->CpId . "_stat_log S_LOG\n\t\t\t\t\tINNER JOIN " . PFX . "_tracker_" . $this->CpId . "_stat_log NODE\n\t\t\t\t\t\tON NODE.COOKIE_LOG=S_LOG.ID\n\t\t\t\t\tINNER JOIN " . PFX . "_tracker_" . $this->CpId . "_stat_sale S_SALE\n\t\t\t\t\t\tON S_SALE.LOG_ID=NODE.ID\n\t\t\t\t\t#JOIN " . PFX . "_tracker_stat_path S_PATH\n\t\t\t\t\t#\tON S_PATH.LOG_ID=S_LOG.ID\n\t\t\t\t\tINNER JOIN " . PFX . "_tracker_" . $this->CpId . "_stat_split S_SPLIT\n\t\t\t\t\t\tON S_SPLIT.LOG_ID=S_LOG.ID\n\t\t\t\t{$JoinStr}\n\t\t\t\t{$WhereStr}\n\t\t\t\t{$GrpList}\n\t\t\t\t{$GroupStr}\n\t\t\t\t{$OrderStr}\n\t\t\t\t{$LimitStr}\n\t\t\t";
         //echo HLSQL($Query);
         $Sql = new Query($Query);
         while ($Row = $Sql->Row()) {
             if ($this->GrpFld) {
                 $Tmp = $this->GrpFld;
                 $Grp = $Row->{$Tmp};
             } else {
                 $Grp = $Sql->Position;
             }
             if (!isset($StatArr[$Grp]) && $this->ShowVisitors) {
                 continue;
             }
             if (!$this->ShowVisitors) {
                 if ($this->GrpName) {
                     $Name = $this->GrpName;
                     $StatArr[$Grp]['Name'] = $Row->{$Name};
                 }
             }
             $StatArr[$Grp]['CntSale'] = $Row->CNT;
             $StatArr[$Grp]['UniSale'] = $Row->UNI;
             $StatArr[$Grp]['Income'] = $Row->SALE_SUM;
             $StatArr[$Grp]['Obj'] = $Row;
         }
     }
     foreach ($StatArr as $i => $Row) {
         if ($this->ShowActionConv) {
             $StatArr[$i]['ActionConv'] = $this->GetRatio($StatArr[$i]['UniClick'], $StatArr[$i]['UniAction']);
         }
         if ($this->ShowSaleConv) {
             $StatArr[$i]['SaleConv'] = $this->GetRatio($StatArr[$i]['UniClick'], $StatArr[$i]['UniSale']);
         }
         if (!$StatArr[$i]['Income']) {
             $StatArr[$i]['Income'] = 0;
         }
     }
     if (!ValidArr($StatArr) || count($StatArr) == 0) {
         return false;
     }
     if (count($this->GroupArr) < 1) {
         if (!isset($Grp)) {
             $Grp = 0;
         }
         return $StatArr[$Grp];
     }
     return $StatArr;
 }
Example #5
0
function GetUserQuery($Id = false)
{
    global $nsUser;
    $Query = "\n\t\tSELECT \n\t\t\tSU.*,\n\t\t\tTA.SUPER_USER, TA.ID AS MERCH_ID, TA.COMPANY_ID, TA.DEMO, \n\t\t\tUNIX_TIMESTAMP(TA.MODIFIED) AS MODIFIED,\n\t\t\tTC.NAME AS COMP_NAME,\n\t\t\tUC.HITS, UC.SALES, UC.ACTIONS, UC.CLICKS, UC.ROI, UC.CONVERSIONS, UC.GRAPHS,\n\t\t\tUS.ADVANCED_MODE, US.HELP_MODE, US.TIMEZONE, US.DEF_PATH_ORDER,\n\t\t\tUS.PAGE_ENCODING\n\t\t\tFROM " . PFX . "_system_user SU\n\t\t\t\tINNER JOIN " . PFX . "_tracker_user TA\n\t\t\t\t\tON TA.USER_ID= SU.ID\n\t\t\t\tLEFT JOIN " . PFX . "_tracker_client TC\n\t\t\t\t\tON TC.ID = TA.COMPANY_ID\n\t\t\t\tLEFT JOIN " . PFX . "_tracker_user_column UC\n\t\t\t\t\tON UC.USER_ID=SU.ID\n\t\t\t\tLEFT JOIN " . PFX . "_tracker_user_settings US\n\t\t\t\t\tON US.USER_ID=SU.ID\n\t";
    if (ValidId($Id)) {
        $Query .= "WHERE SU.ID = {$Id}";
    }
    if (!ValidId($Id) && !$nsUser->ADMIN) {
        $Query .= "WHERE TA.COMPANY_ID=" . $nsUser->COMPANY_ID;
    }
    return $Query;
}
<tr><td class=SubmitLeftTd>
</td><td class=SubmitRightTd>
<input type=submit value="<?php 
echo $Lang['Save'];
?>
">
</td></tr>

</table>
</form>


</td><td width=50% valign=top>

<?php 
if (ValidId($VisGrp->ID)) {
    ?>


<div class=ListDiv>

<table class=CaptionTable>
<tr><td class=CaptionTd>
<?php 
    echo $Lang['IpList'];
    ?>
</td></tr>
</table>


<table class=ListTable2>
Example #7
0
function UpdateHost($Id, &$Arr)
{
    global $Db, $nsProduct, $Logs, $Lang, $EditId, $nsUser;
    extract($Arr);
    if (ValidVar($UseHosts) != 1) {
        $UseHosts = 0;
    }
    if (ValidVar($ShowTitles) != 1) {
        $ShowTitles = 0;
    }
    if (!$Host) {
        $ErrArr['Host'] = $Lang['MustFill'];
    }
    $Host = ToLower($Host);
    $Check = @parse_url($Host);
    if (ValidArr($Check) && ValidVar($Check['scheme'])) {
        $Host = str_replace($Check['scheme'] . "://", "", $Host);
    }
    //$Host=str_replace("http://", "", $Host);
    //if (CheckMiscSymb($Host, "\-\.")) $ErrArr['Host']=$Lang['SymbErr'];
    if (isset($ErrArr)) {
        $Logs->Msg($Lang['FormErr']);
        $GLOBALS['ErrArr'] = $ErrArr;
        return;
    }
    $Query = "UPDATE " . PFX . "_tracker_site SET HOST = ?, USE_HOSTS='{$UseHosts}', COOKIE_DOMAIN=? WHERE ID = {$Id}";
    $Db->Query($Query, $Host, $CookieDomain);
    $CheckId = CheckSiteWatch($Id, $nsUser->UserId());
    $SiteWatch = ValidId($CheckId);
    if (ValidVar($Watch) == 1 && !$SiteWatch) {
        SetSiteWatch($Id, $nsUser->UserId());
    }
    if (ValidVar($Watch) != 1 && $SiteWatch) {
        RemoveSiteWatch($Id, $nsUser->UserId());
    }
    $nsProduct->Redir("company", "EditId={$EditId}&HostId={$Id}&RUpd=1");
}
Example #8
0
function GetUserQuery($Id = false)
{
    $Query = "\n\t\tSELECT \n\t\t\tSU.*,\n\t\t\tTA.SUPER_ADMIN, TA.ID AS AGENT_ID, TA.DEMO, \n\t\t\tUNIX_TIMESTAMP(TA.MODIFIED) AS MODIFIED,\n\t\t\tUC.HITS, UC.SALES, UC.ACTIONS, UC.CLICKS, UC.ROI, UC.CONVERSIONS, UC.GRAPHS,\n\t\t\tUS.ADVANCED_MODE, US.HELP_MODE, US.TIMEZONE, US.DEF_PATH_ORDER,\n\t\t\tUS.PAGE_ENCODING\n\t\t\tFROM " . PFX . "_tracker_admin TA\n\t\t\t\tINNER JOIN " . PFX . "_system_user SU\n\t\t\t\t\tON SU.ID = TA.USER_ID\n\t\t\t\tLEFT JOIN " . PFX . "_tracker_user_column UC\n\t\t\t\t\tON UC.USER_ID=SU.ID\n\t\t\t\tLEFT JOIN " . PFX . "_tracker_user_settings US\n\t\t\t\t\tON US.USER_ID=SU.ID\n\t";
    if (ValidId($Id)) {
        $Query .= "WHERE SU.ID = {$Id}";
    }
    return $Query;
}
	<?php 
    GetFORM(false, false, false, "ID=\"REMOVE_FORM\"");
    ?>
	<?php 
    if (count($ClientsArr > 0)) {
        ?>
		<tr>
		<input type=hidden name=DoClear value=1>
		<td><?php 
        echo $Lang['ClearStat'];
        ?>
</td>
		</tr>
		<?php 
        if (!ValidId($CurrentCompany->ID) || $CurrentCompany->SITE_CNT > 0) {
            ?>
			<tr><td>
			<?php 
            if ($nsUser->ADMIN && $nsProduct->LICENSE != 2) {
                ?>
				<select name=ForClient onchange="SwitchSites(this.value);">
				<option value="all" style="background:#d0d0d0;"><?php 
                echo $Lang['DeleteAll'];
                ?>
</option>
				<?php 
                foreach ($ClientsArr as $ClientId => $ClArr) {
                    ?>
					<option value=<?php 
                    echo $ClientId;
Example #10
0
<?php 
echo $TableCaption;
?>
</td></tr>
</table>

<table  class=FormTable>
<?php 
PostFORM(false, false, false, "ID=\"EDIT_FORM\"");
?>
<input type=hidden name="VisId" value="<?php 
echo $VisId;
?>
">
<input type=hidden name="AlreadySaved" value="<?php 
echo ValidId($Visitor->CLIENT_VIS_ID) ? "1" : "0";
?>
" Id="AlreadySaved">
<input type=hidden id="VisNewIp" name="NewIp" value="">

<tr><td class=FormLeftTd>
<?php 
echo $Lang['LastAgent'];
?>
</td><td class=FormRightTd>
<a href="<?php 
echo getURL("natural_constructor", "CpId={$CpId}&WhereArr[0][Mode]=Agent&WhereArr[0][Id]=" . $Visitor->USER_AGENT_ID . "&WhereArr[0][OrderTo]=DESC&WhereArr[0][OrderBy]=CNT&GroupBy=Vis&WhereArr[1][OrderTo]=DESC&WhereArr[1][OrderBy]=CNT&ShowAll=1", "report");
?>
" title="<?php 
echo $Lang['OtherWithAgent'];
?>
$ProgPath[1]['Url'] = getURL("incampaign", "CampId={$CampId}", "admin");
$Get = "CampId={$CampId}&";
if (isset($_GET['SortId'])) {
    $SortId = $_GET['SortId'];
}
if (isset($_GET['SortTo'])) {
    $SortTo = $_GET['SortTo'];
}
if (isset($_GET['DeleteId'])) {
    $DeleteId = $_GET['DeleteId'];
}
UserColumns();
/////////////////////////////////////////////
///////// call any process functions
if (!$nsUser->DEMO) {
    if (ValidId($SortId) && isset($SortTo)) {
        SortTable(PFX . "_tracker_camp_piece", false, $SortId, $SortTo, "CAMPAIGN_ID={$CampId}");
    }
}
$PathArr = false;
$PathArr = GrpListPath($CampId);
if (count($PathArr) > 1) {
    $PathArr = array_reverse($PathArr);
} else {
    $PathArr = false;
}
/////////////////////////////////////////////
///////// display section here
$SubMenu[0]['Name'] = $Lang['BackToCamp'];
$SubMenu[0]['Link'] = getURL("campaign");
$SubMenu[1]['Name'] = $Lang['AddNewCamp'];
Example #12
0
function UpdateAction($Arr, $Id = false)
{
    global $Db, $Logs, $nsProduct, $HostsArr, $SiteId, $CpId, $Site, $Lang;
    $TPath = "";
    $ActionPath = "";
    $CodeAction = 0;
    $SiteHostId = 0;
    extract($Arr);
    if (!ValidVar($Name)) {
        $Logs->Err($Lang['MustFillName']);
        return;
    }
    if (!ValidVar($Templ) && ValidVar($RedirOnly) != 2) {
        $Logs->Err($Lang['WhatIsAction']);
        return;
    }
    if (ValidVar($RedirOnly) == 1 && !ValidVar($RedirUrl) && !ValidVar($Dynamic)) {
        $Logs->Err($Lang['RedirUrlRequired']);
        return;
    }
    if (!ValidVar($Active)) {
        $Active = 0;
    }
    if (ValidVar($RedirOnly) == 2) {
        $CodeAction = 1;
    }
    if (!$CodeAction) {
        $TmpArr = explode("{a}", $Templ);
        if (ValidArr($TmpArr) && count($TmpArr) > 2) {
            $Logs->Err($Lang['OnlyOneActionTarget']);
            return;
        }
        $NoPage = false;
        $TArr = @parse_url($Templ);
        if (!$TArr) {
            $Logs->Err($Lang['UnableParseTemplate']);
            return;
        }
        if (isset($TArr['path']) && !isset($TArr['host'])) {
            //$Path=ToLower($TArr['path']);
            for ($i = 0; $i < count($HostsArr); $i++) {
                if (strpos($Path, $HostsArr[$i]) !== false) {
                    $Path = str_replace($HostsArr[$i], "", $Path);
                    $TArr['host'] = $HostsArr[$i];
                    $TArr['path'] = $Path;
                    break;
                }
            }
        }
        if (count($TArr) == 1 && substr(ValidVar($TArr['path']), 0, 1) != "/") {
            if (isset($TArr['path']) && !isset($TArr['query'])) {
                $TArr['query'] = $TArr['path'];
            }
            unset($TArr['path']);
            $NoPage = 1;
        }
        if (isset($TArr['fragment'])) {
            unset($TArr['fragment']);
        }
        if (!$NoPage) {
            if (!isset($TArr['host'])) {
                $TArr['host'] = $Site->HOST;
            }
            $TArr['host'] = ToLower($TArr['host']);
            //if (isset($TArr['path'])&&isset($TArr['query'])&&!isset($TArr['host'])) $TArr['host']=$Site->HOST;
            if (isset($TArr['path']) && substr($TArr['path'], 0, 1) != "/") {
                $TArr['path'] = "/" . $TArr['path'];
            }
            if (!ValidVar($TArr['host']) || !in_array($TArr['host'], $HostsArr)) {
                //$Logs->Err($Lang['InvalidDomain']);return;
                $Query = "INSERT INTO " . PFX . "_tracker_site_host (HOST, SITE_ID) VALUES (?, " . $Site->ID . ")";
                $Db->Query($Query, $TArr['host']);
                $NewHostId = $Db->LastInsertId;
                $HostsArr[] = $TArr['host'];
                $Site->Hosts[$NewHostId] = $TArr['host'];
            }
            if (!ValidVar($TArr['path'])) {
                $TArr['path'] = "/";
            }
            if (strpos($TArr['path'], "*") === false && strpos($TArr['path'], "{a}") === false && strpos($TArr['path'], ".") === false && $TArr['path'] != "/" && substr($TArr['path'], -1) != "/") {
                $TArr['path'] .= "/";
            }
            extract($TArr);
            foreach ($Site->Hosts as $SHId => $SHost) {
                if ($host == $SHost) {
                    $SiteHostId = $SHId;
                }
            }
            if (strpos($path, "*") === false && strpos($path, "{a}") === false) {
                $Query = "SELECT ID FROM " . PFX . "_tracker_site_page WHERE SITE_ID={$SiteId} AND PATH='{$path}'";
                $PageId = $Db->ReturnValue($Query);
                if (!ValidId($PageId)) {
                    $Query = "INSERT INTO " . PFX . "_tracker_site_page (SITE_ID, PATH) VALUES ({$SiteId}, '{$path}')";
                    $Db->Query($Query);
                    $PageId = $Db->LastInsertId;
                }
                $ActionPath = $path;
                if (!ValidId($PageId)) {
                    $Logs->Err($Lang['UnableCreatePage']);
                    return;
                }
            } else {
                if (ValidVar($RedirOnly)) {
                    $Logs->Err($Lang['NoRedirWithPageTemp']);
                    return;
                }
                $PageId = 0;
                $TPath = $path;
            }
            if (ValidVar($query)) {
                $query = "?" . $query;
            }
        } else {
            $PageId = 0;
            $query = $Templ;
            if (strpos($query, "?") === false || strpos($query, "?") != 0) {
                $query = "?" . $query;
            }
        }
        if (ValidVar($RedirOnly) != 1 && ValidVar($RedirOnly) != 2) {
            $RedirOnly = 0;
        }
        if (!ValidVar($RedirUrl)) {
            $RedirUrl = "";
        }
        if (!ValidVar($ItemVar)) {
            $ItemVar = "";
        }
        $RedirUrl = urlencode($RedirUrl);
        $LogInfo = "";
    } else {
        $PageId = 0;
        $query = "";
        $RedirUrl = "";
        $TPath = "";
        $ItemVar = "";
        $RedirOnly = 0;
    }
    if (!$Id) {
        $Query = "INSERT INTO " . PFX . "_tracker_visitor_action (SITE_ID, PAGE_ID, NAME, QUERY, PATH, REDIRECT_URL, REDIRECT_CATCH, ITEM_VAR, ACTIVE, CODE_ACTION, SITE_HOST_ID) VALUES ({$SiteId}, {$PageId}, '{$Name}', '{$query}', '{$TPath}', '{$RedirUrl}', '{$RedirOnly}', '{$ItemVar}', '{$Active}', '{$CodeAction}', '{$SiteHostId}')";
        $Db->Query($Query);
        $EditId = $Db->LastInsertId;
        $LogInfo = "&RCrt=1";
    } else {
        $Query = "UPDATE " . PFX . "_tracker_visitor_action SET PAGE_ID={$PageId}, NAME='{$Name}', QUERY='{$query}', PATH='{$TPath}', REDIRECT_URL='{$RedirUrl}', REDIRECT_CATCH='{$RedirOnly}', ITEM_VAR='{$ItemVar}', ACTIVE='{$Active}', CODE_ACTION='{$CodeAction}', SITE_HOST_ID='{$SiteHostId}' WHERE ID = {$Id} AND SITE_ID={$SiteId}";
        $Db->Query($Query);
        $EditId = $Id;
        $LogInfo = "&RUpd=1";
    }
    $WrRes = true;
    $WrErr = false;
    if (!$CodeAction) {
        $UseStore = $Db->ReturnValue("SELECT USE_STORE FROM " . PFX . "_tracker_config WHERE COMPANY_ID=0");
        if ($RedirOnly && $UseStore) {
            $ActionArr['ID'] = $EditId;
            $ActionArr['PAGE_ID'] = $PageId;
            $ActionArr['SITE_ID'] = $SiteId;
            $ActionArr['REDIRECT_URL'] = $RedirUrl;
            $ActionArr['PATH'] = $ActionPath;
            $WrRes = false;
            $WrRes = SaveActionToFile($ActionArr, "redir_action.nodb");
            //if (!$WrRes) $WrErr="&WrErr=1";
        }
    }
    $nsProduct->Redir("actions", "CpId={$CpId}&SiteId={$SiteId}&EditId={$EditId}" . $WrErr . $LogInfo);
}
Example #13
0
//// new campaign
if (isset($EditId) && $EditId == "new") {
    if (!isset($EditArr)) {
        $EditArr['Name'] = "";
        $EditArr['Descr'] = "";
        $EditArr['Company'] = 0;
    }
    $EditArr['Name'] = htmlspecialchars($EditArr['Name']);
    $EditArr['Descr'] = htmlspecialchars($EditArr['Descr']);
    if (!isset($ParentId) || !ValidId($ParentId)) {
        $ParentId = 0;
    }
    $TableCaption = $Lang['CaptionNew'];
    $SubMenu[0]['Name'] = $Lang['BackToList'];
    $SubMenu[0]['Link'] = getURL("campaign");
    if (!ValidId($CompId)) {
        $CompArr = GetCompanies();
        $SelectComp = true;
    } else {
        $SelectComp = false;
    }
    include $nsTemplate->Inc("admin.campaign_edit");
}
/////////////////////////////////////////////
///////// process functions here
function CreateCampaign(&$Arr, $ParentId = false)
{
    global $Db, $Lang, $nsProduct, $Logs, $CompId;
    extract($Arr);
    if (!$Name) {
        $ErrArr['Name'] = $Lang['MustFill'];

<tr><td class=FormLeftTd>
<?php 
echo $Lang['BoundHosts'];
?>
</td><td class=FormRightTd>
<input type=checkbox name="EditArr[UseHosts]" value=1 <?php 
echo $EditArr['UseHosts'] == 1 ? "checked" : "";
?>
>
</td></tr>


<?php 
if (ValidId($EditId) && $nsUser->ADMIN) {
    ?>
<tr><td class=FormLeftTd>
<?php 
    echo $Lang['StShow1stPage'];
    ?>
</td><td class=FormRightTd>
<input type=checkbox name="EditArr[Watch]" value=1 <?php 
    echo $EditArr['Watch'] == 1 ? "checked" : "";
    ?>
>
</td></tr>
<?php 
}
?>
function CheckKeyword($Keyword = false)
{
    if (!$Keyword) {
        return false;
    }
    global $Db;
    $Keyword = addslashes($Keyword);
    $Query = "SELECT ID FROM " . PFX . "_tracker_keyword WHERE KEYWORD = '{$Keyword}'";
    $CheckId = $Db->ReturnValue($Query);
    if (ValidId($CheckId)) {
        return $CheckId;
    }
    $Query = "INSERT INTO " . PFX . "_tracker_keyword (KEYWORD) VALUES ('{$Keyword}')";
    $Db->Query($Query);
    return $Db->LastInsertId;
}
Example #16
0
<tr><td class=SubmitLeftTd>
</td><td class=SubmitRightTd>
<input type=submit value="<?php 
echo $Lang['Save'];
?>
">
</td></tr>
</table>

</form>




<?php 
if (ValidId($EditId) && count($MoveArr) > 0) {
    include $nsTemplate->Inc("inc/move_camp_piece");
}
?>


</td>
<td><p><IMG SRC="<?php 
echo FileLink("images/0.gif");
?>
" WIDTH="10" HEIGHT="1" BORDER="0" ALT=""></p></td>
<td width=50% valign=top>

<?php 
if ($ShowCosts) {
    ?>
Example #17
0
function GetCurrentCompany($Id = false)
{
    if (!ValidId($Id)) {
        return false;
    }
    global $Db, $nsUser, $nsProduct;
    $Company = $Db->Select("SELECT * FROM " . PFX . "_tracker_client WHERE ID = {$Id}");
    if (!$Company) {
        $nsUser->SetCookie("CompId", '', time() - 1000, "/");
        $nsProduct->Redir("default", "", "admin");
    }
    $Company->SITE_CNT = $Db->ReturnValue("SELECT COUNT(*) FROM " . PFX . "_tracker_site WHERE COMPANY_ID={$Id}");
    $Company->CUR[0] = $Company->CURRENCY;
    $Company->CUR[1] = $Company->CURRENCY_POSITION;
    return $Company;
}
    if (ValidArr($AddToMy) && $Mode == "actions") {
        AddToMy($AddToMy, "ACTION_ID");
    }
    if (ValidId($MyDeleteId) && $Mode == "actions") {
        DeleteFromMy($MyDeleteId, "ACTION_ID");
    }
    if (ValidArr($AddToMy) && $Mode == "action_items") {
        AddToMy($AddToMy, "ACTION_ITEM_ID");
    }
    if (ValidId($MyDeleteId) && $Mode == "action_items") {
        DeleteFromMy($MyDeleteId, "ACTION_ITEM_ID");
    }
    if (ValidArr($AddToMy) && $Mode == "sale_items") {
        AddToMy($AddToMy, "SALE_ITEM_ID");
    }
    if (ValidId($MyDeleteId) && $Mode == "sale_items") {
        DeleteFromMy($MyDeleteId, "SALE_ITEM_ID");
    }
}
/////////////////////////////////////////////
///////// display section here
///////////////////////
if ($Mode == "list") {
    $Query = "\n\t\tSELECT UR.*, C.NAME AS COMP_NAME\n\t\tFROM " . PFX . "_tracker_watch W\n\t\tINNER JOIN  " . PFX . "_tracker_user_report UR\n\t\t\tON UR.ID=W.REPORT_ID\n\t\tINNER JOIN " . PFX . "_tracker_client C\n\t\t\tON C.ID=UR.COMPANY_ID\n\t\tWHERE W.USER_ID=" . $nsUser->UserId() . " \n\t\tORDER BY C.NAME, UR.NAME\n\t";
    $Sql = new Query($Query);
    $Sql->ReadSkinConfig();
    $UserReports = array();
    while ($Row = $Sql->Row()) {
        $Row->_STYLE = $Sql->_STYLE;
        $Row->NAME = stripslashes($Row->NAME);
        if ($Row->CONST_TYPE == "NATURAL") {
Example #19
0
function DeleteSplit($CpId, $Id, $NoRedir = false)
{
    global $Db, $Logs, $nsProduct, $Lang, $CompId, $GrpId;
    $SplitId = $Db->ReturnValue("SELECT ID FROM " . PFX . "_tracker_split_test WHERE SUB_ID={$Id}");
    $Query = "DELETE FROM " . PFX . "_tracker_camp_piece WHERE ID = {$Id}";
    $Db->Query($Query);
    $Query = "DELETE FROM " . PFX . "_tracker_split_test WHERE SUB_ID = {$Id}";
    $Db->Query($Query);
    $Query = "DELETE FROM " . PFX . "_tracker_split_page WHERE SPLIT_ID = {$SplitId}";
    $Db->Query($Query);
    DeleteSplitStat($CpId, $Id);
    if (!$NoRedir && !$GrpId) {
        $nsProduct->Redir("split_list", "CompId={$CompId}&RDlt=1");
    }
    if (!$NoRedir && ValidId($GrpId) && $GrpId > 0) {
        $nsProduct->Redir("incampaign", "CampId={$GrpId}&RDlt=1");
    }
}
<?php 
    for ($i = 0; $i < count($SaleItemsList); $i++) {
        $Row = $SaleItemsList[$i];
        ?>

	<tr>
	<td class=<?php 
        echo $Row->_STYLE;
        ?>
>
	<table width=100% cellpadding=0 cellspacing=0 border=0>
	<tr>

	<td width=25 nowrap>
	<?php 
        if (!ValidId($Row->WATCH_ID)) {
            ?>
		<input type=checkbox value=1 name="AddToMy[<?php 
            echo $Row->ID;
            ?>
]">
	<?php 
        }
        ?>
	</td>

	<td >
	<B style="color:#000000"><?php 
        echo $Row->NAME;
        ?>
</B>
}
if (ValidId($GrpId)) {
    $WhereArr[0]['Mode'] = "Grp";
    $WhereArr[0]['Id'] = $GrpId;
    $WhereArr[0]['OrderBy'] = "CNT";
    $WhereArr[0]['OrderTo'] = "DESC";
    $Query = "\n\t\tSELECT C.COMPANY_ID\n\t\t\tFROM " . PFX . "_tracker_campaign C\n\t\t\tWHERE C.ID={$GrpId}\n\t";
    $CpId = $Db->ReturnValue($Query);
}
if (!ValidId($CpId) && !$nsUser->ADMIN) {
    $nsProduct->Redir("default", "", "admin");
}
if ($CpId) {
    $Client = GetCompany($CpId);
}
if (!ValidId($Client->ID) && !$nsUser->ADMIN) {
    $nsProduct->Redir("default", "", "admin");
}
if (!$CpId) {
    $CpId = 0;
}
$GroupByForm = array();
$WhereForm = array();
UserColumns();
$Report = new Paid_v2();
if ($nsUser->Columns->CLICKS) {
    $Report->ShowVisitors = true;
}
if ($nsUser->Columns->ACTIONS) {
    $Report->ShowActions = true;
}
        $EditArr['Name'] = "";
        $EditArr['Ban'] = 0;
        $EditArr['Regular'] = "";
        $EditArr['Regular2'] = "";
    }
    if (!ValidVar($EditArr['Ban'])) {
        $EditArr['Ban'] = 0;
    }
    $TableCaption = $Lang['CaptionNew'];
    $SubMenu[0]['Name'] = $Lang['BackToList'];
    $SubMenu[0]['Link'] = getURL("user_agent");
    $PageTitle = $Lang['AddNewGrp'];
    include $nsTemplate->Inc("admin.agent_grp");
}
//// edit grp
if ($Mode == "Grp" && ValidId($EditId)) {
    $Query = "SELECT * FROM " . PFX . "_tracker_visitor_agent_grp WHERE ID = {$EditId}";
    $EditGrp = $Db->Select($Query);
    $ProgPath[2]['Name'] = $EditGrp->NAME;
    $ProgPath[2]['Url'] = getURL("user_agent", "Mode=Grp&EditId={$EditId}", "admin");
    if (!ValidArr($EditArr)) {
        $EditArr['Name'] = $EditGrp->NAME;
        $EditArr['Ban'] = $EditGrp->BAN;
        $EditArr['Regular'] = $EditGrp->REGULAR_EXPRESSION;
        $EditArr['Regular2'] = $EditGrp->REGULAR_EXPRESSION2;
    }
    if (!ValidVar($EditArr['Ban'])) {
        $EditArr['Ban'] = 0;
    }
    $TableCaption = $Lang['CaptionEdit'] . $EditGrp->NAME;
    $PageTitle = $EditGrp->NAME;
    include $nsTemplate->Inc("inc/move_camp_piece");
}
?>


</td>
<td width=10><p><IMG SRC="<?php 
echo FileLink("images/0.gif");
?>
" WIDTH="10" HEIGHT="1" BORDER="0" ALT=""></p></td>

<td width=50% valign=top>


<?php 
if (ValidId($SplitTest->ID)) {
    ?>


<table class=CaptionTable>
<tr><td class=CaptionTd>
<?php 
    echo $Lang['PagesList'];
    ?>
</td></tr>
</table>
<div class=ListDiv2>

<?php 
    if (ValidArr($PagesArr)) {
        ?>
Example #24
0
" width="9" height="27" border="0"></p>
		</td></tr>
		</table>
	</td>

	<?php 
    }
}
?>
	
<table width=100% cellpadding=0 cellspacing=0 border=0 height=27>
<tr>


<?php 
if (ValidId($CompId)) {
    MenuTab($Lang['MPaidAdv'], getURL("paid_constructor", "CpId={$CompId}", "report"), $nsProduct->Action == "paid_constructor" ? true : false, "stat", 8, 8);
    MenuTab($Lang['MNatural'], getURL("natural_constructor", "CpId={$CompId}", "report"), $nsProduct->Action == "natural_constructor" ? true : false, "stat", 8, 8);
    MenuTab($Lang['MLogs'], getURL("reports", "CpId={$CompId}", "admin"), ValidVar($MenuSection) == "logs" ? true : false, "logs", 11, 9);
    MenuTab($Lang['MCampaign'], getURL("campaign", "CpId={$CompId}", "admin"), $nsProduct->Action == "campaign" || $nsProduct->Action == "incampaign" || $nsProduct->Action == "sub_camp" || $nsProduct->Action == "campaign_link" ? true : false, "campaign", 8, 7);
    MenuTab($Lang['MActions'], getURL("actions", "CpId={$CompId}", "admin"), $nsProduct->Action == "actions" ? true : false, "actions", 4, 8);
    MenuTab($Lang['MSplits'], getURL("split_list", "", "admin"), ValidVar($MenuSection) == "split_test" ? true : false, "split", 13, 8);
    if ($nsUser->ADMIN || $nsUser->SUPER_USER) {
        MenuTab($Lang['MSettings'], getURL("settings", "CpId={$CompId}", "admin"), ValidVar($MenuSection) == "settings" ? true : false, "settings", 9, 9);
    }
    if (isset($AdditionalTabs)) {
        for ($i = 0; $i < count($AdditionalTabs); $i++) {
            $Row = $AdditionalTabs[$i];
            if (ValidVar($Row['Permit'])) {
                if ($Row['Permit'] == "superuser" && !$nsUser->SUPER_USER) {
                    continue;
Example #25
0
    $Comp = $Db->Select($Query);
    $PageTitle = $Comp->NAME;
    $Query = "SELECT ID, HOST FROM " . PFX . "_tracker_site WHERE COMPANY_ID={$CpId}";
    $Sql = new Query($Query);
    while ($Row = $Sql->Row()) {
        $SitesArr[] = $Row;
    }
    if (Count($SitesArr) == 1) {
        $SiteId = $SitesArr[0]->ID;
    }
}
if (ValidId($SiteId)) {
    $Query = "SELECT * FROM " . PFX . "_tracker_site WHERE ID = {$SiteId}";
    $Site = $Db->Select($Query);
    $PageTitle = $Site->HOST;
    $SiteList = $SiteId;
    if (!ValidId($CpId)) {
        $CompId = $CpId = $Site->COMPANY_ID;
    }
}
$PageTitle .= " : " . $Lang['Reports'];
$CompId = ValidId($Comp->ID) ? $Comp->ID : $Site->COMPANY_ID;
/////////////////////////////////////////////
///////// call any process functions
/////////////////////////////////////////////
///////// display section here
include $nsTemplate->Inc();
/////////////////////////////////////////////
///////// process functions here
/////////////////////////////////////////////
///////// library section
Example #26
0
function SetParam($Name, $Type, $Value, $Plg = false)
{
    global $Db, $nsProduct;
    if (!$Type) {
        return false;
    }
    if ($Type != "INTVAL" && $Type != "STRVAL" && $Type != "MEMO") {
        return false;
    }
    $Prd = $nsProduct->ID > 0 ? $nsProduct->ID : "0";
    if (!$Plg || !ValidId($Plg)) {
        $Plg = 0;
    }
    $Query = "SELECT ID FROM " . PFX . "_system_config WHERE PRODUCT_ID={$Prd} AND PLUGIN_ID={$Plg} AND CALLNAME='{$Name}'";
    $Id = $Db->ReturnValue($Query);
    $Name = ereg_replace("[^[:alnum:]_]", "", $Name);
    $Name = addslashes($Name);
    $Value = addslashes($Value);
    if (ValidId($Id)) {
        $Query = "UPDATE " . PFX . "_system_config SET {$Type} = '{$Value}', DATATYPE = '{$Type}' WHERE PRODUCT_ID={$Prd} AND PLUGIN_ID={$Plg} AND CALLNAME='{$Name}'";
    } else {
        $Query = "INSERT INTO " . PFX . "_system_config (PRODUCT_ID, PLUGIN_ID, CALLNAME, DATATYPE, {$Type}) VALUES ({$Prd}, {$Plg}, '{$Name}', '{$Type}', '{$Value}')";
    }
    $Db->Query($Query);
}
DrawPie($SizePie, $Lang['ActionStat'], $ActionsSize, "339933", 1);
DrawPie($SizePie, $Lang['SaleStat'], $SalesSize, "CC6600", 2);
DrawPie($SizePie, $Lang['SplitStat'], $SplitSize, "FF0099", 3);
DrawPie($SizePie, $Lang['CampStat'], $CampSize, "9999FF", 4);
DrawPie($SizePie, $Lang['UndefStat'], $UndefSize, "FFFF00", 5);
DrawPie($SizePie, $Lang['OtherTables'], $OtherSize, "FF0000", 6);
$MinTable = false;
$MaxTable = false;
$MinStamp = 0;
$MaxStamp = 0;
$MinId = 0;
$MaxId = 0;
for ($i = 0; $i < count($StatLogArr); $i++) {
    $Query = "SELECT MIN(ID) AS MIN_ID, MAX(ID) AS MAX_ID FROM " . $StatLogArr[$i];
    $MM = $Db->Select($Query);
    if (ValidId($MM->MIN_ID) && $MM->MIN_ID > 0) {
        $MM->MIN_STAMP = $Db->ReturnValue("SELECT UNIX_TIMESTAMP(STAMP) FROM " . $StatLogArr[$i] . " WHERE ID=" . $MM->MIN_ID);
        $MM->MAX_STAMP = $Db->ReturnValue("SELECT UNIX_TIMESTAMP(STAMP) FROM " . $StatLogArr[$i] . " WHERE ID=" . $MM->MAX_ID);
        if ($MinStamp > $MM->MIN_STAMP || $MinStamp == 0) {
            $MinStamp = $MM->MIN_STAMP;
            $MinTable = $StatLogArr[$i];
            $MinId = $MM->MIN_ID;
        }
        if ($MaxStamp < $MM->MAX_STAMP || $MaxStamp == 0) {
            $MaxStamp = $MM->MAX_STAMP;
            $MaxTable = $StatLogArr[$i];
            $MaxId = $MM->MAX_ID;
        }
    }
}
$MinDays = $MaxDays = false;
function SaveReport($SaveArr, $WhereArr)
{
    global $Db, $Logs, $nsUser, $nsProduct, $NaturalConstPath, $PaidConstPath, $Lang;
    if (ValidVar($SaveArr['SaveMode']) == "NATURAL") {
        $OrderConstPath = $NaturalConstPath;
        $ConstPath = "natural_constructor";
    }
    if (ValidVar($SaveArr['SaveMode']) == "PAID") {
        $OrderConstPath = $PaidConstPath;
        $ConstPath = "paid_constructor";
    }
    if (!ValidVar($SaveArr['Name'])) {
        $Logs->Err($Lang['NameMustFill']);
        return;
    }
    if (ValidVar($SaveArr['SaveMode']) != "NATURAL" && ValidVar($SaveArr['SaveMode']) != "PAID") {
        $Logs->Err($Lang['SaveErr1']);
        return;
    }
    if (!ValidVar($SaveArr['GroupBy'])) {
        $Logs->Err($Lang['SaveErr1']);
        return;
    }
    foreach ($WhereArr as $i => $Row) {
        if (!isset($OrderConstPath[$Row['Mode']])) {
            $Logs->Err($Lang['SaveErr1']);
            return;
        }
    }
    if (ValidVar($SaveArr['ViewDate']) && !ValidDate($SaveArr['ViewDate']) || ValidVar($SaveArr['StartDate']) && !ValidDate($SaveArr['StartDate']) || ValidVar($SaveArr['EndDate']) && !ValidDate($SaveArr['EndDate'])) {
        $Logs->Err($Lang['ValidDates']);
        return;
    }
    $WhereArrStr = serialize($WhereArr);
    $CurrentDate = ValidVar($SaveArr['CurrentDate']) ? $SaveArr['CurrentDate'] : 0;
    $SaveMode = ValidVar($SaveArr['SaveMode']) ? $SaveArr['SaveMode'] : 0;
    $CpId = ValidVar($SaveArr['CpId']) ? $SaveArr['CpId'] : 0;
    $GroupBy = ValidVar($SaveArr['GroupBy']) ? $SaveArr['GroupBy'] : false;
    $DatesUsed = ValidVar($SaveArr['DatesUsed']) ? $SaveArr['DatesUsed'] : false;
    $ViewDate = ValidVar($SaveArr['ViewDate']) ? $SaveArr['ViewDate'] : false;
    $StartDate = ValidVar($SaveArr['StartDate']) ? $SaveArr['StartDate'] : false;
    $EndDate = ValidVar($SaveArr['EndDate']) ? $SaveArr['EndDate'] : false;
    $Filter = ValidVar($SaveArr['Filter']) ? $SaveArr['Filter'] : false;
    $Limit = ValidId($SaveArr['Limit']) ? $SaveArr['Limit'] : 0;
    $ShowAll = ValidVar($SaveArr['ShowAll']) ? $SaveArr['ShowAll'] : 0;
    $OrderBy = ValidVar($SaveArr['OrderBy']) ? $SaveArr['OrderBy'] : false;
    $OrderTo = ValidVar($SaveArr['OrderTo']) ? $SaveArr['OrderTo'] : "ASC";
    $Name = ValidVar($SaveArr['Name']) ? addslashes($SaveArr['Name']) : false;
    $UserId = $nsUser->UserId();
    $AddToMy = ValidVar($SaveArr['AddToMy']) ? $SaveArr['AddToMy'] : false;
    $Query = "\n\t\tINSERT INTO " . PFX . "_tracker_user_report \n\t\t\t(CONST_TYPE, COMPANY_ID, NAME, VIEW_DATE, START_DATE, END_DATE, FILTER, PAGE_LIMIT, SHOW_NO_REF, SORT_BY, SORT_ORDER, USE_CURRENT_DATE, GROUP_BY, WHERE_ARR)\n\t\t\tVALUES \n\t\t\t('{$SaveMode}', {$CpId}, '{$Name}', '{$ViewDate}', '{$StartDate}', '{$EndDate}', '{$Filter}', {$Limit}, '{$ShowAll}', '{$OrderBy}', '{$OrderTo}', '{$CurrentDate}', '{$GroupBy}', '{$WhereArrStr}')\n\t\t";
    $Db->Query($Query);
    $NewId = $Db->LastInsertId;
    if ($AddToMy) {
        $Query = "INSERT INTO " . PFX . "_tracker_watch (USER_ID, REPORT_ID) VALUES ({$UserId}, {$NewId})";
        $Db->Query($Query);
    }
    $nsProduct->Redir($ConstPath, "RUpd=1&ConstId={$NewId}&CpId=" . ValidVar($SaveArr['CpId']), "report");
}
    $Report->SelectArr[] = "RS.REFERER_ID";
    $Report->SelectArr[] = "R.REFERER AS NAME";
    $Report->JoinArr[] = "INNER JOIN " . PFX . "_tracker_referer R ON R.ID=RS.REFERER_ID";
    $Report->GroupArr[] = "RS.REFERER_ID";
    $Report->GrpFld = "REFERER_ID";
    $Report->GrpName = "NAME";
    $Report->OrderArr[] = "{$DefaultOrderBy} {$OrderTo}";
    if (ValidVar($Filter)) {
        $Report->WhereArr[] = "R.REFERER LIKE ('%{$Filter}%')";
    }
}
if (ValidVar($GroupBy) == "Source") {
    $Report->RsNeeded = true;
    $Report->SelectArr[] = "TH.ID";
    $Report->SelectArr[] = "TH.HOST AS NAME";
    if (!ValidId($Report->HostGrp)) {
        $Report->JoinArr[] = "INNER JOIN " . PFX . "_tracker_host TH ON TH.ID=RS.HOST_ID";
    }
    $Report->GroupArr[] = "TH.ID";
    $Report->GrpFld = "ID";
    $Report->GrpName = "NAME";
    $Report->OrderArr[] = "{$DefaultOrderBy} {$OrderTo}";
    if (ValidVar($Filter)) {
        $Report->WhereArr[] = "TH.HOST LIKE ('%{$Filter}%')";
    }
}
if (ValidVar($GroupBy) == "SourceGrp") {
    $Report->RsNeeded = true;
    $Report->SelectArr[] = "TH.GRP_ID";
    $Report->SelectArr[] = "HG.NAME";
    $Report->JoinArr[] = "INNER JOIN " . PFX . "_tracker_host TH ON TH.ID=RS.HOST_ID";
     }
 }
 if ($WhereArr[$i]['Mode'] == "Page") {
     $WhereArr[$i]['Name'] = $Lang['ByPage'];
     $MetaTitle .= ": " . $Lang['ByPage'];
     if (ValidId($WhereArr[$i]['Id'])) {
         //$Report->ByPage=true;
         $WhereArr[$i]['Name2'] = $Db->ReturnValue("SELECT PATH FROM " . PFX . "_tracker_site_page WHERE ID = " . $WhereArr[$i]['Id']);
         $MetaTitle .= ": " . $WhereArr[$i]['Name2'];
         $Report->WhereArr[] = "S_LOG.PAGE_ID=" . $WhereArr[$i]['Id'];
     }
 }
 if ($WhereArr[$i]['Mode'] == "Country") {
     $WhereArr[$i]['Name'] = $Lang['ByCountry'];
     $MetaTitle .= ": " . $Lang['ByCountry'];
     if (ValidId($WhereArr[$i]['Id'])) {
         $WhereArr[$i]['Name2'] = $Db->ReturnValue("SELECT NAME FROM " . PFX . "_tracker_country WHERE ID = " . $WhereArr[$i]['Id']);
         $MetaTitle .= ": " . $WhereArr[$i]['Name2'];
         $Report->WhereArr[] = "V.FIRST_COUNTRY_ID=" . $WhereArr[$i]['Id'];
         $Report->JoinArr[] = "INNER JOIN " . PFX . "_tracker_visitor V ON V.ID=S_LOG.VISITOR_ID";
     }
 }
 if ($WhereArr[$i]['Mode'] == "Resolution") {
     $WhereArr[$i]['Name'] = $Lang['ByResolution'];
     $MetaTitle .= ": " . $Lang['ByResolution'];
     if (ValidVar($WhereArr[$i]['Id'])) {
         $WhereArr[$i]['Name2'] = $WhereArr[$i]['Id'] != "-1" ? $WhereArr[$i]['Id'] : $Lang['Undefined'];
         $MetaTitle .= ": " . ($WhereArr[$i]['Id'] != "-1" ? $WhereArr[$i]['Id'] : $Lang['Undefined']);
         $Report->WhereArr[] = "V.LAST_RESOLUTION='" . $WhereArr[$i]['Id'] . "'";
         $Report->JoinArr[] = "INNER JOIN " . PFX . "_tracker_visitor V ON V.ID=S_LOG.VISITOR_ID";
     }