How to determine WAN IP with php/ssi/etc?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How to determine WAN IP with php/ssi/etc?

Postby Liath » 08. May 2003 15:28


I'm trying to use a java program for my webcam page, but there is one slight problem. I'm on DSL and my IP changes, and the java needs the exact IP! I've been tryign to use a program called IP-Update for the pages I need updated, but the program doesn't work half the time, and was really poorly written to start with--sometimes it modifies the source files instead of the destination files, and things like that.

Someone said to use
Code: Select all
Code: Select all
<!--#echo var="SERVER_ADDR" -->
, but that only returns my LAN IP :(

Does anyone know of either a program that can take source files and stuff my IP in them, or a way to get the server to include the WAN IP? Any hel pwould be greatly appreciated!


P.S. I can use a page like to get my external IP...that is actually what IP-Update uses as well.
Last edited by Liath on 08. May 2003 18:23, edited 1 time in total.
Posts: 12
Joined: 08. May 2003 15:18

Postby AlexPausB » 08. May 2003 16:44

Yes I wrote the things about $SERVER_ADRESS and so on... and now I've got the same problem and I am searching for any hints resolving this.

Any Idea?
Posts: 471
Joined: 05. February 2003 11:19
Location: Fdorf

Think I may have found a *lame* workaround!

Postby Liath » 09. May 2003 09:52

Okay, I don't know if this will work for everyone, but I've found a cheap way to get this to work. It uses PHP, and uses an address that the server doesn't know that still resolves to the server's IP. I use DynDNS, and my DNS is, but it uses wildcards too so * will work as well. The server knows it is but it doesn't know so this works :)

Code: Select all
$IPaddy = gethostbyname(""); // gets IP
$output = $IPaddy;
$myfile = "e:\\wampp2\\htdocs\\protected\\ip.txt";
if($file=fopen($myfile, "w"))
   fwrite($file, $output);

Code: Select all
<title>WebCam Popup</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--#include file="ip.php" -->
Page last updated <!--#flastmod file="ip.txt" -->
<body bgcolor="#000000" text="#00FF00" link="#0000FF" vlink="#FF00FF" alink="#00FFFF">
<p align="center"> <applet width="640" height="480" code="JavaCamPush.class" archive="JavaCamPush.jar" codebase="http://<!--#include file="ip.txt" -->:8888/applet/">
    <param name="cabbase" value="">
    <param name="URL" value="http://<!--#include file="ip.txt" -->:8888">

I'm pretty sure I could have just put the PHP into the page, but I wanted to be able to just use the trick in any page if I need to. Wish I coudl figure out a way to only call the php script if it is needed like when the IP changes.
Posts: 12
Joined: 08. May 2003 15:18

Good idea :)

Postby chanio » 23. May 2003 08:21

I don't know, but you could try using this as a heading for HTML.
<meta http-equiv="expires" content="Thu, 5 Mar 2003 00:00:01 GMT">
<meta http-equiv="refresh" content="3600">
This says that the page has allready expired so it has to renew its content.
It also fixes an amount of time to wait to do the refreshing:
1 hour.
It depends on the proxy content. Some stuf, I saw with Netscape browser, are declared that don't need to renew. So the browser skips it and leave the old value. But when you close-stop your server, it changes instantly.
Better try what happens.
Hope it helps.
Thank's for your code
Alberto :P
Gallactic Firewall
User avatar
Posts: 72
Joined: 18. March 2003 22:05
Location: Argentina

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 66 guests