[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_Ip_geoplugin extends MP_ip_provider_
   3  {
   4      var $id     = 'geoplugin';
   5      var $url    = 'http://www.geoplugin.net/xml.gp?ip=%1$s';
   6      var $credit    = 'http://www.geoplugin.net/';
   7      var $type     = 'xml';
   8  
   9  	function content( $valid, $content )
  10      {
  11          if ( strpos( $content, '<geoplugin_latitude/>' ) !== false ) return false;
  12          return $valid;
  13      }
  14  
  15  	function data( $content, $ip )
  16      {
  17          $skip = array( 'geoplugin_areaCode', 'geoplugin_dmaCode', 'geoplugin_continentCode', 'geoplugin_currencyCode', 'geoplugin_currencySymbol', 'geoplugin_currencySymbol_UTF8', 'geoplugin_currencyConverter' );
  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( 'geoplugin_region', 'geoplugin_countryCode', 'geoplugin_latitude', 'geoplugin_longitude' ) ) ) {$$k = $v; continue;}
  29  
  30              $html .= '<p style="margin:3px;"><b>' . str_replace( 'geoplugin_', '', $k ) . '</b> : ' . $v . '</p>';
  31          }
  32          $geo = ( isset( $geoplugin_latitude ) && isset( $geoplugin_longitude ) ) ?     array( 'lat' => $geoplugin_latitude, 'lng' => $geoplugin_longitude ) : array();
  33          $country = ( isset( $geoplugin_countryCode ) ) ? $geoplugin_countryCode : '';
  34          $subcountry = ( isset( $geoplugin_region ) )   ? $geoplugin_region : '';
  35          return $this->cache_custom( $ip, $geo, strtoupper( substr( $country, 0, 2 ) ), strtoupper( $subcountry ), $html );
  36      }
  37  }
  38  new MP_Ip_geoplugin();


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