-
December 27th, 2003, 02:57 PM
#1
Member
how to find external IP add.
Friends,
I am writting a program to find the external IP address of the client computer, I want to know what code the guy at showmyip.com uses to display the IP of the computer making the request which I am interested in using in my site+program.
Thanks,
AceSpy
-
December 27th, 2003, 04:49 PM
#2
first glance at the webpage i thought itd be a javascript, but when i looked at page's source code, i couldn't find the line, so i went to the next place and found a javascript that would show the viewer's ip address:
Code:
<!-- ONE STEP TO INSTALL IP ADDRESS:
1. Copy the coding into the HEAD of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
// http://www.kdcgrohl.com
// Depending on your server set-up,
// you may need to use the ".shtml"
// extension [instead of the "html"
// or "htm"] as the script uses Server
// Side Includes. To display in the
// title bar, exclude the
//"<title></title>" code from the page.
// This part gets the IP
var ip = '<!--#echo var="REMOTE_ADDR"-->';
// This part is for an alert box
alert("Your IP address is "+ip);
// This part is for the status bar
window.defaultStatus = "Your IP address is "+ip;
// This part is for the title bar
document.write("<title>Your IP address is "+ip+"</title>");
// End -->
</script>
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.09 KB -->
from: http://javascript.internet.com/user-...p-address.html
-
December 29th, 2003, 11:57 PM
#3
Junior Member
They did use javascript at showmyip.com, but there is an easier way but requires more.
PHP is an easy language for things like this because its a lot less code and does so much more, but it does require php installed on the server.
Example page:
<html>
<body>
<?php
echo "<p>Your ip is $REMOTE_HOST</p>"
?>
</body>
</html>
And the browser output would be:
Your ip is 127.0.0.1 (this would actually be your real ip)
Hope that helps, PHP is very useful
PHP links:
PHP Homepage
A nice site to learn from
- DeathIncarnate
cout<<\"Cmon, its not that hard...\\n\\nDeathIncarnate\\n\\n\";
system(\"PAUSE\");
return 0;
}
-
December 30th, 2003, 12:00 AM
#4
That PHP code won't work on newer versions of PHP, because register_globals is off by default (and rightly so). You'd need to replace $REMOTE_HOST with $_SERVER['REMOTE_HOST'] in order for it to work.
-
December 30th, 2003, 05:04 AM
#5
Member
Is there any way to do it in CGI/Perl?
AceSpy
www.acespy.com
-
December 30th, 2003, 08:06 AM
#6
this should help http://www.raingod.com/raingod/resou.../UserInfo.html
you should try searching google for "getting ip with cgi". That's how I got that page. Good luck.
-
January 8th, 2004, 02:52 PM
#7
Junior Member
#!/usr/bin/perl
use CGI qw(:standard);
print "Content-type:text/html\n\n";
print "Your IP address is: ".$ENV{REMOTE_ADDR};
#I love you Perl...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|