Current location: Hot Scripts Forums » Programming Languages » PHP » IP extraction


IP extraction

Reply
  #1 (permalink)  
Old 08-05-06, 07:54 AM
jumbo1 jumbo1 is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 118
Thanks: 0
Thanked 0 Times in 0 Posts
IP extraction

Dear all

I have a problem getting the IP information of my visitors from my server.

I know the IP information is acquired through the following variable:

Code:

$ip=$_SERVER['REMOTE_ADDR'];
Though, i tested this one on a computer connected to an ISP that has a proxy. This code returns an IP: 88.86.31.1 while IPCONFIG on windows and www.whatismyip.com returned 88.86.4.196 so i though most probably the IP returned by the code is actually the IP of the proxy not that of the client...

how can i extract the actual IP of the client??

Thank you
Reply With Quote
  #2 (permalink)  
Old 08-05-06, 08:31 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
You can't.

Besides, how would it help? It will pretty much always be 192.168.*.*
__________________
The toxic ZCE
Reply With Quote
  #3 (permalink)  
Old 08-07-06, 08:37 AM
jumbo1 jumbo1 is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 118
Thanks: 0
Thanked 0 Times in 0 Posts
of course it would help!!

as i said, 88.86.31.1 is the IP of the ISP's proxy... meaning that the variable $_SERVER['REMOTE_ADDR'] would return the same IP for all those people connected to the same ISP!! i cant assume that 1000 people all have the same IP!! i need the real IP of these people over the internet, and i CAN... coz www.whatismyip.com can...
Reply With Quote
  #4 (permalink)  
Old 08-07-06, 09:23 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Huh? You said in your first post that whatismyip.com can only grab the proxy IP, and then in your second message you say it can grab the internal IP? Am I reading that correctly? Once again, you cannot with PHP... and neither can whatismyip.com.

I work in an office with 60+ people, and behind our proxy whatismyip.com returns the same IP for everyone... the external public IP. It cannot get beyond proxies, routers, etc... where our IP is 192.168.2.*

Since PHP is a server-side language, it cannot access internal IP addresses. You will need something client-side, like javascript, to grab the IP from the browser and send that to a PHP file where it can be recorded.
__________________
The toxic ZCE

Last edited by Keith; 08-07-06 at 09:49 AM.
Reply With Quote
  #5 (permalink)  
Old 08-09-06, 08:00 AM
jumbo1 jumbo1 is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 118
Thanks: 0
Thanked 0 Times in 0 Posts
no, what i said is that whatismyip.com returns my correct IP (88.86.4.196) while the PHP $_SERVER['REMOTE_ADDR'] returns the IP of the proxy (88.86.31.1) which is the same for all those connected to that particular ISP.

so there MUST be a way to know what my true IP is... maybe PHP cannot get it..

ipconfig gives me 192.168.5.14 for "server IP address"...

anyway, thanks for the help.. i will try to look somewhere else, and i will report in case of success
Reply With Quote
  #6 (permalink)  
Old 08-16-06, 06:34 PM
0o0o0 0o0o0 is offline
Wannabe Coder
 
Join Date: Jul 2005
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
Did anyone hear a please or thankyou? maybe I missed it.
lol
Reply With Quote
  #7 (permalink)  
Old 08-16-06, 08:58 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
Quote:
Originally Posted by jumbo1
so there MUST be a way to know what my true IP is... maybe PHP cannot get it.
Listen to Keith. You can't necessarily get it via PHP due to several issues- proxies, local masking by routers and firewalls, etc.
__________________
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]
Reply With Quote
  #8 (permalink)  
Old 08-16-06, 09:57 PM
NabZ NabZ is offline
Newbie Coder
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 1 Time in 1 Post
This should help.

$ip = (getenv(HTTP_X_FORWARDED_FOR)) ? getenv(HTTP_X_FORWARDED_FOR):getenv(REMOTE_ADDR);
Reply With Quote
  #9 (permalink)  
Old 08-16-06, 10:06 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
HTTP_X_FORWARDED_FOR is rarely made available, plus it can easily be modified. Just an FYI.
__________________
The toxic ZCE
Reply With Quote
  #10 (permalink)  
Old 08-17-06, 03:34 AM
jumbo1 jumbo1 is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 118
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by 0o0o0
Did anyone hear a please or thankyou? maybe I missed it.
lol
take it easy man, i said thanks, just review my last posting... r u the man who surfs through the post to make sure everyone's polite and gentle??

NabZ, that's what i needed!! getenv(HTTP_X_FORWARDED_FOR) now returns the same IP that whatismyip.com returns...

as for the fact that it is not always made available, i have no idea about it, but there should always be a way to get some information to distinguish a client from another... take google adsense for example... if u click on a google ad and then click again on another, google wont count that click and u wont be paid on it, coz the same "guy" or IP clicked on a google ad previously... if there wasnt a way to distinguish people ALL AROUND THE WORLD (and many are behind a proxy), google adsense would be easily crackable, and a guy behind a proxy would click on ads infinitely and generate lots of money by doing this...

thank you...

keith can u please clarify how HTTP_X_FORWARDED_FOR can be modified?

thanx again
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
Ip Address Question? purpleman The Lounge 2 07-12-06 05:59 PM
Display vistor IP, Browser, OS, Hostname, Country Nubier General HotScripts Site Discussion 0 09-10-05 11:19 PM
Need help with ip unique hits with times control postyourweb PHP 5 07-19-05 08:07 PM
Refresh IP Address thorchan Visual Basic 0 04-16-05 02:30 AM
Ip of machine on network Sowhat PHP 5 04-11-05 07:29 AM


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