1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
geoip_pure.php
См. документацию.
1<?
3/*
4geoiprecord Object
5(
6 [country_code] => RU
7 [country_code3] => RUS
8 [country_name] => Russian Federation
9 [region] => 23
10 [city] => Kaliningrad
11 [postal_code] =>
12 [latitude] => -122.2372
13 [longitude] => 69.82
14 [area_code] =>
15 [dma_code] =>
16)
17*/
19{
20 var $country_avail = false;
21 var $city_avail = false;
22
23 var $postal_code = false;
24 var $latitude = false;
25 var $longitude = false;
26
27 public static function OnCityLookup($arDBRecord = false)
28 {
29 return new CCityLookup_geoip_pure($arDBRecord);
30 }
31
32 function __construct($arDBRecord = false)
33 {
34 parent::__construct($arDBRecord);
35 if(!$arDBRecord)
36 {
37 if(function_exists("geoip_open") && defined("GEOIP_DATABASE_FILE"))
38 {
39 $gi = geoip_open(GEOIP_DATABASE_FILE, defined("GEOIP_MODE")? GEOIP_MODE: GEOIP_STANDARD);
40 if($gi)
41 {
42 $this->country_avail = function_exists("geoip_country_code_by_addr");
43 $this->city_avail = function_exists("geoip_record_by_addr");
44 geoip_close($gi);
45 }
46 $this->is_installed = $this->country_avail || $this->city_avail;
47 }
48 $this->charset = "iso-8859-1";
49 }
50 else
51 {
52 if(array_key_exists("XPOST", $arDBRecord)) $this->postal_code = $arDBRecord["XPOST"];
53 if(array_key_exists("XLAT", $arDBRecord)) $this->latitude = $arDBRecord["XLAT"];
54 if(array_key_exists("XLON", $arDBRecord)) $this->longitude = $arDBRecord["XLON"];
55 }
56 }
57
58 function ArrayForDB()
59 {
60 $ar = parent::ArrayForDB();
61 if($this->postal_code) $ar["XPOST"] = $this->postal_code;
62 if($this->latitude) $ar["XLAT"] = $this->latitude;
63 if($this->longitude) $ar["XLON"] = $this->longitude;
64 return $ar;
65 }
66
67 function GetFullInfo()
68 {
69 $ar = parent::GetFullInfo();
70 $ar["POSTAL_CODE"] = array(
71 "TITLE" => GetMessage("STAT_CITY_GEOIP_PHP_POSTAL_CODE"),
72 "VALUE~" => $this->postal_code,
73 "VALUE" => htmlspecialcharsbx($this->postal_code),
74 );
75 $ar["LONGITUDE"] = array(
76 "TITLE" => GetMessage("STAT_CITY_GEOIP_PHP_LONGITUDE"),
77 "VALUE~" => $this->longitude,
78 "VALUE" => htmlspecialcharsbx($this->longitude),
79 );
80 $ar["LATITUDE"] = array(
81 "TITLE" => GetMessage("STAT_CITY_GEOIP_PHP_LATITUDE"),
82 "VALUE~" => $this->latitude,
83 "VALUE" => htmlspecialcharsbx($this->latitude),
84 );
85 return $ar;
86 }
87
88
89 function GetDescription()
90 {
91 return array(
92 "CLASS" => "CCityLookup_geoip_pure",
93 "DESCRIPTION" => GetMessage("STAT_CITY_GEOIP_PHP_DESCR"),
94 "IS_INSTALLED" => $this->is_installed,
95 "CAN_LOOKUP_COUNTRY" => $this->country_avail || $this->city_avail,
96 "CAN_LOOKUP_CITY" => $this->city_avail,
97 );
98 }
99
100 function IsInstalled()
101 {
102 return $this->is_installed;
103 }
104
105 function Lookup()
106 {
107 $gi = geoip_open(GEOIP_DATABASE_FILE, defined("GEOIP_MODE")? GEOIP_MODE: GEOIP_STANDARD);
108 if($gi)
109 {
110 if($this->city_avail)
111 {
112 $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
113 $this->country_code = $record->country_code;
114 $this->country_short_name = $record->country_code3;
115 $this->country_full_name = $record->country_name;
116 $this->region_name = $record->region;
117 $this->city_name = $record->city;
118 //Extended info
119 $this->postal_code = $record->postal_code;
120 $this->latitude = $record->latitude;
121 $this->longitude = $record->longitude;
122 }
123 elseif($this->country_avail)
124 {
125 $this->country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
126 }
127 geoip_close($gi);
128 }
129 }
130}
131?>
$city_avail
Определения geoip_pure.php:21
ArrayForDB()
Определения geoip_pure.php:58
GetFullInfo()
Определения geoip_pure.php:67
$country_avail
Определения geoip_pure.php:20
static OnCityLookup($arDBRecord=false)
Определения geoip_pure.php:27
IsInstalled()
Определения geoip_pure.php:100
$postal_code
Определения geoip_pure.php:23
GetDescription()
Определения geoip_pure.php:89
__construct($arDBRecord=false)
Определения geoip_pure.php:32
Определения city.php:10
$is_installed
Определения city.php:11
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199