[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_Ip_ipinfoio extends MP_ip_provider_
   3  {
   4      var $id     = 'ipinfoio';
   5      var $url    = 'http://ipinfo.io/%1$s/geo';
   6      var $credit    = 'http://ipinfo.io/';
   7      var $type     = 'json';
   8  
   9  	function content( $valid, $content )
  10      {
  11          if ( !strpos( $content, '"loc":' ) ) return false;
  12          return $valid;
  13      }
  14  
  15  	function data( $content, $ip )
  16      {
  17          $skip = array( 'ip', 'hostname', 'org', 'postal' );
  18          $html = '';
  19  
  20          $json =  json_decode( $content, true );
  21          foreach ( $json as $k => $v )
  22          {
  23              if ( $v == 'n/a' ) continue;
  24              if ( empty( $v ) )   continue;
  25  
  26              if ( in_array( $k, $skip ) ) continue;
  27  
  28              if ( in_array( $k, array( 'country', 'loc' ) ) ) {$$k = $v; continue;}
  29  
  30              $html .= '<p style="margin:3px;"><b>' . $k ; '</b> : ' . $v . '</p>';
  31          }
  32  
  33          $geo = array();
  34          if ( isset( $loc ) ) $ll = explode( ',',$loc );
  35          if ( count( $ll ) == 2 ) $geo = array( 'lat' => $ll[0], 'lng' => $ll[1] );
  36  
  37          $subcountry = ( 'US' == strtoupper( $country ) ) ? MP_Ip::get_USstate( $ip ) : MP_Ip::no_state;
  38          return $this->cache_custom( $ip, $geo, strtoupper( substr( $country, 0, 2 ) ), strtoupper( $subcountry ), $html );
  39      }
  40  }
  41  new MP_Ip_ipinfoio();


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