[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_Ip_extreme_ip_lookup extends MP_ip_provider_
   3  {
   4      var $id     = 'extreme-ip-lookup';
   5      var $url    = 'https://extreme-ip-lookup.com/json/%1$s';
   6      var $credit    = 'https://extreme-ip-lookup.com/';
   7      var $type     = 'json';
   8  
   9  	function content( $valid, $content )
  10      {
  11          if ( strpos( $content, '"lat" : ""' ) ) return false;
  12          return $valid;
  13      }
  14  
  15  	function data( $content, $ip )
  16      {
  17          $UsStates = array(
  18              'Alabama' => 'AL', 'Alaska' => 'AK', 'Arizona' => 'AZ', 'Arkansas' => 'AR', 
  19              'California' => 'CA', 'Colorado' => 'CO', 'Connecticut' => 'CT',
  20              'Delaware' => 'DE',
  21              'Floride' => 'FL',
  22              'Georgia' => 'GA',
  23              'Hawaii' => 'HI',
  24              'Idaho' => 'ID', 'Illinois' => 'IL', 'Indiana' => 'IN', 'Iowa' => 'IA',
  25              'Kansas' => 'KS', 'Kentucky' => 'KY',
  26              'Louisiana' => 'LA',
  27              'Maine' => 'ME', 'Maryland' => 'MD', 'Massachusetts' => 'MA', 'Michigan' => 'MI',     'Minnesota' => 'MN',     'Mississippi' => 'MS', 'Missouri' => 'MO', 'Montana' => 'MT',
  28              'Nebraska' => 'NE', 'Nevada' => 'NV', 'New Hampshire' => 'NH', 'New Jersey' => 'NJ', 'New Mexico' => 'NM', 'New York' => 'NY', 'North Carolina' => 'NC', 'North Dakota' => 'ND',
  29              'Ohio' => 'OH', 'Oklahoma' => 'OK', 'Oregon' => 'OR',
  30              'Pennsylvania' => 'PA',
  31              'Rhode Island' => 'RI',
  32              'South Carolina' => 'SC', 'South Dakota' => 'SD',
  33              'Tennessee' => 'TN', 'Texas' => 'TX',
  34              'Utah' => 'UT',
  35              'Vermont' => 'VT', 'Virginia' => 'VA',
  36              'Washington' => 'WA', 'West Virginia' => 'WV', 'Wisconsin' => 'WI', 'Wyoming' => 'WY',
  37          );
  38              
  39          $skip = array( 'continent', 'ipName', 'ipType', 'isp', 'query', 'status' );
  40          $html = '';
  41  
  42          $json =  json_decode( $content, true );
  43  
  44          foreach ( $json as $k => $v )
  45          {
  46              if ( $v == 'n/a' ) continue;
  47              if ( empty( $v ) ) continue;
  48  
  49              if ( in_array( $k, $skip ) ) continue;
  50  
  51              if ( in_array( $k, array( 'countryCode', 'region', 'lat', 'lon' ) ) ) {$$k = $v; continue;}
  52  
  53              $html .= '<p style="margin:3px;"><b>' . $k . '</b> : ' . $v . '</p>';
  54          }
  55  
  56          $geo = array( 'lat' => $lat, 'lng' => $lon );
  57  
  58          if ( 'US' == strtoupper( $countryCode ) )
  59          {
  60              $subcountry = ( isset( $UsStates[$region] ) ) ? $UsStates[$region] : MP_Ip::get_USstate( $ip );
  61          }
  62          else $subcountry = MP_Ip::no_state;
  63          return $this->cache_custom( $ip, $geo, strtoupper( $countryCode ), strtoupper( $subcountry ), $html );
  64      }
  65  }
  66  new MP_Ip_extreme_ip_lookup();


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