Project

General

Profile

[Solved] How to display a user's ipv4 or ipv6 address?

Added by ryan14 about 13 years ago

Is there a lighttpd code that I can insert into my php website that will display on my website the ipv4 or ipv6 address of a user? I do not want to use any php or javascript code. When a person comes to my website I want it to say the following:

Welcome, your ip address is XX.XXX.XXX


Replies (3)

RE: How to display a user's ipv4 or ipv6 address? - Added by icy about 13 years ago

Why don't you want to use any PHP code when you want to display it inside your PHP site?
And no, Lighty does not have any such ready made code (one could use mod_magnet but why...).

Just echo $_SERVER['REMOTE_ADDR'] in PHP and done.

RE: How to display a user's ipv4 or ipv6 address? - Added by ryan14 about 13 years ago

I thought REMOTE_ADDR can only report an ipv4 address? Because ipv6 addresses are formatted like fe80:0000:0000:0000:0202:b3ff:fe1e:8329. Have you actually tried this yourself?

RE: How to display a user's ipv4 or ipv6 address? - Added by omes about 13 years ago

root@lucas:/var/www# cat myip.php 
<?= "{$_SERVER["REMOTE_ADDR"]}\n"; ?>
root@lucas:~# wget -qO- http://[::1]/myip.php
::1
root@lucas:~# wget -qO- http://127.0.0.1/myip.php
127.0.0.1

Please read http://redmine.lighttpd.net/wiki/lighttpd/IPv4_mapped_addresses
    (1-3/3)