Display a user's website IP address..?
Hi there, I am a newbie to this forum so please forgive me if I have posted this in the wrong section!
I am working on a user information page (for a hosting control panel). I need to be able to show the user what their domain name is (ie. it is a list of things about their local and remote settings and hosting account info on a phone support page).
However, our provider doesn't support extracting this data from their database. Therefore, thinking laterally, the only way (I can think of) to provide this info would be to check the http_referer (ip address?) and change that into a domain name (via DNS).
How would I do this?
The page is currently using ssi to display the user's own (local) IP address and Java to display which plugins they have installed (Flash, Acrobat, SVG, Shockwave etc...). I don't care which scripting language it is in as long as I can still provide the local IP address...
...any ideas would be much appreciated.
I am not sure how you have set-up the SSI's but you can get the local IP address by using the following (on an Apache system):
This code is within a SHTML file (obviously I have chopped out all the jibberish HTML mark-up).
I really am very much a newbie to scripting!
var ip = '<!--#echo var="REMOTE_ADDR"-->';
Oh, you need to give your page a .php extension and use the PHP code tags.
var ip = '<?php echo $_SERVER['REMOTE_ADDR']; ?>';
The $_SERVER collection holds details about the server and client machines.
Thank you so much for your help.
I have found an even easier way to obtain this info:
<? $HTTP_REFERER ?>
However, I need some more help.
The result of the action is too much info, as I get:
and all I want is www.domain-name.co.uk .
How would I strip / trim the un-necessary information out in PHP?
You will need to use the str_replace function to remove the 'http://' substring. You also have to split the string into array and take the first index.
That should print out www.domain-name.co.uk
$newUrl = str_replace("http://", "", $HTTP_REFERER);
$newUrl = split("/", $newUrl, 2);
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)