17 include(
'lib' . DIRECTORY_SEPARATOR .
'geoIp' . DIRECTORY_SEPARATOR .
'geoipcity.inc');
33 $geoLocationDbFile = dirname(__FILE__) . DIRECTORY_SEPARATOR .
"GeoLiteCity.dat";
34 if (file_exists($geoLocationDbFile)) {
35 $isDbFilePresent =
true;
36 $this->_geoLocationTool = geoip_open($geoLocationDbFile, GEOIP_STANDARD);
37 include(
'lib' . DIRECTORY_SEPARATOR .
'geoIp' . DIRECTORY_SEPARATOR .
'geoipregionvars.php');
38 $this->_regionName = $GEOIP_REGION_NAME;
40 $isDbFilePresent =
false;
43 $this->_isDbFilePresent = $isDbFilePresent;
65 if (!$this->_geoLocationTool)
return array(
null,
null,
null);
67 $record = geoip_record_by_addr($this->_geoLocationTool, $ip);
70 return array(
null,
null,
null);
74 if(isset($this->_regionName[$record->country_code][$record->region])) {
75 $regionName = $this->_regionName[$record->country_code][$record->region];
79 $record->country_code,
80 utf8_encode($record->city),
90 if (!$this->_geoLocationTool)
return null;
93 $countryCodes =
$tool->GEOIP_COUNTRY_CODES;
97 $countryCodes[0] = STATISTICS_UNKNOWN_COUNTRY_ID;
129 if (isset($database[$countryId])) {
130 $regions = $database[$countryId];
147 if (!$this->_geoLocationTool)
return $returner;
150 if (isset(
$tool->$countryCodeListName)) {
151 $countryCodeList =
$tool->$countryCodeListName;
156 $countryCodesIndex =
$tool->GEOIP_COUNTRY_CODE_TO_NUMBER;
157 $countryCodeIndex =
null;
159 if (isset($countryCodesIndex[$countryCode])) {
160 $countryCodeIndex = $countryCodesIndex[$countryCode];
163 if ($countryCodeIndex) {
164 if (isset($countryCodeList[$countryCodeIndex])) {
165 $returner = $countryCodeList[$countryCodeIndex];