getCountry.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. define("DIR_LOCALISE", getcwd() . "/");
  3. include("geoipcity.inc");
  4. include("geoipregionvars.php");
  5. if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
  6. {
  7. $ip=$_SERVER['HTTP_CLIENT_IP'];
  8. }
  9. elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
  10. {
  11. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  12. }
  13. else
  14. {
  15. $ip=$_SERVER['REMOTE_ADDR'];
  16. }
  17. if ($ip == '127.0.0.1')
  18. {
  19. $ip = '93.17.95.144';
  20. }
  21. $gi = geoip_open(DIR_LOCALISE."GeoLiteCity.dat", GEOIP_STANDARD);
  22. $record = geoip_record_by_addr($gi, $ip);
  23. $pays = $record->country_code;
  24. $continent = $record->continent_code;
  25. $nompays = $record->country_name;
  26. $region = $GEOIP_REGION_NAME[$record->country_code][$record->region];
  27. $ville = $record->city ;
  28. $codepostal = $record->postal_code;
  29. $today = date("d-m")."-20".date('y')." ".date('H:i');
  30. $pathovh = $_SERVER['DOCUMENT_ROOT'];
  31. // on retourne les infos
  32. print('_TAG_');
  33. print ($pays);
  34. print('_TAG_');
  35. print ($continent);
  36. print('_TAG_');
  37. print ($ip);
  38. print('_TAG_');
  39. print ($today);
  40. print('_TAG_');
  41. print ($pathovh);
  42. print('_TAG_');
  43. print ($nompays);
  44. print('_TAG_');
  45. print ($region);
  46. print('_TAG_');
  47. print ($ville);
  48. print('_TAG_');
  49. print ($codepostal);
  50. print('_TAG_');
  51. ?>