/** * Get country name from client IP. * * @static * * @param null $ip Associated IP or leave null for current user's IP. * * @return bool|mixed */ public static function getCountryName($ip = null) { $registry_key = 'Client_CountryName_' . $ip; if (Registry::KeyExists($registry_key)) { $country_name = Registry::get($registry_key); } else { if (null == $ip) { $ip = self::getIP(); } require_once ROOT_PATH . '/libs/GeoIP-Lite/geoip.php'; $gi = geoip_open(ROOT_PATH . '/libs/GeoIP-Lite/GeoIP.dat', GEOIP_MEMORY_CACHE); $country_name = geoip_country_name_by_addr($gi, $ip); geoip_close($gi); Registry::set($registry_key, $country_name); } return $country_name; }