DotLibrary
[ class tree: DotLibrary ] [ index: DotLibrary ] [ all elements ]

Source for file Geoip.php

Documentation is available at Geoip.php

  1. <?php
  2. /**
  3. * DotBoost Technologies Inc.
  4. * DotKernel Application Framework
  5. *
  6. @category   DotKernel
  7. @package    DotLibrary
  8. @copyright  Copyright (c) 2009 DotBoost  Technologies (http://www.dotboost.com)
  9. @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  10. @version    $Id: Geoip.php 153 2010-06-23 10:06:25Z teo $
  11. */
  12.  
  13. /**
  14. * Geo IP related stuff
  15. @category   DotKernel
  16. @package    DotLibrary
  17. @subpackage DotGeoip
  18. @author     DotKernel Team <team@dotkernel.com>
  19. */
  20.  
  21. class Dot_Geoip 
  22. {
  23.     /**
  24.      * Constructor
  25.      * Return an array with : short name, like 'us' and long name, like 'United States'
  26.      * @access public
  27.      * @return dot_Geoip 
  28.      */
  29.     public function __construct()
  30.     {        
  31.         $this->config Zend_Registry::get('configuration');
  32.     }    
  33.     /**
  34.      * Get the country by IP
  35.      * Return an array with : short name, like 'us' and long name, like 'United States'
  36.      * @access public
  37.      * @param string $ip 
  38.      * @return array 
  39.      */
  40.     public function getCountryByIp($ip)
  41.     {
  42.         if(extension_loaded('geoip'== FALSE)
  43.         {
  44.             // GeoIp extension is not active
  45.             $api new Dot_Geoip_Api();
  46.             $geoipPath 'externals/geoip/';
  47.             $country $api->getCountryByAddr($geoipPath$ip);
  48.         }
  49.         else
  50.         {
  51.             $country[0geoip_country_code_by_name ($ip);
  52.             $country[1geoip_country_name_by_name($ip);
  53.         }        
  54.         return $country;
  55.     }    
  56. }

Documentation generated on Wed, 21 Jul 2010 07:34:40 +0000 by phpDocumentor 1.4.3