[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  if ( defined('MP_Ip_ipstack_access_key') )
   3  {
   4  class MP_Ip_ipstack extends MP_ip_provider_
   5  {
   6      var $id     = 'ipstack';
   7      var $url    = 'http://api.ipstack.com/%1$s?access_key=%2$s';
   8      var $credit= 'https://ipstack.com/';
   9      var $type     = 'json';
  10  
  11  	function content( $valid, $content )
  12      {
  13          if ( strpos( $content, '"latitude":null' ) ) return false;
  14          return $valid;
  15      }
  16  
  17  	function url($arg)
  18      {
  19          $arg[] = MP_Ip_ipstack_access_key;
  20          return $arg;
  21      }
  22  
  23  	function data( $content, $ip )
  24      {
  25          $keep = array( 'country_code', 'region_code', 'region_name', 'city', 'zip', 'latitude', 'longitude', 'connection' );
  26          $html = '';
  27  
  28          $json =  json_decode( $content, true );
  29          foreach ( $json as $k => $v )
  30          {
  31              if ( $v == 'NA' ) continue;
  32              if ( empty( $v ) )   continue;
  33  
  34              if ( ( $k == 'connection' ) && ( isset( $k['connection']['isp'] ) ) ) $k['connection'] = $k['connection']['isp'];
  35  
  36              if ( !in_array( $k, $keep ) ) continue;
  37  
  38              if ( in_array( $k, array( 'country_code', 'region_code', 'latitude', 'longitude' ) ) ) {$$k = $v; continue;}
  39  
  40              $html .= '<p style="margin:3px;"><b>' . $k . '</b> : ' . $v . '</p>';
  41          }
  42  
  43           $geo = array( 'lat' => $latitude, 'lng' => $longitude );
  44  
  45          $subcountry = ( 'US' == strtoupper( $country_code ) ) ? $region_code : MP_Ip::no_state;
  46          return $this->cache_custom( $ip, $geo, strtoupper( $country_code ), strtoupper( $subcountry ), $html );
  47      }
  48  }
  49  new MP_Ip_ipstack();
  50  }


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1