[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/ip/providers/ -> quova.php (source)

   1  <?php
   2  if ( defined('MP_Ip_quova_ApiKey') && defined('MP_Ip_quova_Secret') )
   3  {
   4  class MP_Ip_quova extends MP_ip_provider_
   5  {
   6      var $id     = 'quova';
   7      var $url    = 'http://api.quova.com/v1/ipinfo/%1$s?apikey=%2$s&sig=%3$s&format=xml';
   8      var $credit= 'http://www.quova.com/';
   9      var $type     = 'xml';
  10  
  11  	function content($valid, $content)
  12      {
  13          if (strpos($content, '<gds_error>')) return false;
  14          return $valid;
  15      }
  16  
  17  	function url($arg)
  18      {
  19          $arg[] = MP_Ip_quova_ApiKey;
  20          $arg[] = md5(MP_Ip_quova_ApiKey . MP_Ip_quova_Secret . gmdate('U'));
  21          return $arg;
  22      }
  23  
  24  	function data($content, $ip)
  25      {
  26          $html = '';
  27  
  28          $xml = $this->xml2array( $content );
  29          if (!isset($xml['Location'])) return false;
  30          $xml = $xml['Location'];
  31  
  32  
  33          $latitude         = $xml['latitude'];
  34          $html .= "<p style='margin:3px;'><b>latitude</b> : $latitude</p>";
  35  
  36          $longitude     = $xml['longitude'];
  37          $html .= "<p style='margin:3px;'><b>longitude</b> : $longitude</p>";
  38  
  39          $country         = ucwords($xml['CountryData']['country']);
  40          $html .= "<p style='margin:3px;'><b>country</b> : $country</p>";
  41  
  42          $country_code     = strtoupper($xml['CountryData']['country_code']);
  43          if ('US' == $country_code) 
  44          {
  45              $state_code     = (!empty($xml['StateData']['state_code'])) ? strtoupper($xml['StateData']['state_code']) : '';
  46              $html .= "<p style='margin:3px;'><b>state_code</b> : $state_code</p>";
  47          }
  48  
  49          $city         = ucwords($xml['CityData']['city']);
  50          $html .= "<p style='margin:3px;'><b>city</b> : $city</p>";
  51  
  52          $postal_code     = $xml['CityData']['postal_code'];
  53          $html .= "<p style='margin:3px;'><b>postal_code</b> : $postal_code</p>";
  54  
  55          $geo = (isset($latitude) && isset($longitude)) ? array('lat' => $latitude, 'lng' => $longitude) : array();
  56          return $this->cache_custom($ip, $geo, substr($country_code, 0, 2), $state_code, $html);
  57      }
  58  }
  59  new MP_Ip_quova();
  60  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1