Example #1
0
 public function __construct($arDBRecord = false)
 {
     parent::__construct($arDBRecord);
     $DB = CDatabase::GetModuleConnection('statistic');
     if (!$arDBRecord) {
         $country_recs = COption::GetOptionString("statistic", "COUNTRY_INDEX_LOADED", "N");
         if ($country_recs !== "Y") {
             $rs = $DB->Query(CStatistics::DBTopSql("SELECT /*TOP*/ * FROM b_stat_country", 1));
             if ($rs->Fetch()) {
                 $country_recs = "Y";
                 COption::SetOptionString("statistic", "COUNTRY_INDEX_LOADED", "Y");
             }
         }
         $this->country_avail = $country_recs === "Y";
         if ($this->country_avail) {
             $city_recs = COption::GetOptionString("statistic", "CITY_INDEX_LOADED", "N");
             if ($city_recs !== "Y") {
                 $rs = $DB->Query(CStatistics::DBTopSql("SELECT /*TOP*/ * FROM b_stat_city_ip", 1));
                 if ($rs->Fetch()) {
                     COption::SetOptionString("statistic", "CITY_INDEX_LOADED", "Y");
                 }
             }
             $this->city_avail = COption::GetOptionString("statistic", "CITY_INDEX_LOADED", "N") === "Y";
         }
         $this->is_installed = $this->country_avail;
     }
 }
Example #2
0
 public function __construct($arDBRecord = false)
 {
     parent::__construct($arDBRecord);
     if (!$arDBRecord) {
         if (function_exists("geoip_open") && defined("GEOIP_DATABASE_FILE")) {
             $gi = geoip_open(GEOIP_DATABASE_FILE, defined("GEOIP_MODE") ? GEOIP_MODE : GEOIP_STANDARD);
             if ($gi) {
                 $this->country_avail = function_exists("geoip_country_code_by_addr");
                 $this->city_avail = function_exists("geoip_record_by_addr");
                 geoip_close($gi);
             }
             $this->is_installed = $this->country_avail || $this->city_avail;
         }
         $this->charset = "iso-8859-1";
     } else {
         if (array_key_exists("XPOST", $arDBRecord)) {
             $this->postal_code = $arDBRecord["XPOST"];
         }
         if (array_key_exists("XLAT", $arDBRecord)) {
             $this->latitude = $arDBRecord["XLAT"];
         }
         if (array_key_exists("XLON", $arDBRecord)) {
             $this->longitude = $arDBRecord["XLON"];
         }
     }
 }
Example #3
0
 function __construct($arDBRecord = false)
 {
     parent::__construct($arDBRecord);
     if (!$arDBRecord) {
         if (array_key_exists("GEOIP_COUNTRY_CODE", $_SERVER) && strlen($_SERVER["GEOIP_COUNTRY_CODE"]) == 2) {
             $this->is_installed = true;
             $this->country_code = $_SERVER["GEOIP_COUNTRY_CODE"];
         }
         $this->charset = "iso-8859-1";
     } else {
         if (array_key_exists("XCONT", $arDBRecord)) {
             $this->continent_code = $arDBRecord["XCONT"];
         }
         if (array_key_exists("XLAT", $arDBRecord)) {
             $this->latitude = $arDBRecord["XLAT"];
         }
         if (array_key_exists("XLON", $arDBRecord)) {
             $this->longitude = $arDBRecord["XLON"];
         }
     }
 }
Example #4
0
 public function __construct($arDBRecord = false)
 {
     parent::__construct($arDBRecord);
     if (!$arDBRecord) {
         if (function_exists("geoip_db_avail")) {
             $this->country_avail = geoip_db_avail(GEOIP_COUNTRY_EDITION);
             $this->city_avail = geoip_db_avail(GEOIP_CITY_EDITION_REV0) || geoip_db_avail(GEOIP_CITY_EDITION_REV1);
             $this->is_installed = $this->country_avail || $this->city_avail;
         }
         $this->charset = "iso-8859-1";
     } else {
         if (array_key_exists("XPOST", $arDBRecord)) {
             $this->postal_code = $arDBRecord["XPOST"];
         }
         if (array_key_exists("XLAT", $arDBRecord)) {
             $this->latitude = $arDBRecord["XLAT"];
         }
         if (array_key_exists("XLON", $arDBRecord)) {
             $this->longitude = $arDBRecord["XLON"];
         }
     }
 }