- Модуль: statistic
- Путь к файлу: ~/bitrix/modules/statistic/classes/mysql/statistic.php
- Класс: CStatistics
- Вызов: CStatistics::CleanUpReferer
static function CleanUpReferer()
{
set_time_limit(0);
ignore_user_abort(true);
$err_mess = "File: ".__FILE__."
Line: ";
$DB = CDatabase::GetModuleConnection('statistic');
$DAYS = COption::GetOptionString("statistic", "REFERER_DAYS");
$TOP = COption::GetOptionString("statistic", "REFERER_TOP");
$DAYS = intval($DAYS);
if ($DAYS>=0)
{
$strSql = "SELECT ID FROM b_stat_referer ORDER BY SESSIONS desc LIMIT ".intval($TOP);
$z = $DB->Query($strSql,false,$err_mess.__LINE__);
$str = "0";
while ($zr=$z->Fetch()) $str .= ",".$zr["ID"];
$strSql = "
DELETE FROM b_stat_referer
WHERE
(DATE_LAST <= DATE_SUB(CURDATE(),INTERVAL $DAYS DAY)
OR DATE_LAST is null)
and ID not in ($str)
";
$DB->Query($strSql, false, $err_mess.__LINE__);
if (COption::GetOptionString("statistic", "USE_AUTO_OPTIMIZE")=="Y")
{
$DB->Query("OPTIMIZE TABLE b_stat_referer", false, $err_mess.__LINE__);
}
}
}