Version Notes
Notes
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | AutoCurrency |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/community/Chapagain/AutoCurrency/Helper/Data.php +39 -0
- app/code/community/Chapagain/AutoCurrency/Model/Store.php +54 -0
- app/code/community/Chapagain/AutoCurrency/etc/config.xml +22 -0
- app/etc/modules/Chapagain_AutoCurrency.xml +9 -0
- package.xml +28 -0
- var/geoip/GeoIP.dat +0 -0
- var/geoip/geoip.inc +611 -0
app/code/community/Chapagain/AutoCurrency/Helper/Data.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Loads GeoIP binary data files
|
| 4 |
+
*
|
| 5 |
+
* @category Chapagain
|
| 6 |
+
* @package Chapagain_AutoCurrency
|
| 7 |
+
* @version 0.1.0
|
| 8 |
+
* @author Mukesh Chapagain <mukesh.chapagain@gmail.com>
|
| 9 |
+
* @link http://blog.chapagain.com.np/category/magento/
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
class Chapagain_AutoCurrency_Helper_Data extends Mage_Core_Helper_Abstract
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* Load GeoIP binary data file
|
| 16 |
+
*
|
| 17 |
+
* @return string
|
| 18 |
+
*/
|
| 19 |
+
public function loadGeoIp()
|
| 20 |
+
{
|
| 21 |
+
// Load geoip.inc
|
| 22 |
+
include_once(Mage::getBaseDir().'/var/geoip/geoip.inc');
|
| 23 |
+
|
| 24 |
+
// Open Geo IP binary data file
|
| 25 |
+
$geoIp = geoip_open(Mage::getBaseDir().'/var/geoip/GeoIP.dat',GEOIP_STANDARD);
|
| 26 |
+
|
| 27 |
+
return $geoIp;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Get IP Address
|
| 32 |
+
*
|
| 33 |
+
* @return string
|
| 34 |
+
*/
|
| 35 |
+
public function getIpAddress()
|
| 36 |
+
{
|
| 37 |
+
return $_SERVER['REMOTE_ADDR'];
|
| 38 |
+
}
|
| 39 |
+
}
|
app/code/community/Chapagain/AutoCurrency/Model/Store.php
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Rewrites Mage_Core_Model_Store
|
| 4 |
+
* Returns currency code based on visitor's IP Address
|
| 5 |
+
*
|
| 6 |
+
* @category Chapagain
|
| 7 |
+
* @package Chapagain_AutoCurrency
|
| 8 |
+
* @version 0.1.0
|
| 9 |
+
* @author Mukesh Chapagain <mukesh.chapagain@gmail.com>
|
| 10 |
+
* @link http://blog.chapagain.com.np/category/magento/
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
class Chapagain_AutoCurrency_Model_Store extends Mage_Core_Model_Store
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* Update default store currency code
|
| 17 |
+
*
|
| 18 |
+
* @return string
|
| 19 |
+
*/
|
| 20 |
+
public function getDefaultCurrencyCode()
|
| 21 |
+
{
|
| 22 |
+
$result = $this->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT);
|
| 23 |
+
|
| 24 |
+
return $this->getCurrencyCodeByIp($result);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Get Currency code by IP Address
|
| 29 |
+
*
|
| 30 |
+
* @return string
|
| 31 |
+
*/
|
| 32 |
+
public function getCurrencyCodeByIp($result = '')
|
| 33 |
+
{
|
| 34 |
+
// load GeoIP binary data file
|
| 35 |
+
$geoIp = Mage::helper('autocurrency')->loadGeoIp();
|
| 36 |
+
|
| 37 |
+
$ipAddress = Mage::helper('autocurrency')->getIpAddress();
|
| 38 |
+
|
| 39 |
+
// get country code from ip address
|
| 40 |
+
$countryCode = geoip_country_code_by_addr($geoIp, $ipAddress);
|
| 41 |
+
|
| 42 |
+
if($countryCode == '') {
|
| 43 |
+
return $result;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
// get currency code from country code
|
| 47 |
+
$currencyCode = geoip_currency_code_by_country_code($geoIp, $countryCode);
|
| 48 |
+
|
| 49 |
+
// close the geo database
|
| 50 |
+
geoip_close($geoIp);
|
| 51 |
+
|
| 52 |
+
return $currencyCode;
|
| 53 |
+
}
|
| 54 |
+
}
|
app/code/community/Chapagain/AutoCurrency/etc/config.xml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Chapagain_AutoCurrency>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Chapagain_AutoCurrency>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<core>
|
| 11 |
+
<rewrite>
|
| 12 |
+
<store>Chapagain_AutoCurrency_Model_Store</store>
|
| 13 |
+
</rewrite>
|
| 14 |
+
</core>
|
| 15 |
+
</models>
|
| 16 |
+
<helpers>
|
| 17 |
+
<autocurrency>
|
| 18 |
+
<class>Chapagain_AutoCurrency_Helper</class>
|
| 19 |
+
</autocurrency>
|
| 20 |
+
</helpers>
|
| 21 |
+
</global>
|
| 22 |
+
</config>
|
app/etc/modules/Chapagain_AutoCurrency.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Chapagain_AutoCurrency>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Chapagain_AutoCurrency>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>AutoCurrency</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Auto Currency is a currency switcher extension which automatically switches store currency based on visitor's IP address location.</summary>
|
| 10 |
+
<description>Auto Currency extension tracks visitor's IP address and automatically changes the store currency to the visitor's location currency. Visitor can switch to his/her desired currency at any time.
|
| 11 |
+

|
| 12 |
+
This extension uses MaxMind's GeoIP technology for IP address lookup.
|
| 13 |
+

|
| 14 |
+
No extra configuration settings to be made. Just install the module in your multi-currency Magento shop and the module will work on the fly.
|
| 15 |
+

|
| 16 |
+
Features
|
| 17 |
+

|
| 18 |
+
Easy to install and use
|
| 19 |
+
100% Free
|
| 20 |
+
100% Open Source</description>
|
| 21 |
+
<notes>Notes</notes>
|
| 22 |
+
<authors><author><name>Mukesh Chapagain</name><user>auto-converted</user><email>mukesh.chapagain@gmail.com</email></author></authors>
|
| 23 |
+
<date>2011-05-11</date>
|
| 24 |
+
<time>11:19:07</time>
|
| 25 |
+
<contents><target name="magecommunity"><dir name="Chapagain"><dir name="AutoCurrency"><dir name="Helper"><file name="Data.php" hash="657392d567588d02cff9a00e884e8b1e"/></dir><dir name="Model"><file name="Store.php" hash="8a048e19fb94355e0bfc52e8c09e77d0"/></dir><dir name="etc"><file name="config.xml" hash="df97d6b2762b87d3f7e66cbf64a61dc6"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Chapagain_AutoCurrency.xml" hash="dd65769f686b4c12011f5d09e18249ff"/></dir></target><target name="mage"><dir name="var"><dir name="geoip"><file name="GeoIP.dat" hash="4744053b2eb4264db3b345f40b0bfa9f"/><file name="geoip.inc" hash="e8a6c661ddcb38bf80471939391cab6d"/></dir></dir></target></contents>
|
| 26 |
+
<compatible/>
|
| 27 |
+
<dependencies/>
|
| 28 |
+
</package>
|
var/geoip/GeoIP.dat
ADDED
|
Binary file
|
var/geoip/geoip.inc
ADDED
|
@@ -0,0 +1,611 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
|
| 4 |
+
/* geoip.inc
|
| 5 |
+
*
|
| 6 |
+
* Copyright (C) 2007 MaxMind LLC
|
| 7 |
+
*
|
| 8 |
+
* This library is free software; you can redistribute it and/or
|
| 9 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 10 |
+
* License as published by the Free Software Foundation; either
|
| 11 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 12 |
+
*
|
| 13 |
+
* This library is distributed in the hope that it will be useful,
|
| 14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 16 |
+
* Lesser General Public License for more details.
|
| 17 |
+
*
|
| 18 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 19 |
+
* License along with this library; if not, write to the Free Software
|
| 20 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
define("GEOIP_COUNTRY_BEGIN", 16776960);
|
| 24 |
+
define("GEOIP_STATE_BEGIN_REV0", 16700000);
|
| 25 |
+
define("GEOIP_STATE_BEGIN_REV1", 16000000);
|
| 26 |
+
define("GEOIP_STANDARD", 0);
|
| 27 |
+
define("GEOIP_MEMORY_CACHE", 1);
|
| 28 |
+
define("GEOIP_SHARED_MEMORY", 2);
|
| 29 |
+
define("STRUCTURE_INFO_MAX_SIZE", 20);
|
| 30 |
+
define("DATABASE_INFO_MAX_SIZE", 100);
|
| 31 |
+
define("GEOIP_COUNTRY_EDITION", 106);
|
| 32 |
+
define("GEOIP_PROXY_EDITION", 8);
|
| 33 |
+
define("GEOIP_ASNUM_EDITION", 9);
|
| 34 |
+
define("GEOIP_NETSPEED_EDITION", 10);
|
| 35 |
+
define("GEOIP_REGION_EDITION_REV0", 112);
|
| 36 |
+
define("GEOIP_REGION_EDITION_REV1", 3);
|
| 37 |
+
define("GEOIP_CITY_EDITION_REV0", 111);
|
| 38 |
+
define("GEOIP_CITY_EDITION_REV1", 2);
|
| 39 |
+
define("GEOIP_ORG_EDITION", 110);
|
| 40 |
+
define("GEOIP_ISP_EDITION", 4);
|
| 41 |
+
define("SEGMENT_RECORD_LENGTH", 3);
|
| 42 |
+
define("STANDARD_RECORD_LENGTH", 3);
|
| 43 |
+
define("ORG_RECORD_LENGTH", 4);
|
| 44 |
+
define("MAX_RECORD_LENGTH", 4);
|
| 45 |
+
define("MAX_ORG_RECORD_LENGTH", 300);
|
| 46 |
+
define("GEOIP_SHM_KEY", 0x4f415401);
|
| 47 |
+
define("US_OFFSET", 1);
|
| 48 |
+
define("CANADA_OFFSET", 677);
|
| 49 |
+
define("WORLD_OFFSET", 1353);
|
| 50 |
+
define("FIPS_RANGE", 360);
|
| 51 |
+
define("GEOIP_UNKNOWN_SPEED", 0);
|
| 52 |
+
define("GEOIP_DIALUP_SPEED", 1);
|
| 53 |
+
define("GEOIP_CABLEDSL_SPEED", 2);
|
| 54 |
+
define("GEOIP_CORPORATE_SPEED", 3);
|
| 55 |
+
define("GEOIP_DOMAIN_EDITION", 11);
|
| 56 |
+
define("GEOIP_LOCATIONA_EDITION", 13);
|
| 57 |
+
define("GEOIP_ACCURACYRADIUS_EDITION", 14);
|
| 58 |
+
define("GEOIP_CITYCOMBINED_EDITION", 15);
|
| 59 |
+
define("CITYCOMBINED_FIXED_RECORD", 7 );
|
| 60 |
+
|
| 61 |
+
class GeoIP {
|
| 62 |
+
var $flags;
|
| 63 |
+
var $filehandle;
|
| 64 |
+
var $memory_buffer;
|
| 65 |
+
var $databaseType;
|
| 66 |
+
var $databaseSegments;
|
| 67 |
+
var $record_length;
|
| 68 |
+
var $shmid;
|
| 69 |
+
var $GEOIP_COUNTRY_CODE_TO_NUMBER = array(
|
| 70 |
+
"" => 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5,
|
| 71 |
+
"AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "AN" => 10, "AO" => 11,
|
| 72 |
+
"AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17,
|
| 73 |
+
"AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23,
|
| 74 |
+
"BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29,
|
| 75 |
+
"BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35,
|
| 76 |
+
"BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41,
|
| 77 |
+
"CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47,
|
| 78 |
+
"CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53,
|
| 79 |
+
"CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59,
|
| 80 |
+
"DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65,
|
| 81 |
+
"ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71,
|
| 82 |
+
"FM" => 72, "FO" => 73, "FR" => 74, "FX" => 75, "GA" => 76, "GB" => 77,
|
| 83 |
+
"GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83,
|
| 84 |
+
"GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89,
|
| 85 |
+
"GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95,
|
| 86 |
+
"HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101,
|
| 87 |
+
"IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107,
|
| 88 |
+
"IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113,
|
| 89 |
+
"KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119,
|
| 90 |
+
"KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125,
|
| 91 |
+
"LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131,
|
| 92 |
+
"LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137,
|
| 93 |
+
"MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143,
|
| 94 |
+
"MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149,
|
| 95 |
+
"MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155,
|
| 96 |
+
"NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161,
|
| 97 |
+
"NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167,
|
| 98 |
+
"PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173,
|
| 99 |
+
"PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179,
|
| 100 |
+
"PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185,
|
| 101 |
+
"RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191,
|
| 102 |
+
"SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197,
|
| 103 |
+
"SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203,
|
| 104 |
+
"SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209,
|
| 105 |
+
"TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215,
|
| 106 |
+
"TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221,
|
| 107 |
+
"UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227,
|
| 108 |
+
"VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
|
| 109 |
+
"VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
|
| 110 |
+
"ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
|
| 111 |
+
"O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
|
| 112 |
+
"MF" => 252
|
| 113 |
+
);
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Added for Chapagain_AutoCurrency Magento Module
|
| 117 |
+
*/
|
| 118 |
+
var $GEOIP_COUNTRY_CODE_TO_CURRENCY = array(
|
| 119 |
+
"EU" => "EUR", "AD" => "EUR", "AE" => "AED", "AF" => "AFN",
|
| 120 |
+
"AG" => "XCD", "AI" => "XCD", "AL" => "ALL", "AM" => "AMD", "AN" => "ANG", "AO" => "AOK",
|
| 121 |
+
"AR" => "ARP", "AS" => "EUR", "AT" => "EUR", "AU" => "AUD", "AW" => "ANG",
|
| 122 |
+
"AZ" => "AZM", "BA" => "BAK", "BB" => "BBD", "BD" => "BDT", "BE" => "EUR", "BF" => "XOF",
|
| 123 |
+
"BG" => "BGL", "BH" => "BHD", "BI" => "BIF", "BJ" => "XOF", "BM" => "BMD", "BN" => "BND",
|
| 124 |
+
"BO" => "BOB", "BR" => "BRR", "BS" => "BSD", "BT" => "INR", "BV" => "NOK", "BW" => "BWP",
|
| 125 |
+
"BY" => "BYR", "BZ" => "BZD", "CA" => "CAD", "CC" => "AUD", "CD" => "CDF", "CF" => "XAF",
|
| 126 |
+
"CG" => "XAF", "CH" => "CHF", "CI" => "XOF", "CK" => "NZD", "CL" => "CLP", "CM" => "XAF",
|
| 127 |
+
"CN" => "CNY", "CO" => "COP", "CR" => "CRC", "CU" => "CUP", "CV" => "CVE", "CX" => "AUD",
|
| 128 |
+
"CY" => "CYP", "CZ" => "CSK", "DE" => "EUR", "DJ" => "DJF", "DK" => "DKK", "DM" => "XCD",
|
| 129 |
+
"DO" => "DOP", "DZ" => "DZD", "EC" => "ECS", "EE" => "EEK", "EG" => "EGP", "EH" => "MAD",
|
| 130 |
+
"ER" => "ETB", "ES" => "EUR", "ET" => "ETB", "FI" => "EUR", "FJ" => "FJD", "FK" => "FKP",
|
| 131 |
+
"FM" => "USD", "FO" => "DKK", "FR" => "EUR", "GA" => "XAF", "GB" => "GBP",
|
| 132 |
+
"GD" => "XCD", "GE" => "GEL", "GF" => "EUR", "GH" => "GHC", "GI" => "GIP", "GL" => "DKK",
|
| 133 |
+
"GM" => "GMD", "GN" => "GNF", "GP" => "EUR", "GQ" => "XAF", "GR" => "EUR", "GS" => "GBP",
|
| 134 |
+
"GT" => "GTQ", "GU" => "USD", "GW" => "XOF", "GY" => "GYD", "HK" => "HKD", "HM" => "AUD",
|
| 135 |
+
"HN" => "HNL", "HR" => "HRK", "HT" => "HTG", "HU" => "HUF", "ID" => "IDR", "IE" => "EUR",
|
| 136 |
+
"IL" => "ILS", "IN" => "INR", "IO" => "USD", "IQ" => "IQD", "IR" => "IRR", "IS" => "ISK",
|
| 137 |
+
"IT" => "EUR", "JM" => "JMD", "JO" => "JOD", "JP" => "JPY", "KE" => "KES", "KG" => "KGS",
|
| 138 |
+
"KH" => "KHR", "KI" => "AUD", "KM" => "KMF", "KN" => "XCD", "KP" => "KPW", "KR" => "KRW",
|
| 139 |
+
"KW" => "KWD", "KY" => "KYD", "KZ" => "KZT", "LA" => "LAK", "LB" => "LBP", "LC" => "XCD",
|
| 140 |
+
"LI" => "CHF", "LK" => "LKR", "LR" => "LRD", "LS" => "LSL", "LT" => "LTL", "LU" => "EUR",
|
| 141 |
+
"LV" => "LVL", "LY" => "LYD", "MA" => "MAD", "MC" => "EUR", "MD" => "MDL", "MG" => "MGF",
|
| 142 |
+
"MH" => "USD", "MK" => "MKD", "ML" => "XOF", "MM" => "MMK", "MN" => "MNT", "MO" => "MOP",
|
| 143 |
+
"MP" => "USD", "MQ" => "EUR", "MR" => "MRO", "MS" => "XCD", "MT" => "MTL", "MU" => "MUR",
|
| 144 |
+
"MV" => "MVR", "MW" => "MWK", "MX" => "MXP", "MY" => "MYR", "MZ" => "MZM", "NA" => "NAD",
|
| 145 |
+
"NC" => "XPF", "NE" => "XOF", "NF" => "AUD", "NG" => "NGN", "NI" => "NIO", "NL" => "EUR",
|
| 146 |
+
"NO" => "NOK", "NP" => "NPR", "NR" => "AUD", "NU" => "NZD", "NZ" => "NZD", "OM" => "OMR",
|
| 147 |
+
"PA" => "PAB", "PE" => "PEN", "PF" => "XPF", "PG" => "PGK", "PH" => "PHP", "PK" => "PKR",
|
| 148 |
+
"PL" => "PLZ", "PN" => "NZD", "PR" => "USD", "PT" => "EUR",
|
| 149 |
+
"PW" => "USD", "PY" => "PYG", "QA" => "QAR", "RE" => "EUR", "RO" => "ROL", "RU" => "RUR",
|
| 150 |
+
"RW" => "RWF", "SA" => "SAR", "SB" => "SBD", "SC" => "SCR", "SD" => "SDD", "SE" => "SEK",
|
| 151 |
+
"SG" => "SGD", "SH" => "SHP", "SI" => "EUR", "SJ" => "NOK", "SK" => "SKK", "SL" => "SLL",
|
| 152 |
+
"SM" => "EUR", "SN" => "XOF", "SO" => "SOS", "SR" => "SRG", "ST" => "STD", "SV" => "SVC",
|
| 153 |
+
"SY" => "SYP", "SZ" => "SZL", "TC" => "USD", "TD" => "XAF", "TF" => "EUR", "TG" => "XOF",
|
| 154 |
+
"TH" => "THB", "TJ" => "TJR", "TK" => "NZD", "TM" => "TMM", "TN" => "TND", "TO" => "TOP",
|
| 155 |
+
"TR" => "TRL", "TT" => "TTD", "TV" => "AUD", "TW" => "TWD", "TZ" => "TZS",
|
| 156 |
+
"UA" => "UAH", "UG" => "UGX", "UM" => "USD", "US" => "USD", "UY" => "UYU", "UZ" => "UZS",
|
| 157 |
+
"VA" => "EUR", "VC" => "XCD", "VE" => "VEB", "VG" => "USD", "VI" => "USD", "VN" => "VND",
|
| 158 |
+
"VU" => "VUV", "WF" => "XPF", "WS" => "EUR", "YE" => "YER", "YT" => "EUR",
|
| 159 |
+
"ZA" => "ZAR", "ZM" => "ZMK", "ZW" => "ZWD"
|
| 160 |
+
);
|
| 161 |
+
|
| 162 |
+
var $GEOIP_COUNTRY_CODES = array(
|
| 163 |
+
"", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ",
|
| 164 |
+
"AR", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH",
|
| 165 |
+
"BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA",
|
| 166 |
+
"CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU",
|
| 167 |
+
"CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG",
|
| 168 |
+
"EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "FX", "GA", "GB",
|
| 169 |
+
"GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT",
|
| 170 |
+
"GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN",
|
| 171 |
+
"IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM",
|
| 172 |
+
"KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS",
|
| 173 |
+
"LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN",
|
| 174 |
+
"MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
|
| 175 |
+
"NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA",
|
| 176 |
+
"PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY",
|
| 177 |
+
"QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI",
|
| 178 |
+
"SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC", "TD",
|
| 179 |
+
"TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TL", "TR", "TT", "TV", "TW",
|
| 180 |
+
"TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN",
|
| 181 |
+
"VU", "WF", "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1",
|
| 182 |
+
"AX", "GG", "IM", "JE", "BL", "MF"
|
| 183 |
+
);
|
| 184 |
+
var $GEOIP_COUNTRY_CODES3 = array(
|
| 185 |
+
"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","ATA","ARG",
|
| 186 |
+
"ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI",
|
| 187 |
+
"BEN","BMU","BRN","BOL","BRA","BHS","BTN","BVT","BWA","BLR","BLZ","CAN","CCK",
|
| 188 |
+
"COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV",
|
| 189 |
+
"CXR","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH",
|
| 190 |
+
"ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD",
|
| 191 |
+
"GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","SGS","GTM","GUM",
|
| 192 |
+
"GNB","GUY","HKG","HMD","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IOT",
|
| 193 |
+
"IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA",
|
| 194 |
+
"PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
|
| 195 |
+
"LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC",
|
| 196 |
+
"MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL",
|
| 197 |
+
"NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER",
|
| 198 |
+
"PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT",
|
| 199 |
+
"REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM",
|
| 200 |
+
"SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","ATF",
|
| 201 |
+
"TGO","THA","TJK","TKL","TKM","TUN","TON","TLS","TUR","TTO","TUV","TWN","TZA",
|
| 202 |
+
"UKR","UGA","UMI","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT",
|
| 203 |
+
"WLF","WSM","YEM","MYT","SRB","ZAF","ZMB","MNE","ZWE","A1","A2","O1",
|
| 204 |
+
"ALA","GGY","IMN","JEY","BLM","MAF"
|
| 205 |
+
);
|
| 206 |
+
var $GEOIP_COUNTRY_NAMES = array(
|
| 207 |
+
"", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
|
| 208 |
+
"Afghanistan", "Antigua and Barbuda", "Anguilla", "Albania", "Armenia",
|
| 209 |
+
"Netherlands Antilles", "Angola", "Antarctica", "Argentina", "American Samoa",
|
| 210 |
+
"Austria", "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina",
|
| 211 |
+
"Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain",
|
| 212 |
+
"Burundi", "Benin", "Bermuda", "Brunei Darussalam", "Bolivia", "Brazil",
|
| 213 |
+
"Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize",
|
| 214 |
+
"Canada", "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the",
|
| 215 |
+
"Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook Islands",
|
| 216 |
+
"Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape Verde",
|
| 217 |
+
"Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti",
|
| 218 |
+
"Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia",
|
| 219 |
+
"Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", "Finland", "Fiji",
|
| 220 |
+
"Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe Islands",
|
| 221 |
+
"France", "France, Metropolitan", "Gabon", "United Kingdom",
|
| 222 |
+
"Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland",
|
| 223 |
+
"Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia and the South Sandwich Islands",
|
| 224 |
+
"Guatemala", "Guam", "Guinea-Bissau",
|
| 225 |
+
"Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras",
|
| 226 |
+
"Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India",
|
| 227 |
+
"British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of",
|
| 228 |
+
"Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya", "Kyrgyzstan",
|
| 229 |
+
"Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic People's Republic of",
|
| 230 |
+
"Korea, Republic of", "Kuwait", "Cayman Islands",
|
| 231 |
+
"Kazakhstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia",
|
| 232 |
+
"Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg",
|
| 233 |
+
"Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic of",
|
| 234 |
+
"Madagascar", "Marshall Islands", "Macedonia",
|
| 235 |
+
"Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands",
|
| 236 |
+
"Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives",
|
| 237 |
+
"Malawi", "Mexico", "Malaysia", "Mozambique", "Namibia", "New Caledonia",
|
| 238 |
+
"Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway",
|
| 239 |
+
"Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French Polynesia",
|
| 240 |
+
"Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint Pierre and Miquelon",
|
| 241 |
+
"Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
|
| 242 |
+
"Portugal", "Palau", "Paraguay", "Qatar", "Reunion", "Romania",
|
| 243 |
+
"Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands",
|
| 244 |
+
"Seychelles", "Sudan", "Sweden", "Singapore", "Saint Helena", "Slovenia",
|
| 245 |
+
"Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal",
|
| 246 |
+
"Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab Republic",
|
| 247 |
+
"Swaziland", "Turks and Caicos Islands", "Chad", "French Southern Territories",
|
| 248 |
+
"Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan",
|
| 249 |
+
"Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", "Tuvalu",
|
| 250 |
+
"Taiwan", "Tanzania, United Republic of", "Ukraine",
|
| 251 |
+
"Uganda", "United States Minor Outlying Islands", "United States", "Uruguay",
|
| 252 |
+
"Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the Grenadines",
|
| 253 |
+
"Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
|
| 254 |
+
"Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
|
| 255 |
+
"Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe",
|
| 256 |
+
"Anonymous Proxy","Satellite Provider","Other",
|
| 257 |
+
"Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin"
|
| 258 |
+
);
|
| 259 |
+
|
| 260 |
+
var $GEOIP_CONTINENT_CODES = array(
|
| 261 |
+
"--", "AS", "EU", "EU", "AS", "AS", "NA", "NA", "EU", "AS",
|
| 262 |
+
"NA", "AF", "AN", "SA", "OC", "EU", "OC", "NA", "AS", "EU",
|
| 263 |
+
"NA", "AS", "EU", "AF", "EU", "AS", "AF", "AF", "NA", "AS",
|
| 264 |
+
"SA", "SA", "NA", "AS", "AN", "AF", "EU", "NA", "NA", "AS",
|
| 265 |
+
"AF", "AF", "AF", "EU", "AF", "OC", "SA", "AF", "AS", "SA",
|
| 266 |
+
"NA", "NA", "AF", "AS", "AS", "EU", "EU", "AF", "EU", "NA",
|
| 267 |
+
"NA", "AF", "SA", "EU", "AF", "AF", "AF", "EU", "AF", "EU",
|
| 268 |
+
"OC", "SA", "OC", "EU", "EU", "EU", "AF", "EU", "NA", "AS",
|
| 269 |
+
"SA", "AF", "EU", "NA", "AF", "AF", "NA", "AF", "EU", "AN",
|
| 270 |
+
"NA", "OC", "AF", "SA", "AS", "AN", "NA", "EU", "NA", "EU",
|
| 271 |
+
"AS", "EU", "AS", "AS", "AS", "AS", "AS", "EU", "EU", "NA",
|
| 272 |
+
"AS", "AS", "AF", "AS", "AS", "OC", "AF", "NA", "AS", "AS",
|
| 273 |
+
"AS", "NA", "AS", "AS", "AS", "NA", "EU", "AS", "AF", "AF",
|
| 274 |
+
"EU", "EU", "EU", "AF", "AF", "EU", "EU", "AF", "OC", "EU",
|
| 275 |
+
"AF", "AS", "AS", "AS", "OC", "NA", "AF", "NA", "EU", "AF",
|
| 276 |
+
"AS", "AF", "NA", "AS", "AF", "AF", "OC", "AF", "OC", "AF",
|
| 277 |
+
"NA", "EU", "EU", "AS", "OC", "OC", "OC", "AS", "NA", "SA",
|
| 278 |
+
"OC", "OC", "AS", "AS", "EU", "NA", "OC", "NA", "AS", "EU",
|
| 279 |
+
"OC", "SA", "AS", "AF", "EU", "EU", "AF", "AS", "OC", "AF",
|
| 280 |
+
"AF", "EU", "AS", "AF", "EU", "EU", "EU", "AF", "EU", "AF",
|
| 281 |
+
"AF", "SA", "AF", "NA", "AS", "AF", "NA", "AF", "AN", "AF",
|
| 282 |
+
"AS", "AS", "OC", "AS", "AF", "OC", "AS", "EU", "NA", "OC",
|
| 283 |
+
"AS", "AF", "EU", "AF", "OC", "NA", "SA", "AS", "EU", "NA",
|
| 284 |
+
"SA", "NA", "NA", "AS", "OC", "OC", "OC", "AS", "AF", "EU",
|
| 285 |
+
"AF", "AF", "EU", "AF", "--", "--", "--", "EU", "EU", "EU",
|
| 286 |
+
"EU", "NA", "NA"
|
| 287 |
+
);
|
| 288 |
+
|
| 289 |
+
}
|
| 290 |
+
function geoip_load_shared_mem ($file) {
|
| 291 |
+
|
| 292 |
+
$fp = fopen($file, "rb");
|
| 293 |
+
if (!$fp) {
|
| 294 |
+
print "error opening $file: $php_errormsg\n";
|
| 295 |
+
exit;
|
| 296 |
+
}
|
| 297 |
+
$s_array = fstat($fp);
|
| 298 |
+
$size = $s_array['size'];
|
| 299 |
+
if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
|
| 300 |
+
shmop_delete ($shmid);
|
| 301 |
+
shmop_close ($shmid);
|
| 302 |
+
}
|
| 303 |
+
$shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
|
| 304 |
+
shmop_write ($shmid, fread($fp, $size), 0);
|
| 305 |
+
shmop_close ($shmid);
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
function _setup_segments($gi){
|
| 309 |
+
$gi->databaseType = GEOIP_COUNTRY_EDITION;
|
| 310 |
+
$gi->record_length = STANDARD_RECORD_LENGTH;
|
| 311 |
+
if ($gi->flags & GEOIP_SHARED_MEMORY) {
|
| 312 |
+
$offset = @shmop_size ($gi->shmid) - 3;
|
| 313 |
+
for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
|
| 314 |
+
$delim = @shmop_read ($gi->shmid, $offset, 3);
|
| 315 |
+
$offset += 3;
|
| 316 |
+
if ($delim == (chr(255).chr(255).chr(255))) {
|
| 317 |
+
$gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
|
| 318 |
+
$offset++;
|
| 319 |
+
|
| 320 |
+
if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
|
| 321 |
+
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
|
| 322 |
+
} else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
|
| 323 |
+
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
|
| 324 |
+
} else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
|
| 325 |
+
($gi->databaseType == GEOIP_CITY_EDITION_REV1)
|
| 326 |
+
|| ($gi->databaseType == GEOIP_ORG_EDITION)
|
| 327 |
+
|| ($gi->databaseType == GEOIP_DOMAIN_EDITION)
|
| 328 |
+
|| ($gi->databaseType == GEOIP_ISP_EDITION)
|
| 329 |
+
|| ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
|
| 330 |
+
|| ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
|
| 331 |
+
|| ($gi->databaseType == GEOIP_ASNUM_EDITION)){
|
| 332 |
+
$gi->databaseSegments = 0;
|
| 333 |
+
$buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
|
| 334 |
+
for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
|
| 335 |
+
$gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
|
| 336 |
+
}
|
| 337 |
+
if (($gi->databaseType == GEOIP_ORG_EDITION)
|
| 338 |
+
|| ($gi->databaseType == GEOIP_DOMAIN_EDITION)
|
| 339 |
+
|| ($gi->databaseType == GEOIP_ISP_EDITION)) {
|
| 340 |
+
$gi->record_length = ORG_RECORD_LENGTH;
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
break;
|
| 344 |
+
} else {
|
| 345 |
+
$offset -= 4;
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
|
| 349 |
+
($gi->databaseType == GEOIP_PROXY_EDITION)||
|
| 350 |
+
($gi->databaseType == GEOIP_NETSPEED_EDITION)){
|
| 351 |
+
$gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
|
| 352 |
+
}
|
| 353 |
+
} else {
|
| 354 |
+
$filepos = ftell($gi->filehandle);
|
| 355 |
+
fseek($gi->filehandle, -3, SEEK_END);
|
| 356 |
+
for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
|
| 357 |
+
$delim = fread($gi->filehandle,3);
|
| 358 |
+
if ($delim == (chr(255).chr(255).chr(255))){
|
| 359 |
+
$gi->databaseType = ord(fread($gi->filehandle,1));
|
| 360 |
+
if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
|
| 361 |
+
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
|
| 362 |
+
}
|
| 363 |
+
else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
|
| 364 |
+
$gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
|
| 365 |
+
} else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)
|
| 366 |
+
|| ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
|
| 367 |
+
|| ($gi->databaseType == GEOIP_ORG_EDITION)
|
| 368 |
+
|| ($gi->databaseType == GEOIP_DOMAIN_EDITION)
|
| 369 |
+
|| ($gi->databaseType == GEOIP_ISP_EDITION)
|
| 370 |
+
|| ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
|
| 371 |
+
|| ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
|
| 372 |
+
|| ($gi->databaseType == GEOIP_ASNUM_EDITION)){
|
| 373 |
+
$gi->databaseSegments = 0;
|
| 374 |
+
$buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
|
| 375 |
+
for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
|
| 376 |
+
$gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
|
| 377 |
+
}
|
| 378 |
+
if ( ( $gi->databaseType == GEOIP_ORG_EDITION )
|
| 379 |
+
|| ( $gi->databaseType == GEOIP_DOMAIN_EDITION )
|
| 380 |
+
|| ( $gi->databaseType == GEOIP_ISP_EDITION ) ) {
|
| 381 |
+
$gi->record_length = ORG_RECORD_LENGTH;
|
| 382 |
+
}
|
| 383 |
+
}
|
| 384 |
+
break;
|
| 385 |
+
} else {
|
| 386 |
+
fseek($gi->filehandle, -4, SEEK_CUR);
|
| 387 |
+
}
|
| 388 |
+
}
|
| 389 |
+
if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
|
| 390 |
+
($gi->databaseType == GEOIP_PROXY_EDITION)||
|
| 391 |
+
($gi->databaseType == GEOIP_NETSPEED_EDITION)){
|
| 392 |
+
$gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
|
| 393 |
+
}
|
| 394 |
+
fseek($gi->filehandle,$filepos,SEEK_SET);
|
| 395 |
+
}
|
| 396 |
+
return $gi;
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
function geoip_open($filename, $flags) {
|
| 400 |
+
$gi = new GeoIP;
|
| 401 |
+
$gi->flags = $flags;
|
| 402 |
+
if ($gi->flags & GEOIP_SHARED_MEMORY) {
|
| 403 |
+
$gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
|
| 404 |
+
} else {
|
| 405 |
+
$gi->filehandle = fopen($filename,"rb") or die( "Can not open $filename\n" );
|
| 406 |
+
if ($gi->flags & GEOIP_MEMORY_CACHE) {
|
| 407 |
+
$s_array = fstat($gi->filehandle);
|
| 408 |
+
$gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
|
| 409 |
+
}
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
$gi = _setup_segments($gi);
|
| 413 |
+
return $gi;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
function geoip_close($gi) {
|
| 417 |
+
if ($gi->flags & GEOIP_SHARED_MEMORY) {
|
| 418 |
+
return true;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
return fclose($gi->filehandle);
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
function geoip_country_id_by_name($gi, $name) {
|
| 425 |
+
$addr = gethostbyname($name);
|
| 426 |
+
if (!$addr || $addr == $name) {
|
| 427 |
+
return false;
|
| 428 |
+
}
|
| 429 |
+
return geoip_country_id_by_addr($gi, $addr);
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
function geoip_country_code_by_name($gi, $name) {
|
| 433 |
+
$country_id = geoip_country_id_by_name($gi,$name);
|
| 434 |
+
if ($country_id !== false) {
|
| 435 |
+
return $gi->GEOIP_COUNTRY_CODES[$country_id];
|
| 436 |
+
}
|
| 437 |
+
return false;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
function geoip_country_name_by_name($gi, $name) {
|
| 441 |
+
$country_id = geoip_country_id_by_name($gi,$name);
|
| 442 |
+
if ($country_id !== false) {
|
| 443 |
+
return $gi->GEOIP_COUNTRY_NAMES[$country_id];
|
| 444 |
+
}
|
| 445 |
+
return false;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
function geoip_country_id_by_addr($gi, $addr) {
|
| 449 |
+
$ipnum = ip2long($addr);
|
| 450 |
+
return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
function geoip_country_code_by_addr($gi, $addr) {
|
| 454 |
+
if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
|
| 455 |
+
$record = geoip_record_by_addr($gi,$addr);
|
| 456 |
+
if ( $record !== false ) {
|
| 457 |
+
return $record->country_code;
|
| 458 |
+
}
|
| 459 |
+
} else {
|
| 460 |
+
$country_id = geoip_country_id_by_addr($gi,$addr);
|
| 461 |
+
if ($country_id !== false) {
|
| 462 |
+
return $gi->GEOIP_COUNTRY_CODES[$country_id];
|
| 463 |
+
}
|
| 464 |
+
}
|
| 465 |
+
return false;
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
/**
|
| 469 |
+
* Added for Chapagain_AutoCurrency Magento Module
|
| 470 |
+
*/
|
| 471 |
+
function geoip_currency_code_by_country_code($gi, $code) {
|
| 472 |
+
return $gi->GEOIP_COUNTRY_CODE_TO_CURRENCY[$code];
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
function geoip_country_name_by_addr($gi, $addr) {
|
| 476 |
+
if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
|
| 477 |
+
$record = geoip_record_by_addr($gi,$addr);
|
| 478 |
+
return $record->country_name;
|
| 479 |
+
} else {
|
| 480 |
+
$country_id = geoip_country_id_by_addr($gi,$addr);
|
| 481 |
+
if ($country_id !== false) {
|
| 482 |
+
return $gi->GEOIP_COUNTRY_NAMES[$country_id];
|
| 483 |
+
}
|
| 484 |
+
}
|
| 485 |
+
return false;
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
function _geoip_seek_country($gi, $ipnum) {
|
| 489 |
+
$offset = 0;
|
| 490 |
+
for ($depth = 31; $depth >= 0; --$depth) {
|
| 491 |
+
if ($gi->flags & GEOIP_MEMORY_CACHE) {
|
| 492 |
+
// workaround php's broken substr, strpos, etc handling with
|
| 493 |
+
// mbstring.func_overload and mbstring.internal_encoding
|
| 494 |
+
$enc = mb_internal_encoding();
|
| 495 |
+
mb_internal_encoding('ISO-8859-1');
|
| 496 |
+
|
| 497 |
+
$buf = substr($gi->memory_buffer,
|
| 498 |
+
2 * $gi->record_length * $offset,
|
| 499 |
+
2 * $gi->record_length);
|
| 500 |
+
|
| 501 |
+
mb_internal_encoding($enc);
|
| 502 |
+
} elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
|
| 503 |
+
$buf = @shmop_read ($gi->shmid,
|
| 504 |
+
2 * $gi->record_length * $offset,
|
| 505 |
+
2 * $gi->record_length );
|
| 506 |
+
} else {
|
| 507 |
+
fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
|
| 508 |
+
or die("fseek failed");
|
| 509 |
+
$buf = fread($gi->filehandle, 2 * $gi->record_length);
|
| 510 |
+
}
|
| 511 |
+
$x = array(0,0);
|
| 512 |
+
for ($i = 0; $i < 2; ++$i) {
|
| 513 |
+
for ($j = 0; $j < $gi->record_length; ++$j) {
|
| 514 |
+
$x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
|
| 515 |
+
}
|
| 516 |
+
}
|
| 517 |
+
if ($ipnum & (1 << $depth)) {
|
| 518 |
+
if ($x[1] >= $gi->databaseSegments) {
|
| 519 |
+
return $x[1];
|
| 520 |
+
}
|
| 521 |
+
$offset = $x[1];
|
| 522 |
+
} else {
|
| 523 |
+
if ($x[0] >= $gi->databaseSegments) {
|
| 524 |
+
return $x[0];
|
| 525 |
+
}
|
| 526 |
+
$offset = $x[0];
|
| 527 |
+
}
|
| 528 |
+
}
|
| 529 |
+
trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
|
| 530 |
+
return false;
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
function _get_org($gi,$ipnum){
|
| 534 |
+
$seek_org = _geoip_seek_country($gi,$ipnum);
|
| 535 |
+
if ($seek_org == $gi->databaseSegments) {
|
| 536 |
+
return NULL;
|
| 537 |
+
}
|
| 538 |
+
$record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
|
| 539 |
+
if ($gi->flags & GEOIP_SHARED_MEMORY) {
|
| 540 |
+
$org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
|
| 541 |
+
} else {
|
| 542 |
+
fseek($gi->filehandle, $record_pointer, SEEK_SET);
|
| 543 |
+
$org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
|
| 544 |
+
}
|
| 545 |
+
// workaround php's broken substr, strpos, etc handling with
|
| 546 |
+
// mbstring.func_overload and mbstring.internal_encoding
|
| 547 |
+
$enc = mb_internal_encoding();
|
| 548 |
+
mb_internal_encoding('ISO-8859-1');
|
| 549 |
+
$org_buf = substr($org_buf, 0, strpos($org_buf, "\0"));
|
| 550 |
+
mb_internal_encoding($enc);
|
| 551 |
+
return $org_buf;
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
function geoip_org_by_addr ($gi,$addr) {
|
| 555 |
+
if ($addr == NULL) {
|
| 556 |
+
return 0;
|
| 557 |
+
}
|
| 558 |
+
$ipnum = ip2long($addr);
|
| 559 |
+
return _get_org($gi, $ipnum);
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
function _get_region($gi,$ipnum){
|
| 563 |
+
if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
|
| 564 |
+
$seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
|
| 565 |
+
if ($seek_region >= 1000){
|
| 566 |
+
$country_code = "US";
|
| 567 |
+
$region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
|
| 568 |
+
} else {
|
| 569 |
+
$country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
|
| 570 |
+
$region = "";
|
| 571 |
+
}
|
| 572 |
+
return array ($country_code,$region);
|
| 573 |
+
} else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
|
| 574 |
+
$seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
|
| 575 |
+
//print $seek_region;
|
| 576 |
+
if ($seek_region < US_OFFSET){
|
| 577 |
+
$country_code = "";
|
| 578 |
+
$region = "";
|
| 579 |
+
} else if ($seek_region < CANADA_OFFSET) {
|
| 580 |
+
$country_code = "US";
|
| 581 |
+
$region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
|
| 582 |
+
} else if ($seek_region < WORLD_OFFSET) {
|
| 583 |
+
$country_code = "CA";
|
| 584 |
+
$region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
|
| 585 |
+
} else {
|
| 586 |
+
$country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
|
| 587 |
+
$region = "";
|
| 588 |
+
}
|
| 589 |
+
return array ($country_code,$region);
|
| 590 |
+
}
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
function geoip_region_by_addr ($gi,$addr) {
|
| 594 |
+
if ($addr == NULL) {
|
| 595 |
+
return 0;
|
| 596 |
+
}
|
| 597 |
+
$ipnum = ip2long($addr);
|
| 598 |
+
return _get_region($gi, $ipnum);
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
function getdnsattributes ($l,$ip){
|
| 602 |
+
$r = new Net_DNS_Resolver();
|
| 603 |
+
$r->nameservers = array("ws1.maxmind.com");
|
| 604 |
+
$p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
|
| 605 |
+
$str = is_object($p->answer[0])?$p->answer[0]->string():'';
|
| 606 |
+
ereg("\"(.*)\"",$str,$regs);
|
| 607 |
+
$str = $regs[1];
|
| 608 |
+
return $str;
|
| 609 |
+
}
|
| 610 |
+
|
| 611 |
+
?>
|
