1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
geoip_extension.php
См. документацию.
1<?
3/*
4Array
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] => 54.7099990845
13 [longitude] => 20.5
14 [dma_code] => 0
15 [area_code] => 0
16)
17
18*/
20{
21 var $country_avail = false;
22 var $city_avail = false;
23
24 var $postal_code = false;
25 var $latitude = false;
26 var $longitude = false;
27
28 public static function OnCityLookup($arDBRecord = false)
29 {
30 return new CCityLookup_geoip_extension($arDBRecord);
31 }
32
33 function __construct($arDBRecord = false)
34 {
35 parent::__construct($arDBRecord);
36 if(!$arDBRecord)
37 {
38 if(function_exists("geoip_db_avail"))
39 {
40 $this->country_avail = geoip_db_avail(GEOIP_COUNTRY_EDITION);
41 $this->city_avail = geoip_db_avail(GEOIP_CITY_EDITION_REV0) || geoip_db_avail(GEOIP_CITY_EDITION_REV1);
42 $this->is_installed = $this->country_avail || $this->city_avail;
43 }
44 $this->charset = "iso-8859-1";
45 }
46 else
47 {
48 if(array_key_exists("XPOST", $arDBRecord)) $this->postal_code = $arDBRecord["XPOST"];
49 if(array_key_exists("XLAT", $arDBRecord)) $this->latitude = $arDBRecord["XLAT"];
50 if(array_key_exists("XLON", $arDBRecord)) $this->longitude = $arDBRecord["XLON"];
51 }
52 }
53
54 function ArrayForDB()
55 {
56 $ar = parent::ArrayForDB();
57 if($this->postal_code) $ar["XPOST"] = $this->postal_code;
58 if($this->latitude) $ar["XLAT"] = $this->latitude;
59 if($this->longitude) $ar["XLON"] = $this->longitude;
60 return $ar;
61 }
62
63 function GetFullInfo()
64 {
65 $ar = parent::GetFullInfo();
66 $ar["POSTAL_CODE"] = array(
67 "TITLE" => GetMessage("STAT_CITY_GEOIP_EXT_POSTAL_CODE"),
68 "VALUE~" => $this->postal_code,
69 "VALUE" => htmlspecialcharsbx($this->postal_code),
70 );
71 $ar["LONGITUDE"] = array(
72 "TITLE" => GetMessage("STAT_CITY_GEOIP_EXT_LONGITUDE"),
73 "VALUE~" => $this->longitude,
74 "VALUE" => htmlspecialcharsbx($this->longitude),
75 );
76 $ar["LATITUDE"] = array(
77 "TITLE" => GetMessage("STAT_CITY_GEOIP_EXT_LATITUDE"),
78 "VALUE~" => $this->latitude,
79 "VALUE" => htmlspecialcharsbx($this->latitude),
80 );
81 return $ar;
82 }
83
84 function GetDescription()
85 {
86 return array(
87 "CLASS" => "CCityLookup_geoip_extension",
88 "DESCRIPTION" => GetMessage("STAT_CITY_GEOIP_EXT_DESCR"),
89 "IS_INSTALLED" => $this->is_installed,
90 "CAN_LOOKUP_COUNTRY" => $this->country_avail || $this->city_avail,
91 "CAN_LOOKUP_CITY" => $this->city_avail,
92 );
93 }
94
95 function IsInstalled()
96 {
98 }
99
100 function Lookup()
101 {
102 if($this->city_avail)
103 {
104 $ar = geoip_record_by_name($_SERVER['REMOTE_ADDR']);
105 $this->country_code = $ar["country_code"];
106 $this->country_short_name = $ar["country_code3"];
107 $this->country_full_name = $ar["country_name"];
108 $this->region_name = $ar["region"];
109 $this->city_name = $ar["city"];
110 //Extended info
111 $this->postal_code = $ar["postal_code"];
112 $this->latitude = $ar["latitude"];
113 $this->longitude = $ar["longitude"];
114 }
115 elseif($this->country_avail)
116 {
117 $this->country_code = geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
118 }
119 }
120}
121?>
static OnCityLookup($arDBRecord=false)
Определения geoip_extension.php:28
__construct($arDBRecord=false)
Определения geoip_extension.php:33
Определения 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