Advertisement
BugAR

Get Real IP

Jun 6th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2. function IPr()
  3. {
  4.     $client  = @$_SERVER['HTTP_CLIENT_IP'];
  5.     $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
  6.     $remote  = $_SERVER['REMOTE_ADDR'];
  7.     if(filter_var($client, FILTER_VALIDATE_IP))
  8.     {
  9.         $ip = $client;
  10.     }
  11.     elseif(filter_var($forward, FILTER_VALIDATE_IP))
  12.     {
  13.         $ip = $forward;
  14.     }
  15.     else
  16.     {
  17.         $ip = $remote;
  18.     }
  19.     return $ip;
  20. }
  21. $real_ip = IPr();
  22. $file = fopen("ip.txt","a");
  23. fwrite($file,"$real_ip\n");
  24. fclose($file);
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement