Advertisement
NiTeWuRX

Function to get the IP of submitter

Jun 6th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. <?php
  2. // Function to get the IP of submitter
  3.     function getRealIpAddr()
  4.     {
  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.        //echo $ip;
  18.         return $ip;
  19.     }
  20. //
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement