[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_Ip_ip_api extends MP_ip_provider_
   3  {
   4      var $id     = 'ip_api';
   5      var $url    = 'http://ip-api.com/xml/%1$s';
   6      var $credit    = 'http://ip-api.com/';
   7      var $type     = 'xml';
   8  
   9  	function content( $valid, $content )
  10      {
  11          if ( strpos( $content, '<status><![CDATA[success]]></status>' ) !== false ) return false;
  12          return $valid;
  13      }
  14  
  15  	function data( $content, $ip )
  16      {
  17          $skip = array( 'status', 'timezone', 'zip', 'isp', 'as', 'query' );
  18          $html = '';
  19  
  20          $xml = $this->xml2array( $content );
  21          foreach ( $xml as $k => $v )
  22          {
  23              if ( empty( $v ) )   continue;
  24              if ( $v == 'n/a' ) continue;
  25  
  26              if ( in_array( $k, $skip ) ) continue;
  27  
  28              if ( in_array( $k, array( 'countryCode', 'region', 'regionName', 'lat', 'lon' ) ) ) {$$k = $v; continue;}
  29  
  30              $html .= '<p style="margin:3px;"><b>' . $k . '</b> : ' . $v . '</p>';
  31          }
  32          $geo = ( isset( $lat ) && isset( $lon ) ) ?     array( 'lat' => $lat, 'lng' => $lon ) : array();
  33          $country = ( isset( $country ) ) ? $countryCode : '';
  34          $subcountry =  ( 'US' == strtoupper( $country ) ) ? $region : '';
  35          return $this->cache_custom( $ip, $geo, strtoupper( substr( $countryCode, 0, 2 ) ), strtoupper( $subcountry ), $html );
  36      }
  37  }
  38  new MP_Ip_ip_api();


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