Posted By

daipratt on 07/25/10


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Some0ne
osirisinternet
WaxWing


Get the real IP address of a user.


 / Published in: PHP
 

  1. function getRealIpAddr()
  2. {
  3. if (!emptyempty($_SERVER['HTTP_CLIENT_IP']))
  4. {
  5. $ip=$_SERVER['HTTP_CLIENT_IP'];
  6. }
  7. elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR']))
  8. //to check ip is pass from proxy
  9. {
  10. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  11. }
  12. else
  13. {
  14. $ip=$_SERVER['REMOTE_ADDR'];
  15. }
  16. return $ip;
  17. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: AllKnightAccess on July 26, 2010

There is an error in the code.

The instances of "emptyempty" should just be "empty".

You need to login to post a comment.