• Модуль: statistic
  • Путь к файлу: ~/bitrix/modules/statistic/classes/general/keepstatistic.php
  • Класс: CKeepStatistics
  • Вызов: CKeepStatistics::GetRefererListID
static function GetRefererListID($PROT, $SN, $PAGE_FROM, $CURRENT_URI, $ERROR_404, $sql_site)
{
	$DB = CDatabase::GetModuleConnection('statistic');
	$DB_now = $DB->GetNowFunction();

	// ID of the referer
	$rsReferer = $DB->Query("
		SELECT ID
		FROM b_stat_referer
		WHERE SITE_NAME = '".$DB->ForSql($SN, 255)."'
	", false, "File: ".__FILE__."
Line: ".__LINE__); $arReferer = $rsReferer->Fetch(); if($arReferer) { // update session counter $DB->Update( "b_stat_referer", array("SESSIONS" => "SESSIONS + 1"), "WHERE ID=".$arReferer["ID"], "File: ".__FILE__."
Line: ".__LINE__, false, false, false ); $_SESSION["SESS_REFERER_ID"] = intval($arReferer["ID"]); } else { // add new one $arFields = array( "DATE_FIRST" => $DB_now, "DATE_LAST" => $DB_now, "SITE_NAME" => "'".$DB->ForSql($SN, 255)."'", "SESSIONS" => 1, ); $_SESSION["SESS_REFERER_ID"] = intval($DB->Insert("b_stat_referer", $arFields, "File: ".__FILE__."
Line: ".__LINE__)); } // save referring fact to database $arFields = array( "DATE_HIT" => $DB_now, "REFERER_ID" => $_SESSION["SESS_REFERER_ID"], "PROTOCOL" => "'".$DB->ForSql($PROT, 10)."'", "SITE_NAME" => "'".$DB->ForSql($SN, 255)."'", "URL_FROM" => "'".$DB->ForSql($PAGE_FROM, 2000)."'", "URL_TO" => "'".$DB->ForSql($CURRENT_URI, 2000)."'", "URL_TO_404" => "'".$ERROR_404."'", "SESSION_ID" => intval($_SESSION["SESS_SESSION_ID"]), "ADV_ID" => intval($_SESSION["SESS_ADV_ID"]), "SITE_ID" => $sql_site, ); $REFERER_LIST_ID = intval($DB->Insert("b_stat_referer_list", $arFields, "File: ".__FILE__."
Line: ".__LINE__)); if($ERROR_404=="N") { CStatistics::Set404("b_stat_referer_list", "ID = ".$REFERER_LIST_ID, array("URL_TO_404" => "Y")); } return $REFERER_LIST_ID; }