Cable Forum

Cable Forum (https://www.cableforum.uk/board/index.php)
-   Internet Discussion (https://www.cableforum.uk/board/forumdisplay.php?f=25)
-   -   Remote IP addy on page? (https://www.cableforum.uk/board/showthread.php?t=16406)

altis 18-08-2004 22:50

Remote IP addy on page?
 
How can I get the remote IP address onto an HTML page?

I have discovered that, if I change the filename to index.shtml, this switches on SSI and I can use something like the following:

Code:

<a href="mailto:<!--#echo var='REMOTE_ADDR'-->@mysite.co.uk">
This works fine but it generates the address in the usual xx.xx.xx.xx format. I would prefer it as an 8-digit hexadecimal number so as not to put peeps off.

This code also has a problem with NTLs transparent caches since it reports their IP and not the user's. I seem to remember Sir Robin pointing out that the new caches were configured incorrectly.

Any ideas?

philip.j.fry 19-08-2004 00:16

Re: Remote IP addy on page?
 
I'm not an expert on SSI, but if your web host has php or cgi enabled, you could use these. Fairly similar idea, you get the remote address as a variable, from there you use a conversion function to get the hex then print it back out to the page.

Paul 19-08-2004 02:41

Re: Remote IP addy on page?
 
Quote:

Originally Posted by altis
This code also has a problem with NTLs transparent caches since it reports their IP and not the user's. I seem to remember Sir Robin pointing out that the new caches were configured incorrectly.

Any ideas?

AFAIK the caches are configured correctly, the client ip is contained in one of two other variables - they (and the variable details) are on this page.

Frank 19-08-2004 04:01

Re: Remote IP addy on page?
 
I'm not sure how to do this with SSI (or if you can) as it's so old :D

This can be done very easily on PHP however, just a few line of code to tes the variables and to display them as explained in Paul's link.

E.G.

PHP Code:

<?php
     
if (getenv(HTTP_X_FORWARDED_FOR)) { 
    
//get past a proxy addy
    
$ip=getenv(HTTP_X_FORWARDED_FOR); 
    } else { 
    
//normal ip addy
    
$ip=getenv(REMOTE_ADDR); 
    }
    echo 
"$ip";
    
?>

Some caches did return the IP address backwards at one point, but I believe his was fixed.


All times are GMT. The time now is 04:23.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum