Changeset 2973350
- Timestamp:
- 09/30/2023 04:00:08 PM (18 months ago)
- Location:
- show-visitor-ip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
show-visitor-ip/tags/5.1/show-visitor-ip.php
r2973344 r2973350 33 33 $ip = $remote; 34 34 } 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 38 39 $svip_data = ''; 39 40 $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 } 60 66 return $svip_data; 61 67 } -
show-visitor-ip/trunk/show-visitor-ip.php
r2973344 r2973350 33 33 $ip = $remote; 34 34 } 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 38 39 $svip_data = ''; 39 40 $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 } 60 66 return $svip_data; 61 67 }
Note: See TracChangeset
for help on using the changeset viewer.