Current location: Hot Scripts Forums » Programming Languages » PHP » Get Real Ip Address


Get Real Ip Address

Reply
  #1 (permalink)  
Old 09-28-09, 07:49 AM
smithygotlost smithygotlost is offline
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 413
Thanks: 12
Thanked 3 Times in 3 Posts
Get Real Ip Address

Heya guys

Just wondered if it is possible by any means to get someones ip even if they are using a proxy server. like hidemyass.com i only ask as we are offering people rewards to get their link clicked want it to just be once per ip and think that proxies could be a problem. Any Suggestions ?

thanks
Mike
Reply With Quote
  #2 (permalink)  
Old 09-28-09, 08:18 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Check the HTTP headers... most proxies send an X_FORWARDED_FOR header containing the real IP, or a list of IPs if the client went through multiple proxies.
Reply With Quote
  #3 (permalink)  
Old 09-28-09, 09:22 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
This is reasonably good, but by no means foolproof:
PHP Code:

    // try and get the real IP address...
    
if (getenv('HTTP_CLIENT_IP')) {
        
$ip_address getenv('HTTP_CLIENT_IP');
    }elseif (
getenv('HTTP_X_FORWARDED_FOR')) {
        
$ip_address getenv('HTTP_X_FORWARDED_FOR');
    }elseif (
getenv('HTTP_X_FORWARDED')) {
        
$ip_address getenv('HTTP_X_FORWARDED');
    }elseif (
getenv('HTTP_FORWARDED_FOR')) {
        
$ip_address getenv('HTTP_FORWARDED_FOR');
    }elseif (
getenv('HTTP_FORWARDED')) {
        
$ip_address getenv('HTTP_FORWARDED');
    }else {
        
$ip_address $_SERVER['REMOTE_ADDR'];
    } 
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]

Last edited by Nico; 09-29-09 at 03:21 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freeze columns in a table Rita Negi Script Requests 1 09-01-09 08:23 AM
Ip Address Question? purpleman The Lounge 2 07-12-06 05:59 PM
Refresh IP Address thorchan Visual Basic 0 04-16-05 02:30 AM
Regular Expression IP Address Replacement CMIVXX PHP 3 11-20-04 07:27 AM


All times are GMT -5. The time now is 08:00 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.