473,485 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Php: getting local IP

Jezternz
145 New Member
Easy to get the external ip adress, using the $SERVER var, but I want the local ip.
My situation isnt normal by the way. Basicly im building simple intranet ( i want to run this on a local area network (will be hundreds of people) not on the web, so for logins im gonna be using local ip's, is there any way I can get them easily?
$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] <- people have said this would work.. but would it actually work in a lan invroment, im not so sure.

Thanks, Josh
Jun 7 '08 #1
3 2745
Atli
5,058 Recognized Expert Expert
Hi.

Even when connecting from a LAN, "$_SERVER['REMOTE_ADDR']" should give you the local IP of the computer that sent the request.

I doubt "$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']" works, as it is on of a few non-standard headers, sent by some proxy servers in an attempt to reveal the actual IP of users trying to hide their identity by going through a proxy.
Jun 7 '08 #2
Jezternz
145 New Member
oh ok cool thanks heaps.
So how do you tell pc's apart on the internt if they are shareing the same internet connection? I remember having this problem at school, you log in on one pc, and it logs in on all pcs, because all the pc's had the same external ip? is there any way of getting local ips in that example?

cheers, Josh
Jun 7 '08 #3
Atli
5,058 Recognized Expert Expert
When you connect to the internet via a router, the router is essentially working as a proxy server. It makes the request for you and redirects any response to you.

As such, there is really no way to differentiate between the local machines, as the IP will just point back to the router.
Unless it explicitly set a header with the local IP address, which I find unlikely due to security reasons.
Not to mention that a local IP address is useless to anybody outside the LAN.

If you want to find out, just do a "print_r($_SERVER)" and see if your local IP is in there somewhere. You would obviously have to try this from a remote computer.
Jun 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2682
by: Patrick Saunders | last post by:
I have been trying to GD working on HPUX for about, oh 2 months now, and have come across something that was interesting. I have this configuration: HPUX 11 Bundled Apache 2.0/PHP 4.3.4 ...
4
1620
by: petermichaux | last post by:
Hi, I have installed PHP 5.0.3 for OS X. I have read in several places that PEAR is included in recent installations of PHP. I'm having trouble getting PEAR DB working. How would I know or test...
8
6258
by: lawrence k | last post by:
I've installed Apache 1.3.36 on my Redhat EL 3 machine. Now I'm trying to install PHP 5.1.4. I can not get the ./configure command to work. I keep getting this error: configure: error: Invalid...
1
12330
by: browntown | last post by:
I'm trying to install the Image_Color pear package. I keep getting the following error: "'gd' PHP extension is not installed" phpinfo on my web server indicates that gd is enabled. when I try...
3
5601
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
0
6960
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7116
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6825
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5418
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1376
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
595
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.