PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 11th, 2004, 07:42 PM
devqual devqual is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Porto, Portugal
Posts: 33 devqual User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 19 m 41 sec
Reputation Power: 14
Get Local IP adress using PHP

Dear All,

Is it possible to get a local IP (behind a firewall/proxy server) using php / javascript?

Thank you in advance for your help.

Reply With Quote
  #2  
Old February 12th, 2004, 01:37 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Do you mean local IP as in the remote client's IP?

$_SERVER['REMOTE_ADDR']
The IP address from which the user is viewing the current page.


Check the php documentation for more information:
http://ca2.php.net/reserved.variables

Reply With Quote
  #3  
Old February 12th, 2004, 03:11 AM
devqual devqual is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Porto, Portugal
Posts: 33 devqual User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 19 m 41 sec
Reputation Power: 14
Quote:
Originally Posted by MadCowDzz
Do you mean local IP as in the remote client's IP?

$_SERVER['REMOTE_ADDR']
The IP address from which the user is viewing the current page.


Check the php documentation for more information:
http://ca2.php.net/reserved.variables



Not properly!

$_SERVER['REMOTE_ADDR'] will indeed give me de IP from which the user is viewing the page but what I realy like to know is as follows:

If the user is part of a local network that uses a proxy server to access the internet it will have a local IP to acess that proxy. The problem is that I need to recognize one single computer in that local network but not all the computers behind that proxy.

Thank you for your help.

Reply With Quote
  #4  
Old February 12th, 2004, 04:15 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 14
Send a message via MSN to Spongy
Do you want to share with us why you need some sort of IP? It smells...

Reply With Quote
  #5  
Old February 12th, 2004, 04:33 AM
devqual devqual is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Porto, Portugal
Posts: 33 devqual User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 19 m 41 sec
Reputation Power: 14
Quote:
Originally Posted by Spongy
Do you want to share with us why you need some sort of IP? It smells...


Yes, no problem!

I have an on-line service to libraries that I would like to provide to single computers after a subscription. I initialy though about using an ip adress autentication in order to avoid two problems with user name/pass autentication:

1- The library needs to ask for the password every time e wants to access the service.

2- Avoid the pass distribution to other people.

Thanks,


I really hope it doesn't suck's...
If you have another solution please advise...

Reply With Quote
  #6  
Old February 12th, 2004, 04:37 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 14
Send a message via MSN to Spongy
Ok, I understand... Sorry for that!

I know that people can look at their local adress, and I know that there are some online functions for that... Have you tried Javascript yet?

Reply With Quote
  #7  
Old February 12th, 2004, 04:43 AM
devqual devqual is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Porto, Portugal
Posts: 33 devqual User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 19 m 41 sec
Reputation Power: 14
Quote:
Originally Posted by Spongy
Ok, I understand... Sorry for that!

I know that people can look at their local adress, and I know that there are some online functions for that... Have you tried Javascript yet?


I found something using js and asp but I'm quite new in php and I couldn't get it work...

Reply With Quote
  #8  
Old February 12th, 2004, 04:55 AM
Spongy's Avatar
Spongy Spongy is offline
Alternately High
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Hilversum, Netherlands
Posts: 223 Spongy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 56 m 41 sec
Reputation Power: 14
Send a message via MSN to Spongy
If it works in ASP it'll definitely work in PHP! I don't have much experience using js with PHP, but you'll figure it out.
Maybe you'll find something here

Reply With Quote
  #9  
Old February 12th, 2004, 11:23 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Not neccesarily Not everything is cross platform.. I know that you can get the IP address of the person visiting, the address assigned to them, however if they are behind a firewall or router the capability of getting that internal address is much harder. I would think that you would have to open a direct connection client side to your server in order to get an internal ip address.. and for the type of security you are trying to impliment, ip address authentication would be a bad idea -- addresses can be faked. For example, if I knew that I could establish a connection to your machine via a specific method (for example secure connection thru ssh) and you didn't have any limit on to how many ip addresses I could submit, ideally I could find out your internal ip structure by process of elimination (most people who have home lans use the default of 192.168.x.x with a subnet of 255.255.255.x as default) and therefore fake a packet and get the files you're hosting.. You might want to think about another method for this

Quote:
Originally Posted by Spongy
If it works in ASP it'll definitely work in PHP! I don't have much experience using js with PHP, but you'll figure it out.
Maybe you'll find something here

Reply With Quote
  #10  
Old February 13th, 2004, 02:07 PM
devqual devqual is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Porto, Portugal
Posts: 33 devqual User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 19 m 41 sec
Reputation Power: 14
Thumbs up Thanks

I know that many people use the default 192.168.x.x with a subnet of 255.255.255.x. However I could use both, the server ip and then the lan-network ip to cross check. But any way I will use another sort of validation..

Thank u all

Reply With Quote
  #11  
Old May 8th, 2004, 08:12 PM
matth matth is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 matth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
get local IP with php

Hi all,
That's a little late, but that may help other people, if you want to get the local IP of the user in the situation where the user is requesting through a proxy :
$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']
should do the trick...

Reply With Quote
  #12  
Old May 9th, 2004, 06:02 PM
rpan rpan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 10 rpan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried:

$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']

But it return an empty value. What else do I have to do to get the correct output? I am using PHP 4.3.X

Reply With Quote
  #13  
Old May 9th, 2004, 07:41 PM
agoossens agoossens is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 4 agoossens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Depends on proxy

Whether $_SERVER['HTTP_X_FORWARDED_FOR'] is set or not depends on the proxy server. Not all proxy servers will set this value, so that is why it does not always appear.

You can enable or disable forward reporting in most proxy servers, and the smart move is to disable it; after all, you don't want people on the Internet knowing about the structure of your internal LAN!

Reply With Quote
  #14  
Old August 11th, 2004, 11:31 PM
websecurity websecurity is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 websecurity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yup, should not be a problem. Their internal IP and more, but the catch is that it has to be IE.

Take a look at Patch Management for an example.

I think it does have something with x_forwarded_for and perhaps it is spelled dirrerent - like the referer and the referrer, just depends on the browser being used.

URL

Quote:
Originally Posted by devqual
Dear All,

Is it possible to get a local IP (behind a firewall/proxy server) using php / javascript?

Thank you in advance for your help.

Reply With Quote
  #15  
Old August 13th, 2004, 05:14 AM
pvsat pvsat is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 pvsat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Look for HTTP_FORWARDED_FOR. It should be inside your CGI variable. But again it is not guranteed that it will always be available as it depends on the proxy server thur which the client machine is accessing the internet. So proxy servers do send the HTTP_FORWARDED_FOR and some do not.

Reply With Quote
  #16  
Old November 24th, 2004, 04:03 AM
jayesh jayesh is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 jayesh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Is it possible to get a local IP Address

Use the following function
<?php
function getIp()
{

$ip_address=$_SERVER['HTTP_X_FORWARDED_FOR'];

if ($ip_address==NULL){
$ip_address=$_SERVER[REMOTE_ADDR]; }
return
$ip_address;
}

Last edited by jayesh : November 24th, 2004 at 05:16 AM. Reason: update

Reply With Quote
  #17  
Old February 8th, 2005, 06:24 AM
aneedz aneedz is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 aneedz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 46 sec
Reputation Power: 0
Lightbulb a little note

Hi ... please check the jayesh 's code It probably would work for you.

here's a little tip in case you are missing it, don't check the script in your local lan. proxy's are normally configured to bypass local lan's so put your code on some remote server and then try it out.

http://www.asifiqbal.com/img.php check this link it works perfect for me using firefox, ie, netscape. I am behind squid proxy.

I am not sure about the other proxies.

Asif

Quote:
Originally Posted by devqual
Dear All,

Is it possible to get a local IP (behind a firewall/proxy server) using php / javascript?

Thank you in advance for your help.

Reply With Quote
  #18  
Old February 14th, 2005, 05:50 AM
mudderklirren mudderklirren is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 mudderklirren User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 33 sec
Reputation Power: 0
<quote>Take a look at Patch Management for an example.

I think it does have something with x_forwarded_for and perhaps it is spelled dirrerent - like the referer and the referrer, just depends on the browser being used.
</quote>

Acturally they use an java applet, just like at this page
http://reglos.de/myaddress/MyAddress.html
The problem here is that it on some computers takes quite a while to start the Java VM, and it doesnt work on browsers without java.

I just keep searching...

/Dan

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Get Local IP adress using PHP


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap