Advertisement
Guest User

Untitled

a guest
Mar 1st, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?php
  2.  
  3. $IP = $_SERVER['REMOTE_ADDR'];
  4.  
  5. //$IP = '31.3.223.255'; //uk ip for test
  6.  
  7. $Url='https://geoip.maxmind.com/geoip/v2.1/country/'.$IP;
  8.  
  9. $username = 100969;
  10.  
  11. $password = 'uESdyU1V0cyJ';
  12.  
  13.  
  14.  
  15. $ch = curl_init();
  16.  
  17. curl_setopt($ch, CURLOPT_URL, $Url);
  18.  
  19. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  20.  
  21. curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  22.  
  23. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  24.  
  25. $tmp_json_country_code = curl_exec($ch);
  26.  
  27. curl_close($ch);
  28.  
  29. $record=json_decode($tmp_json_country_code);
  30.  
  31.  
  32.  
  33. $country_name=$record->country->names->en;
  34.  
  35.  
  36.  
  37. if($country_name=="United Kingdom" || $country_name=="Ireland" || $country_name=="England" || $country_name=="Wales" || $country_name=="Scotland")
  38.  
  39. {
  40.  
  41. $tmp_ip=1;
  42.  
  43. }
  44.  
  45. else
  46.  
  47. {
  48.  
  49. $tmp_ip=0;
  50.  
  51. }
  52.  
  53.  
  54.  
  55. $tmp_str_filenames=$_SERVER['REQUEST_URI'];
  56.  
  57.  
  58.  
  59.  
  60.  
  61. $tmp_str_file_path=substr($tmp_str_filenames,1); // remove the first/
  62.  
  63.  
  64.  
  65. if(strpos($_SERVER['UNENCODED_URL'], 'special') !== false && $tmp_ip==1){
  66.  
  67. header("HTTP/1.1 301 Moved Permanently");
  68.  
  69. header( "Location: http://www.eliteislandresorts.co.uk/pages/special-offers.php" ); exit;
  70.  
  71. }else if(strpos($_SERVER['UNENCODED_URL'],'contact') !== false && $tmp_ip==1){
  72.  
  73. header("HTTP/1.1 301 Moved Permanently");
  74.  
  75. header( "Location: http://www.eliteislandresorts.co.uk/pages/contact-us.php" ); exit;
  76.  
  77. }
  78.  
  79.  
  80.  
  81. if($tmp_ip==1)
  82.  
  83. {
  84.  
  85. header("HTTP/1.1 301 Moved Permanently");
  86.  
  87. header( "Location: http://www.eliteislandresorts.co.uk/index.php" ); exit;
  88.  
  89. }
  90.  
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement