PDA

Click to See Complete Forum and Search --> : IP Address's


Beacon
Jul 12th, 2001, 09:34 PM
Hi new to all this web programming stuff but i wonder if someone could give me some code for getting the ip address of all who view my web page?

thanks
B

sail3005
Jul 12th, 2001, 11:15 PM
what language?

Beacon
Jul 12th, 2001, 11:46 PM
Javascript, vbscript or html hell i dont really care!
;) :p

sail3005
Jul 13th, 2001, 09:54 AM
how about ASP?

It's really easy that way...(i suppose something simular would work for vbs)

<% = Request.ServerVariables("REMOTE_HOST") %>

JoshT
Jul 13th, 2001, 11:01 AM
Yeah, all server-side CGI languages can get the ip address pretty easy with the REMOTE_HOST or REMOTE_ADDR cgi variables. REMOTE_ADDR will be the ip address, on some servers, REMOTE_HOST will name resolve the ip address.

scoutt
Jul 13th, 2001, 11:09 AM
Perl = $ENV{'REMOTE_ADDR'}

PHP = $remote_ip=getenv("REMOTE_ADDR");

just in case you don't want ASP or VBS

sail3005
Jul 13th, 2001, 06:23 PM
i wonder if there is any way to do it in javascript?

Wynd
Jul 13th, 2001, 06:29 PM
There's this, I didn't test it.


browserName = navigator.appName
browserVer = parseInt(navigator.appVersion)
ipAdd = ""

if (browserName == "Netscape" && navigator.javaEnabled()) {
if (browserVer >= 4) {
ipAdd = java.net.InetAddress.getLocalHost().getHostName()
}
else {
ipAdd = java.net.InetAddress.getLocalHostName()
}
}
if (ipAdd != "") {
document.writeln("<H1>Your IP address is: " + ipAdd + ".</H1>")
if (ipAdd.substring(0,7) == "17.254.") {
document.write("<H2>Welcome, visitor from Apple!</H2>")
}
}

sail3005
Jul 13th, 2001, 11:24 PM
thanks, i'll check it out

JoshT
Jul 16th, 2001, 07:08 AM
Let me know if that code works. Getting an ip address through client-side javascript is a security hole that would need to be closed.