Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. // from http://www.xpertdeveloper.com/2011/09/get-real-ip-address-using-php/
  3. if (!empty($_SERVER["HTTP_CLIENT_IP"]))
  4. {
  5. //check for ip from share internet
  6. $ip = $_SERVER["HTTP_CLIENT_IP"];
  7. }
  8. elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
  9. {
  10. // Check for the Proxy User
  11. $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
  12. }
  13. else
  14. {
  15. $ip = $_SERVER["REMOTE_ADDR"];
  16. }
  17. // This will print user's real IP Address
  18. // does't matter if user using proxy or not.
  19. echo "ايبيك يا حمار ".$ip;
  20. $cip = $ip;
  21. $iptolocation = 'https://api.ipgeolocation.io/ipgeo?apiKey=c142ac7883294fe49dd958aa00cde096&ip='.$ip.'&fields=country_name,city';
  22. $creatorlocation = file_get_contents($iptolocation);
  23. ?>
  24. <?php
  25. if(isset($ip))
  26. {
  27. $data=$ip;
  28. $fp = fopen('ip.txt', 'a');
  29. fwrite($fp, " $creatorlocation ".date(" d/m/Y").date(" h:i:s")."\n");
  30. fclose($fp);
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement