function ClearStat($EndTime = false, $CpId = false, $SiteId = false)
{
    global $Logs, $Db, $Lang;
    if ($SiteId) {
        $Query = "SELECT MIN(S_LOG.STAMP) FROM " . PFX . "_tracker_" . $CpId . "_stat_log S_LOG WHERE S_LOG.SITE_ID={$SiteId}";
        $StartTime = $Db->ReturnValue($Query);
        DeleteSiteStat($CpId, $SiteId, $StartTime, $EndTime);
    }
    if ($CpId && !$SiteId) {
        $Query = "SELECT MIN(S_LOG.STAMP) FROM " . PFX . "_tracker_" . $CpId . "_stat_log S_LOG INNER JOIN " . PFX . "_tracker_site S ON S.ID=S_LOG.SITE_ID WHERE S.COMPANY_ID={$CpId}";
        $StartTime = $Db->ReturnValue($Query);
        global $ClientsArr;
        if (ValidArr($ClientsArr[$CpId]['Sites']) && count($ClientsArr[$CpId]['Sites']) > 0) {
            foreach ($ClientsArr[$CpId]['Sites'] as $SiteId => $Name) {
                DeleteSiteStat($CpId, $SiteId, $StartTime, $EndTime);
            }
        }
    }
    if (!$CpId && !$SiteId) {
        $Query = "SELECT ID, COMPANY_ID FROM " . PFX . "_tracker_site";
        $Sql = new Query($Query);
        while ($Row = $Sql->Row()) {
            $Query = "SELECT MIN(S_LOG.STAMP) FROM " . PFX . "_tracker_" . $Row->COMPANY_ID . "_stat_log S_LOG";
            $StartTime = $Db->ReturnValue($Query);
            DeleteSiteStat($Row->COMPANY_ID, $Row->ID, $StartTime, $EndTime);
        }
    }
    $Logs->Msg($Lang['StatDeleted']);
}
Example #2
0
function DeleteHost($CpId, $Id, $NoDelStat = false, $NoRedir = false)
{
    global $Db, $nsUser, $nsProduct;
    if (!$NoDelStat) {
        DeleteSiteStat($CpId, $Id);
    }
    $Query = "DELETE FROM " . PFX . "_tracker_site WHERE ID = {$Id}";
    $Db->Query($Query);
    $Query = "DELETE FROM " . PFX . "_tracker_site_host WHERE SITE_ID={$Id}";
    $Db->Query($Query);
    $Query = "DELETE FROM " . PFX . "_tracker_site_page WHERE SITE_ID={$Id}";
    $Db->Query($Query);
    $Query = "DELETE FROM " . PFX . "_tracker_visitor_action WHERE SITE_ID={$Id}";
    $Db->Query($Query);
    $Query = "DELETE FROM " . PFX . "_tracker_watch WHERE SITE_ID={$Id}";
    $Db->Query($Query);
    if (!$NoRedir) {
        $nsProduct->Redir("company", "EditId={$CpId}&RDlt=1", "admin");
    }
}