public static function GetList($arSort=array(), $arFilter=array(), $arNavParams=false, $arUserField)
	{
		$rs = false;

		if(\CModule::IncludeModule("statistic"))
		{
			$arAliases = array("ID" => "CITY_ID", "NAME" => "CITY_NAME");

			$ob = new \CCity();
			$rs = new CUserTypeLocationEnum($ob->GetList(
				static::__makeArrayFromAlias($arSort, $arAliases),
				static::__makeArrayFromAlias($arFilter, $arAliases)
			));

			// getlist is not supported pagenavigation yet
			if(is_array($arNavParams) && is_set($arNavParams, "nTopCount"))
			{
				$arr = array();
				while($ar = $rs->Fetch())
				{
					if(count($arr) >= intval($arNavParams["nTopCount"]))
						break;
					$arr[] = $ar;
				}
				$rs = new CUserTypeLocationEnum();
				$rs->InitFromArray($arr);
			}
		}

		return $rs;
	}
Esempio n. 2
0
    function ShowStep()
    {
        $wizard =& $this->GetWizard();
        $import_type = $wizard->GetVar('import_type');
        if ($import_type !== 'city') {
            $import_type = 'country';
            $this->content = GetMessage('STATWIZ_STEP2_COUNTRY_CHOOSEN');
        } else {
            $this->content = GetMessage('STATWIZ_STEP2_CITY_CHOOSEN');
        }
        $this->content .= "<br><br>";
        $this->content .= GetMessage('STATWIZ_STEP2_CONTENT');
        $this->content .= "<br><br>";
        $file_name = $wizard->GetVar('file_name');
        $arFiles = CCity::FindFiles($import_type);
        if (count($arFiles) <= 0) {
            $this->content .= GetMessage('STATWIZ_FILES_NOT_FOUND');
        } else {
            $this->content .= "<style>\n\t\t\ttable.statwiz_table  { border-collapse:collapse; }\n\t\t\ttable.statwiz_table td { font-family:Verdana,Arial,sans-serif; border: 1px solid #BDC6E0; padding:3px; background-color: white; }\n\t\t\ttable.statwiz_table td.head { background-color:#E6E9F4; }\n\t\t\ttable.statwiz_table td.tail { background-color:#EAEDF7; }\n\t\t\t</style>\n\t\t\t";
            $this->content .= '<table class="statwiz_table">
			<tr>
				<td class="head">&nbsp;</td>
				<td class="head">' . GetMessage('STATWIZ_STEP2_FILE_NAME') . '</td>
				<td class="head">' . GetMessage('STATWIZ_STEP2_FILE_SIZE') . '</td>
				<td class="head">' . GetMessage('STATWIZ_STEP2_DESCRIPTION') . '</td>
			</tr>';
            foreach ($arFiles as $arFile) {
                $this->content .= '<tr>';
                $arInputAttr = array();
                if ($arFile["FILE"] === $file_name) {
                    $arInputAttr['checked'] = 'checked';
                }
                $arInputAttr["id"] = htmlspecialcharsbx($arFile["FILE"]);
                $this->content .= '<td>' . $this->ShowRadioField("file_name", $arFile["FILE"], $arInputAttr) . '</td>';
                $this->content .= '<td nowrap><label for="' . $arInputAttr["id"] . '">' . $arFile["FILE"] . '</label></td>';
                $pos = 0;
                $this->content .= '<td nowrap>' . CFile::FormatSize($arFile["SIZE"]) . '</td>';
                switch ($arFile["SOURCE"]) {
                    case "MAXMIND-IP-COUNTRY":
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_MAXMIND_IP_COUNTRY') . '</td>';
                        break;
                    case "IP-TO-COUNTRY":
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_IP_TO_COUNTRY') . '</td>';
                        break;
                    case "MAXMIND-IP-LOCATION":
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_MAXMIND_IP_LOCATION') . '</td>';
                        break;
                    case "MAXMIND-CITY-LOCATION":
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_MAXMIND_CITY_LOCATION') . '</td>';
                        break;
                    case "IPGEOBASE":
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_IPGEOBASE') . '</td>';
                        break;
                    case "IPGEOBASE2":
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_IPGEOBASE2') . '</td>';
                        break;
                    case "IPGEOBASE2-CITY":
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_IPGEOBASE2_CITY') . '</td>';
                        break;
                    default:
                        $this->content .= '<td>' . GetMessage('STATWIZ_STEP2_FILE_TYPE_UNKNOWN') . '</td>';
                }
                $this->content .= '</tr>';
            }
            $this->content .= '</table>';
        }
    }
Esempio n. 3
0
						<td style="text-align:center"><input type="radio" name="IP_LOOKUP_CLASS" value="<?php 
        echo $arDescr["CLASS"];
        ?>
" <?php 
        echo $arDescr["CLASS"] == $selected ? "checked" : "";
        ?>
></td>
					</tr>
				<?php 
    }
    ?>
			</table>

			<?php 
    echo BeginNote();
    $obCity = new CCity();
    $arCity = $obCity->GetFullInfo();
    foreach ($arCity as $FIELD_ID => $arField) {
        echo $arField["TITLE"], ": ", $arField["VALUE"], "<br>";
    }
    echo EndNote();
    ?>

		</td>
	</tr>

	<?php 
    $tabControl->BeginNextTab();
    foreach ($arOPTIONS["TAB3"] as $key => $Option) {
        if (!is_array($Option)) {
            if ($key == "BROWSERS") {
Esempio n. 4
0
 public static function GetPageWeights_RS()
 {
     $err_mess = CAdvBanner::err_mess() . "<br>Function: GetPageWeights_RS<br>Line: ";
     global $APPLICATION, $DB, $USER;
     $stat_adv_id = intval($_SESSION["SESS_LAST_ADV_ID"]);
     $stat_country_id = trim($_SESSION["SESS_COUNTRY_ID"]);
     $stat_city_id = intval($_SESSION["SESS_CITY_ID"]);
     if ($stat_city_id > 0 && CModule::IncludeModule('statistic')) {
         $rsCity = CCity::GetList(array(), array("=CITY_ID" => $stat_city_id));
         if ($arCity = $rsCity->Fetch()) {
             $stat_region = $arCity["REGION_NAME"];
         }
     }
     $new_guest = $_SESSION["SESS_GUEST_NEW"] == "N" ? "N" : "Y";
     $url = CAdvBanner::GetCurUri();
     $arrTime = getdate();
     $weekday = strtoupper($arrTime["weekday"]);
     $hour = intval($arrTime["hours"]);
     $strUserGroups = $USER->GetUserGroupString();
     $DONT_USE_CONTRACT = COption::GetOptionString("advertising", "DONT_USE_CONTRACT", "N");
     if ($DONT_USE_CONTRACT == "N") {
         $strSql = "\n\t\t\t\tSELECT DISTINCT\n\t\t\t\t\tB.TYPE_SID,\n\t\t\t\t\tB.ID\t\t\t\t\tBANNER_ID,\n\t\t\t\t\tB.WEIGHT\t\t\t\tBANNER_WEIGHT,\n\t\t\t\t\tB.SHOWS_FOR_VISITOR,\n\t\t\t\t\tB.FIX_CLICK,\n\t\t\t\t\tB.FIX_SHOW,\n\t\t\t\t\tB.KEYWORDS\t\t\t\tBANNER_KEYWORDS,\n\t\t\t\t\t" . $DB->DateToCharFunction("B.DATE_SHOW_FIRST") . "\t\tDATE_SHOW_FIRST,\n\t\t\t\t\t" . $DB->DateToCharFunction("B.DATE_SHOW_FROM") . "\t\t\tDATE_SHOW_FROM,\n\t\t\t\t\t" . $DB->DateToCharFunction("B.DATE_SHOW_TO") . "\t\t\tDATE_SHOW_TO,\n\t\t\t\t\tB.FLYUNIFORM\t\t\tFLYUNIFORM,\n\t\t\t\t\tB.MAX_SHOW_COUNT\t\tMAX_SHOW_COUNT,\n\t\t\t\t\tB.SHOW_COUNT\t\t\tSHOW_COUNT,\n\t\t\t\t\tC.ID\t\t\t\t\tCONTRACT_ID,\n\t\t\t\t\tC.WEIGHT\t\t\t\tCONTRACT_WEIGHT,\n\t\t\t\t\tC.KEYWORDS\t\t\t\tCONTRACT_KEYWORDS\n\t\t\t\tFROM\n\t\t\t\t\tb_adv_type T\n\n\t\t\t\tINNER JOIN b_adv_banner B ON (\n\t\t\t\t\t\tB.ACTIVE='Y'\n\t\t\t\t\tand\tB.TYPE_SID = T.SID\n\t\t\t\t\tand\tB.STATUS_SID = 'PUBLISHED'\n\t\t\t\t\tand (B.FOR_NEW_GUEST is null or B.FOR_NEW_GUEST='{$new_guest}')\n\t\t\t\t\tand\t(ifnull(B.MAX_SHOW_COUNT,0)>ifnull(B.SHOW_COUNT,0) or ifnull(B.MAX_SHOW_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_CLICK_COUNT,0)>ifnull(B.CLICK_COUNT,0) or ifnull(B.MAX_CLICK_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_VISITOR_COUNT,0)>ifnull(B.VISITOR_COUNT,0) or ifnull(B.MAX_VISITOR_COUNT,0)=0)\n\t\t\t\t\tand (B.DATE_SHOW_FROM<=now() or B.DATE_SHOW_FROM is null or length(B.DATE_SHOW_FROM)<=0)\n\t\t\t\t\tand (B.DATE_SHOW_TO>=now() or B.DATE_SHOW_TO is null or length(B.DATE_SHOW_TO)<=0))\n\n\t\t\t\tINNER JOIN b_adv_banner_2_site BS ON (\n\t\t\t\t\t\tBS.BANNER_ID = B.ID\n\t\t\t\t\tand BS.SITE_ID = '" . SITE_ID . "')\n\n\t\t\t\tINNER JOIN b_adv_contract C ON (\n\t\t\t\t\t\tC.ID = B.CONTRACT_ID\n\t\t\t\t\tand C.ACTIVE='Y'\n\t\t\t\t\tand\t(ifnull(C.MAX_SHOW_COUNT,0)>ifnull(C.SHOW_COUNT,0) or ifnull(C.MAX_SHOW_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(C.MAX_CLICK_COUNT,0)>ifnull(C.CLICK_COUNT,0) or ifnull(C.MAX_CLICK_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(C.MAX_VISITOR_COUNT,0)>ifnull(C.VISITOR_COUNT,0) or ifnull(C.MAX_VISITOR_COUNT,0)=0)\n\t\t\t\t\tand (C.DATE_SHOW_FROM<=now() or C.DATE_SHOW_FROM is null or length(C.DATE_SHOW_FROM)<=0)\n\t\t\t\t\tand (C.DATE_SHOW_TO>=now() or C.DATE_SHOW_TO is null or length(C.DATE_SHOW_TO)<=0))\n\n\t\t\t\tINNER JOIN b_adv_contract_2_site CS ON (\n\t\t\t\t\t\tCS.CONTRACT_ID = B.CONTRACT_ID\n\t\t\t\t\tand CS.SITE_ID = '" . SITE_ID . "')\n\n\t\t\t\tINNER JOIN b_adv_contract_2_type CT ON (\n\t\t\t\t\t\tCT.CONTRACT_ID = C.ID\n\t\t\t\t\tand (CT.TYPE_SID = 'ALL' or CT.TYPE_SID = T.SID))\n\n\t\t\t\tINNER JOIN b_adv_banner_2_weekday BW ON (\n\t\t\t\t\t\tBW.BANNER_ID = B.ID\n\t\t\t\t\tand BW.C_WEEKDAY='" . $DB->ForSql($weekday, 10) . "'\n\t\t\t\t\tand BW.C_HOUR = '{$hour}')\n\n\t\t\t\tINNER JOIN b_adv_contract_2_weekday CW ON (\n\t\t\t\t\t\tCW.CONTRACT_ID = C.ID\n\t\t\t\t\tand CW.C_WEEKDAY='" . $DB->ForSql($weekday, 10) . "'\n\t\t\t\t\tand CW.C_HOUR = '{$hour}')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_group UG1 ON (\n\t\t\t\t\t(UG1.BANNER_ID = B.ID\n\t\t\t\t\tand UG1.GROUP_ID in (" . $strUserGroups . ") and UG1.GROUP_ID<>2)\n\t\t\t\t)\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP1 ON (\n\t\t\t\t\t\tBP1.BANNER_ID = B.ID\n\t\t\t\t\tand BP1.SHOW_ON_PAGE='Y')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP2 ON (\n\t\t\t\t\t\tBP2.BANNER_ID = B.ID\n\t\t\t\t\tand BP2.SHOW_ON_PAGE='N'\n\t\t\t\t\tand '" . $DB->ForSQL($url) . "' like concat(BP2.PAGE, '%'))\n\n\t\t\t\tLEFT JOIN b_adv_contract_2_page\tCP1 ON (\n\t\t\t\t\t\tCP1.CONTRACT_ID = C.ID\n\t\t\t\t\tand CP1.SHOW_ON_PAGE='Y')\n\n\t\t\t\tLEFT JOIN b_adv_contract_2_page CP2 ON (\n\t\t\t\t\t\tCP2.CONTRACT_ID = C.ID\n\t\t\t\t\tand CP2.SHOW_ON_PAGE='N'\n\t\t\t\t\tand '" . $DB->ForSQL($url) . "' like concat(CP2.PAGE, '%'))\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_stat_adv\tBA\tON BA.BANNER_ID = B.ID\n\t\t\t\tLEFT JOIN b_adv_banner_2_country BC ON BC.BANNER_ID = B.ID AND (\n\t\t\t\t\t(\n\t\t\t\t\t\t(B.STAT_TYPE is null OR length(B.STAT_TYPE)=0 OR B.STAT_TYPE='COUNTRY')\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='REGION'\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t\tAND BC.REGION='" . $DB->ForSql($stat_region) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='CITY'\n\t\t\t\t\t\tAND BC.CITY_ID='" . intval($stat_city_id) . "'\n\t\t\t\t\t)\n\t\t\t\t)\n\n\t\t\t\tWHERE\n\t\t\t\t\tT.ACTIVE = 'Y'\n\n\t\t\t\tand (\n\t\t\t\t\tB.STAT_COUNT is null\n\t\t\t\t\tor B.STAT_COUNT = 0\n\t\t\t\t\tor BC.BANNER_ID is not null\n\t\t\t\t)\n\t\t\t\tand BP2.ID is null\n\t\t\t\tand CP2.ID is null\n\t\t\t\tand (BP1.ID is null or '" . $DB->ForSQL($url) . "' like concat(BP1.PAGE, '%'))\n\t\t\t\tand (CP1.ID is null or '" . $DB->ForSQL($url) . "' like concat(CP1.PAGE, '%'))\n\t\t\t\tand (BA.STAT_ADV_ID is null or BA.STAT_ADV_ID='" . $stat_adv_id . "')\n\t\t\t\tand (BC.COUNTRY_ID is null or BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "')\n\n\t\t\t\tand\n\t\t\t\t(\n\t\t\t\t\t(B.SHOW_USER_GROUP = 'Y' and UG1.GROUP_ID is not null)\n\t\t\t\t\tor\n\t\t\t\t\t(B.SHOW_USER_GROUP <> 'Y' and UG1.GROUP_ID is null)\n\t\t\t\t)\n\n\t\t\t\tORDER BY B.TYPE_SID desc, C.ID desc\n\t\t\t\t";
     } else {
         $strSql = "\n\t\t\t\tSELECT DISTINCT\n\t\t\t\t\tB.TYPE_SID,\n\t\t\t\t\tB.ID\t\t\t\t\tBANNER_ID,\n\t\t\t\t\tB.WEIGHT\t\t\t\tBANNER_WEIGHT,\n\t\t\t\t\tB.SHOWS_FOR_VISITOR,\n\t\t\t\t\tB.FIX_CLICK,\n\t\t\t\t\tB.FIX_SHOW,\n\t\t\t\t\tB.KEYWORDS\t\t\t\tBANNER_KEYWORDS\n\t\t\t\tFROM\n\t\t\t\t\tb_adv_type T\n\n\t\t\t\tINNER JOIN b_adv_banner B ON (\n\t\t\t\t\t\tB.ACTIVE='Y'\n\t\t\t\t\tand\tB.TYPE_SID = T.SID\n\t\t\t\t\tand\tB.STATUS_SID = 'PUBLISHED'\n\t\t\t\t\tand (B.FOR_NEW_GUEST is null or B.FOR_NEW_GUEST='{$new_guest}')\n\t\t\t\t\tand\t(ifnull(B.MAX_SHOW_COUNT,0)>ifnull(B.SHOW_COUNT,0) or ifnull(B.MAX_SHOW_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_CLICK_COUNT,0)>ifnull(B.CLICK_COUNT,0) or ifnull(B.MAX_CLICK_COUNT,0)=0)\n\t\t\t\t\tand (ifnull(B.MAX_VISITOR_COUNT,0)>ifnull(B.VISITOR_COUNT,0) or ifnull(B.MAX_VISITOR_COUNT,0)=0)\n\t\t\t\t\tand (B.DATE_SHOW_FROM<=now() or B.DATE_SHOW_FROM is null or length(B.DATE_SHOW_FROM)<=0)\n\t\t\t\t\tand (B.DATE_SHOW_TO>=now() or B.DATE_SHOW_TO is null or length(B.DATE_SHOW_TO)<=0))\n\n\t\t\t\tINNER JOIN b_adv_banner_2_site BS ON (\n\t\t\t\t\t\tBS.BANNER_ID = B.ID\n\t\t\t\t\tand BS.SITE_ID = '" . SITE_ID . "')\n\n\t\t\t\tINNER JOIN b_adv_banner_2_weekday BW ON (\n\t\t\t\t\t\tBW.BANNER_ID = B.ID\n\t\t\t\t\tand BW.C_WEEKDAY='" . $DB->ForSql($weekday, 10) . "'\n\t\t\t\t\tand BW.C_HOUR = '{$hour}')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_group UG1 ON (\n\t\t\t\t\t(UG1.BANNER_ID = B.ID\n\t\t\t\t\tand UG1.GROUP_ID in (" . $strUserGroups . ") and UG1.GROUP_ID<>2)\n\t\t\t\t)\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP1 ON (\n\t\t\t\t\t\tBP1.BANNER_ID = B.ID\n\t\t\t\t\tand BP1.SHOW_ON_PAGE='Y')\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_page BP2 ON (\n\t\t\t\t\t\tBP2.BANNER_ID = B.ID\n\t\t\t\t\tand BP2.SHOW_ON_PAGE='N'\n\t\t\t\t\tand '" . $DB->ForSQL($url) . "' like concat(BP2.PAGE, '%'))\n\n\t\t\t\tLEFT JOIN b_adv_banner_2_stat_adv\tBA\tON BA.BANNER_ID = B.ID\n\t\t\t\tLEFT JOIN b_adv_banner_2_country BC ON BC.BANNER_ID = B.ID AND (\n\t\t\t\t\t(\n\t\t\t\t\t\t(B.STAT_TYPE is null OR length(B.STAT_TYPE)=0 OR B.STAT_TYPE='COUNTRY')\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='REGION'\n\t\t\t\t\t\tAND BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "'\n\t\t\t\t\t\tAND BC.REGION='" . $DB->ForSql($stat_region) . "'\n\t\t\t\t\t) OR (\n\t\t\t\t\t\tB.STAT_TYPE='CITY'\n\t\t\t\t\t\tAND BC.CITY_ID='" . intval($stat_city_id) . "'\n\t\t\t\t\t)\n\t\t\t\t)\n\n\t\t\t\tWHERE\n\t\t\t\t\tT.ACTIVE = 'Y'\n\n\t\t\t\tand (\n\t\t\t\t\tB.STAT_COUNT is null\n\t\t\t\t\tor B.STAT_COUNT = 0\n\t\t\t\t\tor BC.BANNER_ID is not null\n\t\t\t\t)\n\t\t\t\tand BP2.ID is null\n\t\t\t\tand (BP1.ID is null or '" . $DB->ForSQL($url) . "' like concat(BP1.PAGE, '%'))\n\t\t\t\tand (BA.STAT_ADV_ID is null or BA.STAT_ADV_ID='" . $stat_adv_id . "')\n\t\t\t\tand (BC.COUNTRY_ID is null or BC.COUNTRY_ID='" . $DB->ForSql($stat_country_id, 2) . "')\n\t\t\t\tand\n\t\t\t\t(\n\t\t\t\t\t(B.SHOW_USER_GROUP = 'Y' and UG1.GROUP_ID is not null)\n\t\t\t\t\tor\n\t\t\t\t\t(B.SHOW_USER_GROUP <> 'Y' and UG1.GROUP_ID is null)\n\t\t\t\t)\n\t\t\t\tORDER BY B.TYPE_SID desc";
     }
     $rs = $DB->Query($strSql, false, $err_mess . __LINE__);
     return $rs;
 }
Esempio n. 5
0
 public static function LoadCSV($file_name, $step, &$file_position)
 {
     global $APPLICATION;
     $DB = CDatabase::GetModuleConnection('statistic');
     $arCache = array();
     $arLookupCache = array();
     $arCountryCache = array();
     $fp = fopen($_SERVER["DOCUMENT_ROOT"] . $file_name, "rb");
     if (!$fp) {
         return "Y";
     }
     $file_format = CCity::GetCSVFormatType($fp);
     $file_position = intval($file_position);
     fseek($fp, $file_position);
     if ($step > 0) {
         $end_time = getmicrotime() + $step;
     } else {
         $end_time = 0;
     }
     switch ($file_format) {
         case "MAXMIND-IP-COUNTRY":
             $delimiter = ",";
             $char_set = LANG_CHARSET;
             $table_name = "b_stat_country";
             $arFieldsMap = array("ID" => array("key" => true, "index" => 4, "type" => "varchar", "len" => 2, "default" => "NA"), "NAME" => array("index" => 5, "type" => "varchar", "len" => 50, "default" => "N00", "enc" => true));
             break;
         case "IP-TO-COUNTRY":
             $delimiter = ",";
             $char_set = LANG_CHARSET;
             $table_name = "b_stat_country";
             $arFieldsMap = array("ID" => array("key" => true, "index" => 2, "type" => "varchar", "len" => 2, "default" => "NA"), "SHORT_NAME" => array("index" => 3, "type" => "varchar", "len" => 3, "default" => "N00"), "NAME" => array("index" => 4, "type" => "varchar", "len" => 50, "enc" => true));
             break;
         case "MAXMIND-IP-LOCATION":
             $delimiter = ",";
             $char_set = LANG_CHARSET;
             $table_name = "b_stat_city_ip";
             $arFieldsMap = array("START_IP" => array("key" => true, "index" => 0, "type" => "ipnum"), "END_IP" => array("index" => 1, "type" => "ipnum"), "XML_ID" => array("index" => 2, "type" => "lookup"), "COUNTRY_ID" => array("index" => -1, "type" => "varchar"), "CITY_ID" => array("index" => -2, "type" => "number"));
             //Some files need to skip first line
             if ($file_position <= 0) {
                 fgets($fp, 4096);
                 fgets($fp, 4096);
             }
             break;
         case "MAXMIND-CITY-LOCATION":
             $delimiter = ",";
             $char_set = "iso-8859-1";
             $table_name = "b_stat_city";
             $arFieldsMap = array("COUNTRY_ID" => array("index" => 1, "type" => "varchar", "len" => 2, "default" => "NA"), "REGION" => array("index" => 2, "type" => "varchar", "len" => 255, "enc" => true), "NAME" => array("index" => 3, "type" => "varchar", "len" => 255, "enc" => true), "XML_ID" => array("key" => true, "index" => 0, "type" => "varchar", "len" => 255));
             //Some files need to skip first line
             if ($file_position <= 0) {
                 fgets($fp, 4096);
                 fgets($fp, 4096);
             }
             break;
         case "IPGEOBASE":
             $delimiter = "\t";
             $char_set = "Windows-1251";
             $table_name = "b_stat_city_ip";
             $arFieldsMap = array("START_IP" => array("key" => true, "index" => 0, "type" => "ipnum"), "END_IP" => array("index" => 1, "type" => "ipnum"), "COUNTRY_ID" => array("index" => 3, "type" => "varchar", "len" => 2, "default" => "NA"), "XML_ID" => array("index" => array(3, 4, 5), "type" => "upsert", "enc" => true, "master" => array("COUNTRY_ID" => array("index" => 3, "type" => "varchar", "len" => 2, "default" => "NA"), "REGION" => array("index" => 5, "type" => "varchar", "len" => 255, "enc" => true), "NAME" => array("index" => 4, "type" => "varchar", "len" => 255, "enc" => true))), "CITY_ID" => array("index" => -1, "type" => "number"));
             break;
         case "IPGEOBASE2":
             $delimiter = "\t";
             $char_set = "Windows-1251";
             $table_name = "b_stat_city_ip";
             $arFieldsMap = array("START_IP" => array("key" => true, "index" => 0, "type" => "ipnum"), "END_IP" => array("index" => 1, "type" => "ipnum"), "COUNTRY_ID" => array("index" => 3, "type" => "varchar", "len" => 2, "default" => "NA", "update_city" => 4), "XML_ID" => array("index" => 4, "type" => "lookup"), "CITY_ID" => array("index" => -1, "type" => "number"));
             break;
         case "IPGEOBASE2-CITY":
             $delimiter = "\t";
             $char_set = "Windows-1251";
             $table_name = "b_stat_city";
             $arFieldsMap = array("COUNTRY_ID" => array("skip_update" => true, "index" => 100, "type" => "varchar", "len" => 2, "default" => "NA"), "REGION" => array("index" => 2, "type" => "varchar", "len" => 255, "enc" => true), "NAME" => array("index" => 1, "type" => "varchar", "len" => 255, "enc" => true), "XML_ID" => array("key" => true, "index" => 0, "type" => "varchar", "len" => 255));
             break;
         default:
             return "Y";
     }
     $bConv = $char_set != LANG_CHARSET;
     while (!feof($fp)) {
         //$arr = fgetcsv($fp, 4096, $delimiter);
         $arr = fgets($fp, 4096);
         if ($bConv && preg_match("/[^a-zA-Z0-9 \t\n\r]/", $arr)) {
             $arr = $APPLICATION->ConvertCharset($arr, $char_set, LANG_CHARSET);
         }
         $arr = preg_split("/" . $delimiter . "/" . BX_UTF_PCRE_MODIFIER, $arr);
         $arAllSQLFields = array();
         $arFields = array();
         $strUpdate = "";
         $strWhere = "";
         $strInsert1 = "";
         $strInsert2 = "";
         $bEmptyKey = false;
         foreach ($arFieldsMap as $FIELD_ID => $arField) {
             if (is_array($arField["index"])) {
                 $value = "";
                 foreach ($arField["index"] as $index) {
                     $value .= trim($arr[$index], "\" \n\r\t");
                 }
                 $value = md5($value);
             } else {
                 $value = trim($arr[$arField["index"]], "\" \n\r\t");
             }
             //if($bConv && $arField["enc"] && preg_match("/[^a-zA-Z0-9 \t\n\r]/", $value))
             //	$value = $APPLICATION->ConvertCharset($value, $char_set, LANG_CHARSET);
             if (!$value && $arField["default"]) {
                 $value = $arField["default"];
             }
             if ($arField["type"] == "upsert") {
                 if (!array_key_exists($value, $arLookupCache)) {
                     $rs = $DB->Query("SELECT ID as CITY_ID FROM b_stat_city WHERE XML_ID = '" . $DB->ForSQL($value) . "'");
                     $ar = $rs->Fetch();
                     if (!$ar) {
                         $arNewMaster = array("XML_ID" => $value);
                         foreach ($arField["master"] as $MASTER_FIELD_ID => $arMasterField) {
                             $m_value = trim($arr[$arMasterField["index"]], "\"");
                             //if($bConv && $arMasterField["enc"] && preg_match("/[^a-zA-Z0-9 \t\n\r]/", $m_value))
                             //	$m_value = $APPLICATION->ConvertCharset($m_value, $char_set, LANG_CHARSET);
                             if (!$m_value && $arMasterField["default"]) {
                                 $m_value = $arMasterField["default"];
                             }
                             $arNewMaster[$MASTER_FIELD_ID] = $m_value;
                         }
                         $ar = array("CITY_ID" => $DB->Add("b_stat_city", $arNewMaster));
                     }
                     $arLookupCache[$value] = $ar;
                 }
                 foreach ($arLookupCache[$value] as $key => $val) {
                     $arr[$arFieldsMap[$key]["index"]] = $val;
                 }
                 continue;
             }
             if ($arField["type"] == "lookup") {
                 if (!array_key_exists($value, $arLookupCache)) {
                     $rs = $DB->Query("SELECT COUNTRY_ID, ID as CITY_ID FROM b_stat_city WHERE XML_ID = '" . $DB->ForSQL($value) . "'");
                     $ar = $rs->Fetch();
                     if (!$ar) {
                         $ar = array("COUNTRY_ID" => "NA", "CITY_ID" => 0);
                     }
                     $arLookupCache[$value] = $ar;
                 }
                 foreach ($arLookupCache[$value] as $key => $val) {
                     $arr[$arFieldsMap[$key]["index"]] = $val;
                 }
                 continue;
             }
             if ($FIELD_ID === "COUNTRY_ID" && !array_key_exists($value, $arCountryCache) && strlen($value) > 0) {
                 $cid = $DB->ForSQL($value, 2);
                 $rs = $DB->Query("SELECT ID FROM b_stat_country WHERE ID = '" . $cid . "'");
                 if (!$rs->Fetch()) {
                     $DB->Query("insert into b_stat_country (ID) values ('" . $cid . "')");
                 }
                 $arCountryCache[$value] = true;
             }
             if ($FIELD_ID === "COUNTRY_ID" && isset($arField["update_city"]) && strlen($value) > 0) {
                 $city_id = $DB->ForSQL(trim($arr[$arField["update_city"]], "\" \n\r\t"));
                 $cid = $DB->ForSQL($value, 2);
                 $rs = $DB->Query("UPDATE b_stat_city SET COUNTRY_ID = '" . $cid . "' WHERE XML_ID = '" . $city_id . "'");
             }
             switch ($arField["type"]) {
                 case "varchar":
                     $sql_value = "'" . $DB->ForSQL($value, $arField["len"]) . "'";
                     break;
                 case "ipnum":
                 case "number":
                     $sql_value = preg_replace("/[^0-9]/", "", $value);
                     break;
                 default:
                     $sql_value = "'" . $DB->ForSQL($value) . "'";
                     break;
             }
             $arAllSQLFields[$FIELD_ID] = $sql_value;
             if ($arField["key"]) {
                 if ($value) {
                     if ($strWhere) {
                         $strWhere .= " AND ";
                     }
                     $strWhere .= $FIELD_ID . " = " . $sql_value;
                 } else {
                     $bEmptyKey = true;
                 }
             } else {
                 $arFields[$FIELD_ID] = $value;
                 if ($strUpdate) {
                     $strUpdate .= ", ";
                 }
                 $strUpdate .= $FIELD_ID . " = " . $sql_value;
             }
             if ($strInsert1) {
                 $strInsert1 .= ", ";
             }
             $strInsert1 .= $FIELD_ID;
             if ($strInsert2) {
                 $strInsert2 .= ", ";
             }
             $strInsert2 .= $sql_value;
         }
         if (!$bEmptyKey && $strWhere && $strUpdate && !array_key_exists($strWhere, $arCache)) {
             if ($table_name == "b_stat_city_ip" && $arAllSQLFields["START_IP"] && $arAllSQLFields["END_IP"]) {
                 $arToUpdate = CCity::ResolveIPRange($arAllSQLFields["START_IP"], $arAllSQLFields["END_IP"]);
             } else {
                 $rs = $DB->Query("SELECT * FROM {$table_name} WHERE {$strWhere}");
                 $arToUpdate = $rs->Fetch();
             }
             if ($arToUpdate) {
                 $bNeedUpdate = false;
                 foreach ($arFields as $UPD_FIELD_ID => $upd_value) {
                     if (!isset($arFieldsMap[$UPD_FIELD_ID]["skip_update"])) {
                         if ($upd_value != $arToUpdate[$UPD_FIELD_ID]) {
                             $bNeedUpdate = true;
                             break;
                         }
                     }
                 }
                 if ($bNeedUpdate) {
                     $DB->Query("UPDATE {$table_name} SET {$strUpdate} WHERE {$strWhere}");
                 }
             } else {
                 $DB->Query("INSERT INTO {$table_name} ({$strInsert1}) VALUES ({$strInsert2})");
             }
             $arCache[$strWhere] = true;
         }
         if ($end_time && getmicrotime() > $end_time) {
             $file_position = ftell($fp);
             return "N";
         }
     }
     $file_position = ftell($fp);
     return "Y";
 }
Esempio n. 6
0
}
// create image
$ImageHandle = CreateImageHandle($width, $height);
$arrX = array();
// data points X
$arrY = array();
// data points Y
$arrayX = array();
// axis X
$arrayY = array();
// axis Y
/******************************************************
			Get data
*******************************************************/
$arF = array("COUNTRY_ID" => $find_country_id, "DATE1" => $find_date1, "DATE2" => $find_date2);
$arrDays = CCity::GetGraphArray($arF, $arrLegend, $find_data_type, 20);
reset($arrDays);
while (list($keyD, $arD) = each($arrDays)) {
    $date = mktime(0, 0, 0, $arD["M"], $arD["D"], $arD["Y"]);
    $date_tmp = 0;
    $next_date = AddTime($prev_date, 1, "D");
    if ($date > $next_date && intval($prev_date) > 0) {
        $date_tmp = $next_date;
        while ($date_tmp < $date) {
            $arrX[] = $date_tmp;
            reset($arrLegend);
            while (list($keyL, $arrL) = each($arrLegend)) {
                $arrY_data[$keyL][] = 0;
                $arrY[] = 0;
            }
            $date_tmp = AddTime($date_tmp, 1, "D");
Esempio n. 7
0
</td>
	</tr>
	<?php 
}
?>

	<?php 
if (CModule::IncludeModule("statistic")) {
    $arDisplay = array();
    if ($str_STAT_TYPE === "CITY") {
        if (is_array($arrSTAT_TYPE_VALUES) && count($arrSTAT_TYPE_VALUES) > 0) {
            $arFilter = array();
            foreach ($arrSTAT_TYPE_VALUES as $ar) {
                $arFilter[] = $ar["CITY_ID"];
            }
            $rs = CCity::GetList("CITY", array("=CITY_ID" => $arFilter));
            while ($ar = $rs->GetNext()) {
                $arDisplay[$ar["CITY_ID"]] = "[" . $ar["COUNTRY_ID"] . "] [" . $ar["REGION_NAME"] . "] " . $ar["CITY_NAME"];
            }
        }
    } elseif ($str_STAT_TYPE === "REGION") {
        if (is_array($arrSTAT_TYPE_VALUES)) {
            foreach ($arrSTAT_TYPE_VALUES as $ar) {
                $arDisplay[$ar["COUNTRY_ID"] . "|" . $ar["REGION"]] = "[" . $ar["COUNTRY_ID"] . "] " . $ar["REGION"];
            }
        }
    } else {
        if (is_array($arrSTAT_TYPE_VALUES) && count($arrSTAT_TYPE_VALUES) > 0) {
            $arr = array_flip($arrSTAT_TYPE_VALUES);
            $v1 = "s_id";
            $rs = CStatCountry::GetList($v1, $v2, array(), $v3);
        $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
    }
}
IncludeModuleLangFile(__FILE__);
$sTableID = "tbl_stat_city_multiselect";
$oSort = new CAdminSorting($sTableID, "CITY", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
$FilterArr = array("find", "find_type", "find_country_id", "find_country_id_exact_match", "find_country_short_name", "find_country_short_name_exact_match", "find_country_name", "find_country_name_exact_match", "find_region_name", "find_region_name_exact_match", "find_city_name", "find_city_name_exact_match");
$lAdmin->InitFilter($FilterArr);
$arFilter = array(($find_country_id_exact_match == "Y" ? "=" : "%") . "COUNTRY_ID" => $find != "" && $find_type == "county_id" ? $find : $find_country_id, ($find_country_short_name_exact_match == "Y" ? "=" : "%") . "COUNTRY_SHORT_NAME" => $find != "" && $find_type == "county_short_name" ? $find : $find_country_short_name, ($find_country_name_exact_match == "Y" ? "=" : "%") . "COUNTRY_NAME" => $find != "" && $find_type == "county_name" ? $find : $find_country_name, ($find_region_name_exact_match == "Y" ? "=" : "%") . "REGION_NAME" => $find != "" && $find_type == "region_name" ? $find : $find_region_name, ($find_city_name_exact_match == "Y" ? "=" : "%") . "CITY_NAME" => $find != "" && $find_type == "city_name" ? $find : $find_city_name);
foreach ($arFilter as $i => $flt) {
    if (trim($flt) == "") {
        unset($arFilter[$i]);
    }
}
$cData = new CCity();
$rsData = $cData->GetList(array($by => $order), $arFilter, $is_filtered);
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("STAT_CITY_MSEL_PAGES")));
$arHeaders = array(array("id" => "COUNTRY_ID", "content" => GetMessage("STAT_CITY_MSEL_COUNTRY_ID"), "sort" => "CITY", "default" => true), array("id" => "COUNTRY_SHORT_NAME", "content" => GetMessage("STAT_CITY_MSEL_COUNTRY_SHORT_NAME"), "sort" => "COUNTRY_SHORT_NAME", "default" => true), array("id" => "COUNTRY_NAME", "content" => GetMessage("STAT_CITY_MSEL_COUNTRY_NAME"), "sort" => "COUNTRY_NAME", "default" => true), array("id" => "REGION_NAME", "content" => GetMessage("STAT_CITY_MSEL_REGION_NAME"), "sort" => "REGION_NAME", "default" => true), array("id" => "CITY_NAME", "content" => GetMessage("STAT_CITY_MSEL_CITY_NAME"), "sort" => "CITY_NAME", "default" => true));
$lAdmin->AddHeaders($arHeaders);
while ($arRes = $rsData->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_CITY_ID, $arRes);
    $row->AddViewField("COUNTRY_ID", $f_COUNTRY_ID . '<input type="hidden" name="CITY_NAME[' . $f_CITY_ID . ']" id="CITY_NAME[' . $f_CITY_ID . ']" value="[' . $f_COUNTRY_ID . '] [' . $f_REGION_NAME . '] ' . $f_CITY_NAME . '">');
}
$arFooter = array();
$arFooter[] = array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $rsData->SelectedRowsCount());
$arFooter[] = array("counter" => true, "title" => GetMessage("MAIN_ADMIN_LIST_CHECKED"), "value" => "0");
$lAdmin->AddFooter($arFooter);
$lAdmin->AddGroupActionTable(array(array("action" => "setTargetValue(0, 'form_" . $sTableID . "', '" . CUtil::JSEscape($_REQUEST["field"]) . "')", "value" => "select", "type" => "button", "title" => GetMessage("STAT_CITY_MSEL_SELECT_TITLE"), "name" => GetMessage("STAT_CITY_MSEL_SELECT"))), array("disable_action_target" => true));
Esempio n. 9
0
    function ReallyKeep()
    {
        global $USER, $APPLICATION, $STOP_SAVE_STATISTIC, $STOP_MESSAGE, $STOP_REDIRECT_URL, $STOP, $STOP_LIST_ID, $STOP_MESSAGE_LID;
        $DB = CDatabase::GetModuleConnection('statistic');
        $SITE_ID = "";
        if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
            $sql_site = "null";
        } elseif (defined("SITE_ID")) {
            $sql_site = "'" . $DB->ForSql(SITE_ID, 2) . "'";
            $SITE_ID = SITE_ID;
        } else {
            $sql_site = "null";
        }
        $ADV_NA = COption::GetOptionString("statistic", "ADV_NA");
        __SetReferer("referer1", "REFERER1_SYN");
        __SetReferer("referer2", "REFERER2_SYN");
        __SetReferer("referer3", "REFERER3_SYN");
        $SAVE_HITS = COption::GetOptionString("statistic", "SAVE_HITS") == "N" ? "N" : "Y";
        $SAVE_VISITS = COption::GetOptionString("statistic", "SAVE_VISITS") == "N" ? "N" : "Y";
        $SAVE_REFERERS = COption::GetOptionString("statistic", "SAVE_REFERERS") == "N" ? "N" : "Y";
        $SAVE_PATH_DATA = COption::GetOptionString("statistic", "SAVE_PATH_DATA") == "N" ? "N" : "Y";
        $stmp = time();
        $hour = date("G", $stmp);
        // 0..23
        $weekday = date("w", $stmp);
        // 0..6
        if ($weekday == 0) {
            $weekday = 7;
        }
        $month = date("n", $stmp);
        // 1..12
        if ($STOP_SAVE_STATISTIC != "N" or $STOP != "Y") {
            if (isset($_SESSION["SESS_ADD_TO_FAVORITES"]) && $_SESSION["SESS_ADD_TO_FAVORITES"] == "Y") {
                $FAVORITES = "Y";
                $_SESSION["SESS_ADD_TO_FAVORITES"] = "";
            } else {
                $FAVORITES = "N";
            }
            $ERROR_404 = defined("ERROR_404") && ERROR_404 == "Y" ? "Y" : "N";
            $DB_now = $DB->GetNowFunction();
            // save function for use in sql
            $DB_now_date = $DB->GetNowDate();
            // save function for use in sql
            $STOP_LIST_ID = intval($STOP_LIST_ID);
            if ($ERROR_404 == "Y") {
                init_get_params($APPLICATION->GetCurUri());
            }
            $IS_USER_AUTHORIZED = intval($_SESSION["SESS_LAST_USER_ID"]) > 0 && is_object($USER) && $USER->IsAuthorized() ? "Y" : "N";
            stat_session_register("SESS_SEARCHER_ID");
            stat_session_register("SESS_SEARCHER_NAME");
            stat_session_register("SESS_SEARCHER_CHECK_ACTIVITY");
            stat_session_register("SESS_SEARCHER_SAVE_STATISTIC");
            stat_session_register("SESS_SEARCHER_HIT_KEEP_DAYS");
            stat_session_register("SESS_LAST_PROTOCOL");
            stat_session_register("SESS_LAST_URI");
            stat_session_register("SESS_LAST_HOST");
            stat_session_register("SESS_LAST_PAGE");
            stat_session_register("SESS_LAST_DIR");
            stat_session_register("SESS_HTTP_REFERER");
            stat_session_register("SESS_COUNTRY_ID");
            stat_session_register("SESS_CITY_ID");
            stat_session_register("SESS_SESSION_ID");
            stat_session_register("SESS_REFERER_ID");
            stat_session_register("FROM_SEARCHER_ID");
            stat_session_register("SESS_FROM_SEARCHERS");
            stat_session_register("SESS_REQUEST_URI_CHANGE");
            stat_session_register("SESS_LAST_DIR_ID");
            stat_session_register("SESS_LAST_PAGE_ID");
            stat_session_register("SESS_GRABBER_STOP_TIME");
            stat_session_register("SESS_GRABBER_DEFENCE_STACK");
            stat_session_register("ACTIVITY_EXCEEDING_NOTIFIED");
            // SESSION_DATA_ID will be false when there is no sessions stored
            // true when session was not found in database
            // and an integer when was found and populated to $SESSION array
            $SESSION_DATA_ID = CKeepStatistics::RestoreSession();
            // Let's check activity limit
            $BLOCK_ACTIVITY = CStatistics::BlockVisitorActivity();
            // Activity under the limit
            if (!$BLOCK_ACTIVITY) {
                //Check if searcher was not deleted from searchers list
                if (intval($_SESSION["SESS_SEARCHER_ID"]) > 0) {
                    $strSql = "\n\t\t\t\t\t\tSELECT ID\n\t\t\t\t\t\tFROM b_stat_searcher\n\t\t\t\t\t\tWHERE ID = '" . intval($_SESSION["SESS_SEARCHER_ID"]) . "'\n\t\t\t\t\t";
                    $z = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                    if (!$z->Fetch()) {
                        unset($_SESSION["SESS_SEARCHER_ID"]);
                    }
                }
                // We did not check for searcher
                if (strlen($_SESSION["SESS_SEARCHER_ID"]) <= 0) {
                    // is it searcher hit?
                    $strSql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tID, NAME, SAVE_STATISTIC, HIT_KEEP_DAYS, CHECK_ACTIVITY\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_stat_searcher\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tACTIVE = 'Y'\n\t\t\t\t\t\tand " . $DB->Length("USER_AGENT") . ">0\n\t\t\t\t\t\tand upper('" . $DB->ForSql($_SERVER["HTTP_USER_AGENT"], 500) . "') like " . $DB->Concat("'%'", "upper(USER_AGENT)", "'%'") . "\n\t\t\t\t\t\tORDER BY " . $DB->Length("USER_AGENT") . " desc, ID\n\t\t\t\t\t\t";
                    $z = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                    if ($zr = $z->Fetch()) {
                        $_SESSION["SESS_SEARCHER_ID"] = intval($zr["ID"]);
                        $_SESSION["SESS_SEARCHER_NAME"] = $zr["NAME"];
                        $_SESSION["SESS_SEARCHER_CHECK_ACTIVITY"] = $zr["CHECK_ACTIVITY"];
                        $_SESSION["SESS_SEARCHER_SAVE_STATISTIC"] = $zr["SAVE_STATISTIC"];
                        $_SESSION["SESS_SEARCHER_HIT_KEEP_DAYS"] = $zr["HIT_KEEP_DAYS"];
                        //Here was warning "A session is active. You cannot change the session module's ini settings at this time."
                        //@ini_set("url_rewriter.tags", "");
                    }
                    $_SESSION["SESS_SEARCHER_ID"] = intval($_SESSION["SESS_SEARCHER_ID"]);
                }
                /************************************************
                					Searcher section
                			************************************************/
                // searcher detected
                if (intval($_SESSION["SESS_SEARCHER_ID"]) > 0) {
                    $_SESSION["SESS_SEARCHER_ID"] = intval($_SESSION["SESS_SEARCHER_ID"]);
                    // let's update day counter
                    $arFields = array("DATE_LAST" => $DB_now, "TOTAL_HITS" => "TOTAL_HITS + 1");
                    $rows = $DB->Update("b_stat_searcher_day", $arFields, "WHERE SEARCHER_ID='" . $_SESSION["SESS_SEARCHER_ID"] . "' and DATE_STAT=" . $DB_now_date, "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                    // there is no stat for the day yet
                    if (intval($rows) <= 0) {
                        // add it
                        $arFields_i = array("DATE_STAT" => $DB_now_date, "DATE_LAST" => $DB_now, "SEARCHER_ID" => $_SESSION["SESS_SEARCHER_ID"], "TOTAL_HITS" => 1);
                        $DB->Insert("b_stat_searcher_day", $arFields_i, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                    } elseif (intval($rows) > 1) {
                        $strSql = "SELECT ID FROM b_stat_searcher_day WHERE SEARCHER_ID='" . $_SESSION["SESS_SEARCHER_ID"] . "' and DATE_STAT=" . $DB_now_date . " ORDER BY ID";
                        $i = 0;
                        $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                        while ($ar = $rs->Fetch()) {
                            $i++;
                            if ($i > 1) {
                                $strSql = "DELETE FROM b_stat_searcher_day WHERE ID = " . $ar["ID"];
                                $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                            }
                        }
                    }
                    // save indexed page if neccessary
                    if ($_SESSION["SESS_SEARCHER_SAVE_STATISTIC"] == "Y") {
                        $sql_HIT_KEEP_DAYS = strlen($_SESSION["SESS_SEARCHER_HIT_KEEP_DAYS"]) > 0 ? intval($_SESSION["SESS_SEARCHER_HIT_KEEP_DAYS"]) : "null";
                        $arFields = array("DATE_HIT" => $DB_now, "SEARCHER_ID" => intval($_SESSION["SESS_SEARCHER_ID"]), "URL" => "'" . $DB->ForSql(__GetFullRequestUri(), 2000) . "'", "URL_404" => "'" . $ERROR_404 . "'", "IP" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "USER_AGENT" => "'" . $DB->ForSql($_SERVER["HTTP_USER_AGENT"], 500) . "'", "HIT_KEEP_DAYS" => $sql_HIT_KEEP_DAYS, "SITE_ID" => $sql_site);
                        $id = $DB->Insert("b_stat_searcher_hit", $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                        if ($ERROR_404 == "N") {
                            CStatistics::Set404("b_stat_searcher_hit", "ID = " . intval($id), array("URL_404" => "Y"));
                        }
                    }
                } else {
                    /************************************************
                    					Visitor section
                    			************************************************/
                    /************************************************
                    				Variables which describe current page
                    			************************************************/
                    $CURRENT_DIR = __GetCurrentDir();
                    $CURRENT_PAGE = __GetCurrentPage();
                    $CURRENT_PROTOCOL = CMain::IsHTTPS() ? "https://" : "http://";
                    // protocol
                    $CURRENT_PORT = $_SERVER["SERVER_PORT"];
                    // port
                    $CURRENT_HOST = $_SERVER["HTTP_HOST"];
                    // domain
                    $CURRENT_PAGE = __GetFullRequestUri($CURRENT_PAGE);
                    // w/o parameters
                    $CURRENT_URI = __GetFullRequestUri();
                    // with params
                    $CURRENT_DIR = __GetFullRequestUri($CURRENT_DIR);
                    // catalog
                    /************************************************
                    					Country detection
                    			************************************************/
                    if (strlen($_SESSION["SESS_COUNTRY_ID"]) <= 0) {
                        $obCity = new CCity();
                        $_SESSION["SESS_COUNTRY_ID"] = $obCity->GetCountryCode();
                        $_SESSION["SESS_CITY_ID"] = $obCity->GetCityID();
                    }
                    /************************************************
                    					IP => number
                    			************************************************/
                    $REMOTE_ADDR_NUMBER = ip2number($_SERVER["REMOTE_ADDR"]);
                    /************************************************
                    					Advertising campaign
                    			************************************************/
                    CStatistics::Set_Adv();
                    /************************************************
                    					Guest ID detection
                    			************************************************/
                    $arGuest = CStatistics::Set_Guest();
                    // Setup default advertising campaign
                    if ($ADV_NA == "Y" && intval($_SESSION["SESS_ADV_ID"]) <= 0 && intval($_SESSION["SESS_LAST_ADV_ID"]) <= 0) {
                        $_SESSION["referer1"] = COption::GetOptionString("statistic", "AVD_NA_REFERER1");
                        $_SESSION["referer2"] = COption::GetOptionString("statistic", "AVD_NA_REFERER2");
                        CStatistics::Set_Adv();
                        $arGuest = CStatistics::Set_Guest();
                    }
                    /************************************************
                    					Session section
                    			************************************************/
                    $_SESSION["SESS_SESSION_ID"] = intval($_SESSION["SESS_SESSION_ID"]);
                    //session already exists
                    if ($_SESSION["SESS_SESSION_ID"] > 0) {
                        $SESSION_NEW = "N";
                        // update
                        $arFields = array("USER_ID" => intval($_SESSION["SESS_LAST_USER_ID"]), "USER_AUTH" => "'" . $IS_USER_AUTHORIZED . "'", "USER_AGENT" => "'" . $DB->ForSql($_SERVER["HTTP_USER_AGENT"], 500) . "'", "DATE_LAST" => $DB_now, "IP_LAST" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "IP_LAST_NUMBER" => $REMOTE_ADDR_NUMBER, "HITS" => "HITS + 1");
                        $rows = $DB->Update("b_stat_session", $arFields, "WHERE ID='" . $_SESSION["SESS_SESSION_ID"] . "'", "File: " . __FILE__ . "<br>Line: " . __LINE__);
                        // was cleaned up
                        if (intval($rows) <= 0) {
                            // store as new
                            $_SESSION["SESS_SESSION_ID"] = 0;
                            if ($ADV_NA == "Y" && intval($_SESSION["SESS_ADV_ID"]) <= 0 && intval($_SESSION["SESS_LAST_ADV_ID"]) <= 0) {
                                $_SESSION["referer1"] = COption::GetOptionString("statistic", "AVD_NA_REFERER1");
                                $_SESSION["referer2"] = COption::GetOptionString("statistic", "AVD_NA_REFERER2");
                            }
                            CStatistics::Set_Adv();
                            $arGuest = CStatistics::Set_Guest();
                        }
                    }
                    // it is new session
                    if ($_SESSION["SESS_SESSION_ID"] <= 0) {
                        $SESSION_NEW = "Y";
                        // save session data
                        $arFields = array("GUEST_ID" => intval($_SESSION["SESS_GUEST_ID"]), "NEW_GUEST" => "'" . $DB->ForSql($_SESSION["SESS_GUEST_NEW"]) . "'", "USER_ID" => intval($_SESSION["SESS_LAST_USER_ID"]), "USER_AUTH" => "'" . $DB->ForSql($IS_USER_AUTHORIZED) . "'", "URL_FROM" => "'" . $DB->ForSql($_SERVER["HTTP_REFERER"], 2000) . "'", "URL_TO" => "'" . $DB->ForSql($CURRENT_URI, 2000) . "'", "URL_TO_404" => "'" . $DB->ForSql($ERROR_404) . "'", "URL_LAST" => "'" . $DB->ForSql($CURRENT_URI, 2000) . "'", "URL_LAST_404" => "'" . $DB->ForSql($ERROR_404) . "'", "USER_AGENT" => "'" . $DB->ForSql($_SERVER["HTTP_USER_AGENT"], 500) . "'", "DATE_STAT" => $DB_now_date, "DATE_FIRST" => $DB_now, "DATE_LAST" => $DB_now, "IP_FIRST" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "IP_FIRST_NUMBER" => "'" . $DB->ForSql($REMOTE_ADDR_NUMBER) . "'", "IP_LAST" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "IP_LAST_NUMBER" => "'" . $DB->ForSql($REMOTE_ADDR_NUMBER) . "'", "PHPSESSID" => "'" . $DB->ForSql(session_id(), 255) . "'", "STOP_LIST_ID" => "'" . $DB->ForSql($STOP_LIST_ID) . "'", "COUNTRY_ID" => "'" . $DB->ForSql($_SESSION["SESS_COUNTRY_ID"], 2) . "'", "CITY_ID" => $_SESSION["SESS_CITY_ID"] > 0 ? intval($_SESSION["SESS_CITY_ID"]) : "null", "ADV_BACK" => "null", "FIRST_SITE_ID" => $sql_site, "LAST_SITE_ID" => $sql_site, "HITS" => 1);
                        // campaign?
                        if (intval($_SESSION["SESS_ADV_ID"]) > 0) {
                            $arFields["ADV_ID"] = intval($_SESSION["SESS_ADV_ID"]);
                            $arFields["ADV_BACK"] = "'N'";
                            $arFields["REFERER1"] = "'" . $DB->ForSql($_SESSION["referer1"], 255) . "'";
                            $arFields["REFERER2"] = "'" . $DB->ForSql($_SESSION["referer2"], 255) . "'";
                            $arFields["REFERER3"] = "'" . $DB->ForSql($_SESSION["referer3"], 255) . "'";
                        } elseif (intval($_SESSION["SESS_LAST_ADV_ID"]) > 0) {
                            $arFields["ADV_ID"] = intval($_SESSION["SESS_LAST_ADV_ID"]);
                            $arFields["ADV_BACK"] = "'Y'";
                            $arFields["REFERER1"] = "'" . $DB->ForSql($arGuest["last_referer1"], 255) . "'";
                            $arFields["REFERER2"] = "'" . $DB->ForSql($arGuest["last_referer2"], 255) . "'";
                        }
                        // look for the same IP?
                        $day_host_counter = 1;
                        $day_host_counter_site = strlen($SITE_ID) > 0 ? 1 : 0;
                        $strSql = "\n\t\t\t\t\t\t\tSELECT S.FIRST_SITE_ID\n\t\t\t\t\t\t\tFROM b_stat_session S\n\t\t\t\t\t\t\tWHERE S.IP_FIRST_NUMBER = " . $REMOTE_ADDR_NUMBER . "\n\t\t\t\t\t\t\t\tAND S.DATE_STAT=" . $DB_now_date . "\n\t\t\t\t\t\t";
                        $e = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                        while ($er = $e->Fetch()) {
                            $day_host_counter = 0;
                            if ($SITE_ID == $er["FIRST_SITE_ID"]) {
                                $day_host_counter_site = 0;
                                break;
                            }
                        }
                        $_SESSION["SESS_SESSION_ID"] = intval($DB->Insert("b_stat_session", $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__));
                        if ($ERROR_404 == "N") {
                            CStatistics::Set404("b_stat_session", "ID = " . $_SESSION["SESS_SESSION_ID"], array("URL_TO_404" => "Y", "URL_LAST_404" => "Y"));
                        }
                        $day_guest_counter = 0;
                        $new_guest_counter = 0;
                        // new guest
                        if ($_SESSION["SESS_GUEST_NEW"] == "Y") {
                            // update day statistic
                            $day_guest_counter = 1;
                            $new_guest_counter = 1;
                        } else {
                            // first hit for today
                            if ($_SESSION["SESS_LAST"] != "Y") {
                                // update day statistic
                                $day_guest_counter = 1;
                                $_SESSION["SESS_LAST"] = "Y";
                            }
                        }
                        // update day counter
                        $arFields = array("SESSIONS" => 1, "C_HOSTS" => intval($day_host_counter), "GUESTS" => intval($day_guest_counter), "NEW_GUESTS" => intval($new_guest_counter), "SESSION" => 1, "HOST" => intval($day_host_counter), "GUEST" => intval($day_guest_counter), "NEW_GUEST" => intval($new_guest_counter));
                        // when current day is already exists
                        // we have to update it
                        $rows = CTraffic::IncParam($arFields);
                        if ($rows !== false && $rows <= 0) {
                            // add new one
                            CStatistics::SetNewDay(1, 0, 1, 0, intval($new_guest_counter), 1);
                            // and update it
                            CTraffic::IncParam(array("SESSION" => 1, "HOST" => 1, "GUEST" => 1, "NEW_GUEST" => intval($new_guest_counter)));
                        }
                        // site is not defined
                        if (strlen($SITE_ID) > 0) {
                            // обновляем счетчик "по дням" для текущего сайта
                            $arFields = array("SESSIONS" => 1, "C_HOSTS" => intval($day_host_counter_site), "SESSION" => 1, "HOST" => intval($day_host_counter_site));
                            // обновим счетчики траффика для текущего дня
                            $rows = CTraffic::IncParam(array(), $arFields, $SITE_ID);
                            // если текущего дня для сайта в базе еще нет то
                            if ($rows !== false && intval($rows) <= 0) {
                                // добавляем его
                                CStatistics::SetNewDayForSite($SITE_ID, 1, 0, 1);
                                // обновим счетчики траффика для текущего дня
                                CTraffic::IncParam(array(), array("SESSION" => 1, "HOST" => 1), $SITE_ID);
                            }
                        }
                        // если страна определена то
                        if (strlen($_SESSION["SESS_COUNTRY_ID"]) > 0) {
                            $arFields = array("SESSIONS" => 1, "NEW_GUESTS" => $new_guest_counter);
                            CStatistics::UpdateCountry($_SESSION["SESS_COUNTRY_ID"], $arFields);
                        }
                        if ($_SESSION["SESS_CITY_ID"] > 0) {
                            $arFields = array("SESSIONS" => 1, "NEW_GUESTS" => $new_guest_counter);
                            CStatistics::UpdateCity($_SESSION["SESS_CITY_ID"], $arFields);
                        }
                        // обновляем гостя
                        $arFields = array("SESSIONS" => "SESSIONS + 1", "LAST_SESSION_ID" => $_SESSION["SESS_SESSION_ID"], "LAST_USER_AGENT" => "'" . $DB->ForSql($_SERVER["HTTP_USER_AGENT"], 500) . "'", "LAST_COUNTRY_ID" => "'" . $DB->ForSql($_SESSION["SESS_COUNTRY_ID"], 2) . "'", "LAST_CITY_ID" => $_SESSION["SESS_CITY_ID"] > 0 ? intval($_SESSION["SESS_CITY_ID"]) : "null");
                        //
                        if ($obCity) {
                            $arFields["LAST_CITY_INFO"] = "'" . $obCity->ForSQL() . "'";
                        }
                        // если это прямой заход по рекламной кампании то
                        if (intval($_SESSION["SESS_ADV_ID"]) > 0) {
                            // обновляем рекламную кампанию последнего захода гостя
                            $arFields["LAST_ADV_ID"] = intval($_SESSION["SESS_ADV_ID"]);
                            $arFields["LAST_ADV_BACK"] = "'N'";
                            $arFields["LAST_REFERER1"] = "'" . $DB->ForSql($_SESSION["referer1"], 255) . "'";
                            $arFields["LAST_REFERER2"] = "'" . $DB->ForSql($_SESSION["referer2"], 255) . "'";
                            $arFields["LAST_REFERER3"] = "'" . $DB->ForSql($_SESSION["referer3"], 255) . "'";
                        } elseif (intval($_SESSION["SESS_LAST_ADV_ID"]) > 0) {
                            // взводим флаг возврата на последнем заходе гостя
                            $arFields["LAST_ADV_BACK"] = "'Y'";
                            $arFields["LAST_REFERER1"] = "'" . $DB->ForSql($arGuest["last_referer1"], 255) . "'";
                            $arFields["LAST_REFERER2"] = "'" . $DB->ForSql($arGuest["last_referer2"], 255) . "'";
                        }
                        if ($_SESSION["SESS_GUEST_NEW"] == "Y") {
                            $arFields["FIRST_SESSION_ID"] = $_SESSION["SESS_SESSION_ID"];
                        }
                        $rows = $DB->Update("b_stat_guest", $arFields, "WHERE ID=" . intval($_SESSION["SESS_GUEST_ID"]), "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                        // обновляем рекламные кампании
                        if (intval($_SESSION["SESS_ADV_ID"]) > 0 || intval($_SESSION["SESS_LAST_ADV_ID"]) > 0) {
                            CStatistics::Update_Adv();
                        }
                        /************************************************
                        					Referring sites
                        			************************************************/
                        if ($SAVE_REFERERS != "N" && __GetReferringSite($PROT, $SN, $SN_WithoutPort, $PAGE_FROM) && strlen($SN) > 0 && $SN != $_SERVER["HTTP_HOST"]) {
                            $REFERER_LIST_ID = CStatistics::GetRefererListID($PROT, $SN, $PAGE_FROM, $CURRENT_URI, $ERROR_404, $sql_site);
                            /************************************************
                            					Search phrases
                            			************************************************/
                            if (substr($SN, 0, 4) == "www.") {
                                $sql = "('" . $DB->ForSql(substr($SN, 4), 255) . "' like P.DOMAIN or '" . $DB->ForSql($SN, 255) . "' like P.DOMAIN)";
                            } else {
                                $sql = "'" . $DB->ForSql($SN, 255) . "' like P.DOMAIN";
                            }
                            $strSql = "\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tS.ID,\n\t\t\t\t\t\t\t\t\tS.NAME,\n\t\t\t\t\t\t\t\t\tP.DOMAIN,\n\t\t\t\t\t\t\t\t\tP.VARIABLE,\n\t\t\t\t\t\t\t\t\tP.CHAR_SET\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tb_stat_searcher S,\n\t\t\t\t\t\t\t\t\tb_stat_searcher_params P\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tS.ACTIVE='Y'\n\t\t\t\t\t\t\t\tand\tP.SEARCHER_ID = S.ID\n\t\t\t\t\t\t\t\tand\t" . $sql . "\n\t\t\t\t\t\t\t";
                            $q = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                            if ($qr = $q->Fetch()) {
                                $_SESSION["FROM_SEARCHER_ID"] = $qr["ID"];
                                $FROM_SEARCHER_NAME = $qr["NAME"];
                                $FROM_SEARCHER_PHRASE = "";
                                if (strlen($qr["VARIABLE"]) > 0) {
                                    $page = substr($PAGE_FROM, strpos($PAGE_FROM, "?") + 1);
                                    $bIsUTF8 = is_utf8_url($page);
                                    parse_str($page, $arr);
                                    $arrVar = explode(",", $qr["VARIABLE"]);
                                    foreach ($arrVar as $var) {
                                        $var = trim($var);
                                        $phrase = $arr[$var];
                                        if (get_magic_quotes_gpc()) {
                                            $phrase = stripslashes($phrase);
                                        }
                                        if ($bIsUTF8) {
                                            $phrase_temp = trim($APPLICATION->ConvertCharset($phrase, "utf-8", LANG_CHARSET));
                                            if (strlen($phrase_temp)) {
                                                $phrase = $phrase_temp;
                                            }
                                        } elseif (strlen($qr["CHAR_SET"]) > 0) {
                                            $phrase_temp = trim($APPLICATION->ConvertCharset($phrase, $qr["CHAR_SET"], LANG_CHARSET));
                                            if (strlen($phrase_temp)) {
                                                $phrase = $phrase_temp;
                                            }
                                        }
                                        $phrase = trim($phrase);
                                        if (strlen($phrase)) {
                                            $FROM_SEARCHER_PHRASE .= strlen($FROM_SEARCHER_PHRASE) > 0 ? " / " . $phrase : $phrase;
                                        }
                                    }
                                }
                                //echo "FROM_SEARCHER_PHRASE = ".$FROM_SEARCHER_PHRASE."<br>\n";
                                // если извлекли поисковую фразу, то занесем ее в базу
                                if (strlen($FROM_SEARCHER_PHRASE) > 0) {
                                    $arFields = array("DATE_HIT" => $DB_now, "SEARCHER_ID" => intval($_SESSION["FROM_SEARCHER_ID"]), "REFERER_ID" => $REFERER_LIST_ID, "PHRASE" => "'" . $DB->ForSql($FROM_SEARCHER_PHRASE, 255) . "'", "URL_FROM" => "'" . $DB->ForSql($PROT . $SN . $PAGE_FROM, 2000) . "'", "URL_TO" => "'" . $DB->ForSql($CURRENT_URI, 2000) . "'", "URL_TO_404" => "'" . $ERROR_404 . "'", "SESSION_ID" => $_SESSION["SESS_SESSION_ID"], "SITE_ID" => $sql_site);
                                    $id = $DB->Insert("b_stat_phrase_list", $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                                    if ($ERROR_404 == "N") {
                                        CStatistics::Set404("b_stat_phrase_list", "ID = " . intval($id), array("URL_TO_404" => "Y"));
                                    }
                                    // запомним поисковую фразу в сессии
                                    $_SESSION["SESS_SEARCH_PHRASE"] = $FROM_SEARCHER_PHRASE;
                                    // увеличим счетчик фраз у поисковой системы
                                    $_SESSION["SESS_FROM_SEARCHERS"][] = $_SESSION["FROM_SEARCHER_ID"];
                                    $arFields = array("PHRASES" => "PHRASES + 1");
                                    $rows = $DB->Update("b_stat_searcher", $arFields, "WHERE ID=" . intval($_SESSION["FROM_SEARCHER_ID"]), "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                                }
                            }
                        }
                    }
                    /************************************************
                    						Hits
                    			************************************************/
                    if ($_SESSION["SESS_SESSION_ID"] > 0) {
                        if ($SAVE_HITS != "N") {
                            // добавляем хит
                            $arFields = array("SESSION_ID" => $_SESSION["SESS_SESSION_ID"], "DATE_HIT" => $DB_now, "GUEST_ID" => intval($_SESSION["SESS_GUEST_ID"]), "NEW_GUEST" => "'" . $DB->ForSql($_SESSION["SESS_GUEST_NEW"]) . "'", "USER_ID" => intval($_SESSION["SESS_LAST_USER_ID"]), "USER_AUTH" => "'" . $IS_USER_AUTHORIZED . "'", "URL" => "'" . $DB->ForSql($CURRENT_URI, 2000) . "'", "URL_404" => "'" . $ERROR_404 . "'", "URL_FROM" => "'" . $DB->ForSql(isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "", 2000) . "'", "IP" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "METHOD" => "'" . $DB->ForSql($_SERVER["REQUEST_METHOD"], 10) . "'", "COOKIES" => "'" . $DB->ForSql(GetCookieString(), 2000) . "'", "USER_AGENT" => "'" . $DB->ForSql($_SERVER["HTTP_USER_AGENT"], 500) . "'", "STOP_LIST_ID" => "'" . $STOP_LIST_ID . "'", "COUNTRY_ID" => "'" . $DB->ForSql($_SESSION["SESS_COUNTRY_ID"], 2) . "'", "CITY_ID" => $_SESSION["SESS_CITY_ID"] > 0 ? intval($_SESSION["SESS_CITY_ID"]) : "null", "SITE_ID" => $sql_site);
                            self::$HIT_ID = intval($DB->Insert("b_stat_hit", $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__));
                            if ($ERROR_404 == "N") {
                                CStatistics::Set404("b_stat_hit", "ID = " . self::$HIT_ID, array("URL_404" => "Y"));
                            }
                        }
                        // если гость на данном хите добавил в фавориты и до этого еще не добавлял то
                        $favorites_counter = 0;
                        if ($FAVORITES == "Y" && $_SESSION["SESS_GUEST_FAVORITES"] == "N") {
                            $ALLOW_ADV_FAVORITES = "Y";
                            $_SESSION["SESS_GUEST_FAVORITES"] = "Y";
                            $favorites_counter = 1;
                        }
                        // обновляем счетчик "по дням"
                        $arFields = array("HITS" => 1, "FAVORITES" => $favorites_counter, "HIT" => 1, "FAVORITE" => $favorites_counter);
                        // если текущий день есть в базе то
                        // обновим счетчики траффика для текущего дня
                        $rows = CTraffic::IncParam($arFields);
                        if ($rows !== false && intval($rows) <= 0) {
                            // если текущий день не определен в базе то
                            // добавляем его
                            $new_guest_counter = $_SESSION["SESS_GUEST_NEW"] == "Y" ? 1 : 0;
                            CStatistics::SetNewDay(1, 0, 1, 1, $new_guest_counter, 1, $favorites_counter);
                            // обновим счетчики траффика для текущего дня
                            CTraffic::IncParam(array("SESSION" => 1, "HIT" => 1, "HOST" => 1, "GUEST" => 1, "NEW_GUEST" => $new_guest_counter, "FAVORITE" => $favorites_counter));
                        }
                        // если сайт определен то
                        if (strlen($SITE_ID) > 0) {
                            // обновляем счетчик "по дням"
                            $arFields = array("HITS" => 1, "HIT" => 1);
                            // если текущий день сайта определен в базе то
                            // обновим счетчики траффика для текущего дня
                            $rows = CTraffic::IncParam(array(), $arFields, $SITE_ID);
                            if ($rows !== false && intval($rows) <= 0) {
                                // если текущий день сайта не определен в базе то
                                // добавляем его
                                CStatistics::SetNewDayForSite($SITE_ID, 1, 0, 1, 1);
                                // обновим счетчики траффика для текущего дня
                                CTraffic::IncParam(array(), array("SESSION" => 1, "HIT" => 1, "HOST" => 1), $SITE_ID);
                            }
                        }
                        /************************************************
                        							Пути по сайту
                        			************************************************/
                        if ($SAVE_PATH_DATA != "N") {
                            CStatistics::SavePathData($SITE_ID, $CURRENT_PAGE, $ERROR_404);
                        }
                        /************************************************
                        						Посещение разделов и страниц
                        			************************************************/
                        if ($SAVE_VISITS != "N") {
                            CStatistics::SaveVisits($sql_site, $SESSION_NEW, $CURRENT_DIR, $CURRENT_PAGE, $ERROR_404);
                        }
                        // обновляем сессию
                        $arFields = array("LAST_HIT_ID" => self::$HIT_ID, "URL_LAST" => "'" . $DB->ForSql($CURRENT_URI, 2000) . "'", "URL_LAST_404" => "'" . $ERROR_404 . "'", "DATE_LAST" => $DB_now, "LAST_SITE_ID" => $sql_site);
                        if ($SESSION_NEW == "Y") {
                            $arFields["FIRST_HIT_ID"] = self::$HIT_ID;
                        }
                        if ($FAVORITES == "Y") {
                            $arFields["FAVORITES"] = "'Y'";
                        }
                        $DB->Update("b_stat_session", $arFields, "WHERE ID=" . $_SESSION["SESS_SESSION_ID"], "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                        if ($ERROR_404 == "N") {
                            CStatistics::Set404("b_stat_session", "ID = " . $_SESSION["SESS_SESSION_ID"], array("URL_LAST_404" => "Y"));
                        }
                        // обновляем гостя
                        $arFields = array("HITS" => "HITS + 1", "LAST_SESSION_ID" => $_SESSION["SESS_SESSION_ID"], "LAST_DATE" => $DB_now, "LAST_USER_ID" => intval($_SESSION["SESS_LAST_USER_ID"]), "LAST_USER_AUTH" => "'" . $IS_USER_AUTHORIZED . "'", "LAST_URL_LAST" => "'" . $DB->ForSql($CURRENT_URI, 2000) . "'", "LAST_URL_LAST_404" => "'" . $ERROR_404 . "'", "LAST_USER_AGENT" => "'" . $DB->ForSql($_SERVER["HTTP_USER_AGENT"], 500) . "'", "LAST_IP" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "LAST_COOKIE" => "'" . $DB->ForSql(GetCookieString(), 2000) . "'", "LAST_LANGUAGE" => "'" . $DB->ForSql($_SERVER["HTTP_ACCEPT_LANGUAGE"], 255) . "'", "LAST_SITE_ID" => $sql_site);
                        if ($FAVORITES == "Y") {
                            $arFields["FAVORITES"] = "'Y'";
                        }
                        $DB->Update("b_stat_guest", $arFields, "WHERE ID=" . intval($_SESSION["SESS_GUEST_ID"]), "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                        if ($ERROR_404 == "N") {
                            CStatistics::Set404("b_stat_guest", "ID = " . intval($_SESSION["SESS_GUEST_ID"]), array("LAST_URL_LAST_404" => "Y"));
                        }
                        // обновляем прямые рекламные кампании
                        if (intval($_SESSION["SESS_ADV_ID"]) > 0) {
                            // увеличиваем счетчик хитов на прямом заходе
                            $arFields = array("DATE_LAST" => $DB_now, "HITS" => "HITS+1");
                            if ($FAVORITES == "Y" && $ALLOW_ADV_FAVORITES == "Y") {
                                // увеличиваем счетчик посетителей добавивших в избранное на прямом заходе
                                $arFields["FAVORITES"] = "FAVORITES + 1";
                                $favorite = 1;
                            }
                            $DB->Update("b_stat_adv", $arFields, "WHERE ID=" . intval($_SESSION["SESS_ADV_ID"]), "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                            // обновляем счетчик хитов по дням
                            $arFields = array("HITS" => "HITS+1", "FAVORITES" => "FAVORITES + " . intval($favorite));
                            $rows = $DB->Update("b_stat_adv_day", $arFields, "WHERE ADV_ID=" . intval($_SESSION["SESS_ADV_ID"]) . " and DATE_STAT=" . $DB_now_date, "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                            // если его нет то
                            if (intval($rows) <= 0) {
                                // добавляем его
                                $arFields = array("ADV_ID" => intval($_SESSION["SESS_ADV_ID"]), "DATE_STAT" => $DB_now_date, "HITS" => 1, "FAVORITES" => intval($favorite));
                                $DB->Insert("b_stat_adv_day", $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                            }
                        } elseif (intval($_SESSION["SESS_LAST_ADV_ID"]) > 0) {
                            // увеличиваем счетчик хитов на возврате
                            $arFields = array("DATE_LAST" => $DB_now, "HITS_BACK" => "HITS_BACK+1");
                            if ($FAVORITES == "Y" && $ALLOW_ADV_FAVORITES == "Y") {
                                // увеличиваем счетчик посетителей добавивших в избранное на возврате
                                $arFields["FAVORITES_BACK"] = "FAVORITES_BACK + 1";
                                $favorite = 1;
                            }
                            $DB->Update("b_stat_adv", $arFields, "WHERE ID=" . intval($_SESSION["SESS_LAST_ADV_ID"]), "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                            $arFields = array("HITS_BACK" => "HITS_BACK+1", "FAVORITES_BACK" => "FAVORITES_BACK + " . intval($favorite));
                            // обновляем счетчик хитов по дням
                            $rows = $DB->Update("b_stat_adv_day", $arFields, "WHERE ADV_ID=" . intval($_SESSION["SESS_LAST_ADV_ID"]) . " and DATE_STAT=" . $DB_now_date, "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                            // если его нет то
                            if (intval($rows) <= 0) {
                                // добавляем его
                                $arFields = array("ADV_ID" => intval($_SESSION["SESS_LAST_ADV_ID"]), "DATE_STAT" => $DB_now_date, "HITS_BACK" => 1, "FAVORITES_BACK" => intval($favorite));
                                $DB->Insert("b_stat_adv_day", $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                            }
                        }
                        // обрабатываем событие
                        if (defined("GENERATE_EVENT") && GENERATE_EVENT == "Y") {
                            global $event1, $event2, $event3, $goto, $money, $currency, $site_id;
                            if (strlen($site_id) <= 0) {
                                $site_id = false;
                            }
                            CStatistics::Set_Event($event1, $event2, $event3, $goto, $money, $currency, $site_id);
                        }
                        // увеличиваем счетчик хитов у страны
                        if (strlen($_SESSION["SESS_COUNTRY_ID"]) > 0) {
                            CStatistics::UpdateCountry($_SESSION["SESS_COUNTRY_ID"], array("HITS" => 1));
                        }
                        if ($_SESSION["SESS_CITY_ID"] > 0) {
                            CStatistics::UpdateCity($_SESSION["SESS_CITY_ID"], array("HITS" => 1));
                        }
                        if (isset($_SESSION["SESS_FROM_SEARCHERS"]) && is_array($_SESSION["SESS_FROM_SEARCHERS"]) && !empty($_SESSION["SESS_FROM_SEARCHERS"])) {
                            // обновляем счетчик хитов у поисковых фраз для поисковиков
                            $arFields = array("PHRASES_HITS" => "PHRASES_HITS+1");
                            $_SESSION["SESS_FROM_SEARCHERS"] = array_unique($_SESSION["SESS_FROM_SEARCHERS"]);
                            if (count($_SESSION["SESS_FROM_SEARCHERS"]) > 0) {
                                $str = "0";
                                foreach ($_SESSION["SESS_FROM_SEARCHERS"] as $value) {
                                    $str .= ", " . intval($value);
                                }
                                $DB->Update("b_stat_searcher", $arFields, "WHERE ID in ({$str})", "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                            }
                        }
                        if (isset($_SESSION["SESS_REFERER_ID"]) && intval($_SESSION["SESS_REFERER_ID"]) > 0) {
                            // обновляем ссылающиеся
                            $arFields = array("HITS" => "HITS+1");
                            $DB->Update("b_stat_referer", $arFields, "WHERE ID=" . intval($_SESSION["SESS_REFERER_ID"]), "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                        }
                    }
                    /*******************************************************
                    				Переменные хранящие параметры предыдущей страницы
                    			*******************************************************/
                    $_SESSION["SESS_HTTP_REFERER"] = $_SESSION["SESS_LAST_URI"];
                    $_SESSION["SESS_LAST_PROTOCOL"] = $CURRENT_PROTOCOL;
                    $_SESSION["SESS_LAST_PORT"] = $CURRENT_PORT;
                    $_SESSION["SESS_LAST_HOST"] = $CURRENT_HOST;
                    $_SESSION["SESS_LAST_URI"] = $CURRENT_URI;
                    $_SESSION["SESS_LAST_PAGE"] = $CURRENT_PAGE;
                    $_SESSION["SESS_LAST_DIR"] = $CURRENT_DIR;
                }
            } else {
                /************************************************
                				Обработка превышения лимита активности
                			*************************************************/
                $fname = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/activity_limit.php";
                if (file_exists($fname)) {
                    include $fname;
                } else {
                    CHTTP::SetStatus("503 Service Unavailable");
                    die;
                }
            }
            /************************************************************
            				Обрабатываем ситуацию когда не поддерживаются
            				сессии и/или не сохраняются куки
            			*************************************************************/
            // если мы делали select из таблицы b_stat_session_data то
            if ($SESSION_DATA_ID) {
                $arrSTAT_SESSION = stat_session_register(true);
                $sess_data_for_db = strtolower($DB->type) == "oracle" ? "'" . $DB->ForSql(serialize($arrSTAT_SESSION), 2000) . "'" : "'" . $DB->ForSql(serialize($arrSTAT_SESSION)) . "'";
                // если в результате этого select'а были выбраны данные то
                if (intval($SESSION_DATA_ID) > 0 && $SESSION_DATA_ID !== true) {
                    // обновляем их
                    $arFields = array("DATE_LAST" => $DB_now, "GUEST_MD5" => "'" . get_guest_md5() . "'", "SESS_SESSION_ID" => intval($_SESSION["SESS_SESSION_ID"]), "SESSION_DATA" => $sess_data_for_db);
                    $DB->Update("b_stat_session_data", $arFields, "WHERE ID = " . intval($SESSION_DATA_ID), "File: " . __FILE__ . "<br>Line: " . __LINE__, false, false, false);
                } else {
                    // иначе вставляем эти данные
                    $arFields = array("DATE_FIRST" => $DB_now, "DATE_LAST" => $DB_now, "GUEST_MD5" => "'" . get_guest_md5() . "'", "SESS_SESSION_ID" => intval($_SESSION["SESS_SESSION_ID"]), "SESSION_DATA" => $sess_data_for_db);
                    $DB->Insert("b_stat_session_data", $arFields, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                }
            }
        }
        // if ($STOP_SAVE_STATISTIC!="N" or $STOP!="Y")
        if ($STOP == "Y") {
            $z = CLanguage::GetByID($STOP_MESSAGE_LID);
            $zr = $z->Fetch();
            $charset = strlen($zr["CHARSET"]) > 0 ? $zr["CHARSET"] : "windows-1251";
            //We have URL with no MESSAGE
            if (strlen($STOP_REDIRECT_URL) > 0 && strlen($STOP_MESSAGE) <= 0) {
                //So just do redirect
                LocalRedirect($STOP_REDIRECT_URL, true);
            } elseif (strlen($STOP_MESSAGE) > 0) {
                $STOP_MESSAGE .= " [" . $STOP_LIST_ID . "]";
                echo '<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=' . $charset . '">
		' . (strlen($STOP_REDIRECT_URL) > 0 ? '<meta http-equiv="Refresh" content="3;URL=' . htmlspecialcharsbx($STOP_REDIRECT_URL) . '">' : '') . '
	</head>
	<body>
		<div align="center"><h3>' . $STOP_MESSAGE . '</h3></div>
	</body>
</html>';
            }
            die;
        }
    }
Esempio n. 10
0
            } elseif ($file_type === "MAXMIND-IP-COUNTRY") {
                i2c_create_db($total_reindex, $reindex_success, $step_reindex, $_SESSION["STATWIZ_INT_PREV"], 5, $FILE_NAME, "maxmind.com");
            } elseif ($file_type === "MAXMIND-CITY-LOCATION") {
                $reindex_success = "Y";
            } elseif ($file_type === "MAXMIND-IP-LOCATION") {
                $reindex_success = "Y";
            } else {
                $reindex_success = "Y";
            }
            if ($reindex_success === "Y") {
                echo '<script>Import(2)</script>';
            } else {
                $_SESSION["STATWIZ_TOTAL_REINDEX"] = $total_reindex[0];
                echo "<script>Import(1, {file_position:'" . intval($total_reindex[1]) . "',AMOUNT:" . intval(filesize($ABS_FILE_NAME)) . ",POS:" . intval($total_reindex[1]) . "})</script>";
            }
            break;
        case 2:
            $reindex_success = CCity::LoadCSV($FILE_NAME, 10, $file_position);
            if ($reindex_success === "Y") {
                echo '<script>Import(3)</script>';
            } else {
                echo "<script>Import(2, {file_position:'" . intval($file_position) . "',AMOUNT:" . intval(filesize($ABS_FILE_NAME)) . ",POS:" . intval($file_position) . "})</script>";
            }
            break;
        case 3:
            echo GetMessage("STATWIZ_IMPORT_ALL_DONE") . "<br>";
            echo '<script>EnableButton();</script>';
            break;
    }
}
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
Esempio n. 11
0
 public function __construct($scenario = 'search')
 {
     parent::__construct($scenario);
 }
Esempio n. 12
0
    } else {
        $find_data_type = "SESSIONS";
    }
} elseif ($saved_group_by != $find_data_type) {
    //Set if changed
    $saved_group_by = $find_data_type;
}
InitFilterEx($arSettings, $sTableID . "_settings", "set");
$arrDays = array();
AdminListCheckDate($lAdmin, array("find_date1" => $find_date1, "find_date2" => $find_date2));
$arrLegend = array();
$arrTotalLegend = array();
$arFilter = array("COUNTRY_ID" => $find_country_id < 0 ? "" : $find_country_id, "DATE1" => $find_date1, "DATE2" => $find_date2);
if (strlen($arFilter["COUNTRY_ID"]) == 2) {
    $arrDays = CCity::GetGraphArray($arFilter, $arrLegend, $find_data_type, 20);
    $arrTotalDays = CCity::GetGraphArray($arFilter, $arrTotalLegend, "TOTAL_" . $find_data_type, 20);
} else {
    $lAdmin->AddFilterError(GetMessage("STAT_NO_COUNTRY_ID"));
}
$lAdmin->BeginCustomContent();
if (!function_exists("ImageCreate")) {
    ShowError(GetMessage("STAT_GD_NOT_INSTALLED"));
} else {
    $width = COption::GetOptionString("statistic", "GRAPH_WEIGHT");
    $height = COption::GetOptionString("statistic", "GRAPH_HEIGHT");
    $diameter = COption::GetOptionString("statistic", "DIAGRAM_DIAMETER");
    $found = false;
    foreach ($arrLegend as $key => $val) {
        if ($val[$find_data_type] > 0) {
            $found = true;
            break;