Advertisement
AlexM1SHOP

geo php

Dec 27th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. $client  = @$_SERVER['HTTP_CLIENT_IP'];
  4. $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
  5. $remote  = @$_SERVER['REMOTE_ADDR'];
  6. $result  = array('country'=>'', 'city'=>'');
  7.  
  8. if(filter_var($client, FILTER_VALIDATE_IP)) $ip = $client;
  9. elseif(filter_var($forward, FILTER_VALIDATE_IP)) $ip = $forward;
  10. else $ip = $remote;
  11.  
  12. $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
  13. if($ip_data && $ip_data->geoplugin_countryName != null)
  14. {
  15.     $geo = $ip_data->geoplugin_countryCode;
  16. }
  17.  
  18. switch ($geo) {
  19.     case "RU":
  20.         $oldPrice='';
  21.         $newPrice='';
  22.     break;
  23.    
  24. default:
  25.         $oldPrice='';
  26.         $newPrice='';
  27. }
  28.  
  29. ?>
  30.  
  31. <?include('geo.php');?>
  32. <?=$oldPrice;?>
  33. <?=$newPrice;?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement