Plugin Directory

Changeset 2973350


Ignore:
Timestamp:
09/30/2023 04:00:08 PM (18 months ago)
Author:
devikas301
Message:

updating

Location:
show-visitor-ip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • show-visitor-ip/tags/5.1/show-visitor-ip.php

    r2973344 r2973350  
    3333        $ip = $remote;
    3434    }
    35 
    36     $ip_data = @json_decode(file_get_contents("http://ip-api.com/json/".$ip.'?fields=status,country,countryCode,region,regionName,city,lat,lon,timezone,currency'));   
    37          
     35   
     36    $url = 'http://ip-api.com/json/'. $ip.'?fields=status,country,countryCode,region,regionName,city,lat,lon,timezone,currency';
     37    $response = wp_remote_get($url);   
     38   
    3839    $svip_data = '';
    3940    $svip_ltype = $svip['type'];
    40      
    41     if($ip_data && $ip_data->status == 'success'){     
    42      if($svip_ltype == 'countryCode'){
    43        $svip_data = $ip_data->countryCode;
    44      } elseif($svip_ltype == 'region'){
    45        $svip_data = $ip_data->regionName;
    46      } elseif($svip_ltype == 'lat'){
    47        $svip_data = $ip_data->lat;
    48      } elseif($svip_ltype == 'long'){
    49        $svip_data = $ip_data->lon;
    50      } elseif($svip_ltype == 'city'){
    51        $svip_data = $ip_data->city;
    52      } elseif($svip_ltype == 'timeZone'){
    53        $svip_data = $ip_data->timezone;
    54      } elseif($svip_ltype == 'currency'){
    55        $svip_data = $ip_data->currency;
    56      } else {
    57        $svip_data = $ip_data->country;
    58      }
    59     }
     41   
     42    if(is_array($response)){
     43       
     44        $ip_data = json_decode($response['body'], true);
     45       
     46        if($ip_data){       
     47         if($svip_ltype == 'countryCode'){
     48           $svip_data = $ip_data['countryCode'];
     49         } elseif($svip_ltype == 'region'){
     50           $svip_data = $ip_data['regionName'];
     51         } elseif($svip_ltype == 'lat'){
     52           $svip_data = $ip_data['lat'];
     53         } elseif($svip_ltype == 'long'){
     54           $svip_data = $ip_data['lon'];
     55         } elseif($svip_ltype == 'city'){
     56           $svip_data = $ip_data['city'];
     57         } elseif($svip_ltype == 'timeZone'){
     58           $svip_data = $ip_data['timezone'];
     59         } elseif($svip_ltype == 'currency'){
     60           $svip_data = $ip_data['currency'];
     61         } else {
     62           $svip_data = $ip_data['country'];
     63         }
     64        }
     65    }
    6066    return $svip_data;
    6167 }
  • show-visitor-ip/trunk/show-visitor-ip.php

    r2973344 r2973350  
    3333        $ip = $remote;
    3434    }
    35 
    36     $ip_data = @json_decode(file_get_contents("http://ip-api.com/json/".$ip.'?fields=status,country,countryCode,region,regionName,city,lat,lon,timezone,currency'));   
    37          
     35   
     36    $url = 'http://ip-api.com/json/'. $ip.'?fields=status,country,countryCode,region,regionName,city,lat,lon,timezone,currency';
     37    $response = wp_remote_get($url);   
     38   
    3839    $svip_data = '';
    3940    $svip_ltype = $svip['type'];
    40      
    41     if($ip_data && $ip_data->status == 'success'){     
    42      if($svip_ltype == 'countryCode'){
    43        $svip_data = $ip_data->countryCode;
    44      } elseif($svip_ltype == 'region'){
    45        $svip_data = $ip_data->regionName;
    46      } elseif($svip_ltype == 'lat'){
    47        $svip_data = $ip_data->lat;
    48      } elseif($svip_ltype == 'long'){
    49        $svip_data = $ip_data->lon;
    50      } elseif($svip_ltype == 'city'){
    51        $svip_data = $ip_data->city;
    52      } elseif($svip_ltype == 'timeZone'){
    53        $svip_data = $ip_data->timezone;
    54      } elseif($svip_ltype == 'currency'){
    55        $svip_data = $ip_data->currency;
    56      } else {
    57        $svip_data = $ip_data->country;
    58      }
    59     }
     41   
     42    if(is_array($response)){
     43       
     44        $ip_data = json_decode($response['body'], true);
     45       
     46        if($ip_data){       
     47         if($svip_ltype == 'countryCode'){
     48           $svip_data = $ip_data['countryCode'];
     49         } elseif($svip_ltype == 'region'){
     50           $svip_data = $ip_data['regionName'];
     51         } elseif($svip_ltype == 'lat'){
     52           $svip_data = $ip_data['lat'];
     53         } elseif($svip_ltype == 'long'){
     54           $svip_data = $ip_data['lon'];
     55         } elseif($svip_ltype == 'city'){
     56           $svip_data = $ip_data['city'];
     57         } elseif($svip_ltype == 'timeZone'){
     58           $svip_data = $ip_data['timezone'];
     59         } elseif($svip_ltype == 'currency'){
     60           $svip_data = $ip_data['currency'];
     61         } else {
     62           $svip_data = $ip_data['country'];
     63         }
     64        }
     65    }
    6066    return $svip_data;
    6167 }
Note: See TracChangeset for help on using the changeset viewer.