<html>
<head>
<title>Dynamic FreeDNS IP Address Updater -Update Manually</title>
</head>
<body>
<h2>Dynamic FreeDNS IP Address Updater - Manual IP Address Update</h2>
<?php
/* Dynamic FreeDNS Copyright (c) 2007 Nathan Wynn from Vyoufinder Software Company */
/* This script is free but not free to distribute. Please download it from the original source */
/* and installation instructions via www.vyoufinder.com */
include "dbconnect.php";
$sql = mysql_query("SELECT `yn` FROM `router`")
or die(mysql_error());
$url = mysql_query("SELECT `getip` FROM `url`")
or die(mysql_error());
$userouter = mysql_fetch_array($sql);
$urlgetip = mysql_fetch_array($url);
if ($userouter[yn] =="1") {
echo "Dynamic FreeDNS is set to get the server's i.p. address from an external source. The URL where "getmyip.php" is located is set to: ".$urlgetip[getip]."<BR><BR>" ;
}
else {
echo "Dynamic FreeDNS is configured to use whatsmyip.com for determining the server's internet protocol address.";
}
$ipfrom=$userouter[yn];
$getmyip=$urlgetip[getip];
$done=0;
$rcnt=0;
while((!$done) && ($rcnt < 3)) {
echo("Detecting your current internet protocol address...<BR><BR> \n\n");
if (!$ipfrom) {
$remoteip=file_get_contents("http://www.whatismyip.com/automation/n09230945.asp");
}
else {
$remoteip=@file_get_contents($getmyip);
}
if ($remoteip != "") {
echo("Internet protocol address successfully obtained.<BR><BR> \n\n");
} else {
echo("Error retreiving internet protocol address.<BR><BR>\n\n");
include "footer.php";
}
echo("Detected current WAN internet protocol address is: <B>".$remoteip."</B><BR><BR>\n\n");
include "dbconnect.php";
$lastip = mysql_query("SELECT * FROM `lastip`")
or die(mysql_error());
$ip = mysql_fetch_array( $lastip );
echo "The most recent i.p. address used by this server was: <B> ".$ip['lastip'] . " </B><BR><BR>";
if (($ip['lastip'] != $remoteip && $remoteip != "")) {
echo "Internet protocol addresses do <I>not</I> match. Proceeding with update:<BR><BR>";
$queryprint = mysql_query("SELECT * FROM `update`")
or die(mysql_error());
while($codeprint = mysql_fetch_assoc( $queryprint ))
{
if ($codeprint['freedns1'] != "" ) { Print "<b>Executing update URL : </b> ".$codeprint['freedns1'] . " <br>"; }
if ($codeprint['freedns2'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns2'] . " <br>"; }
if ($codeprint['freedns3'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns3'] . " <br>"; }
if ($codeprint['freedns4'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns4'] . " <br>"; }
if ($codeprint['freedns5'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns5'] . " <br>"; }
if ($codeprint['freedns6'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns6'] . " <br>"; }
if ($codeprint['freedns7'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns7'] . " <br>"; }
if ($codeprint['freedns8'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns8'] . " <br>"; }
if ($codeprint['freedns9'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns9'] . " <br>"; }
if ($codeprint['freedns10'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns10'] . " <br>"; }
if ($codeprint['freedns11'] != "" ){ Print "<b>Executing update URL : </b> ".$codeprint['freedns11'] . " <br>"; }
if ($codeprint['freedns12'] != "" ){ Print "<b>Executing Update URL 12: </b> ".$codeprint['freedns12'] . " <br>"; }
}
echo "Update In Progress...<BR<BR>";
$query = mysql_query("SELECT * FROM `update`")
or die(mysql_error());
while($code = mysql_fetch_assoc( $query ))
{
if ($code['freedns1'] != "" ) { exec("wget \"".$code['freedns1'] ."\""); }
if ($code['freedns2'] != "" ) { exec("wget \"".$code['freedns2'] ."\""); }
if ($code['freedns3'] != "" ) { exec("wget \"".$code['freedns3'] ."\""); }
if ($code['freedns4'] != "" ) { exec("wget \"".$code['freedns4'] ."\""); }
if ($code['freedns5'] != "" ) { exec("wget \"".$code['freedns5'] ."\""); }
if ($code['freedns6'] != "" ) { exec("wget \"".$code['freedns6'] ."\""); }
if ($code['freedns7'] != "" ) { exec("wget \"".$code['freedns7'] ."\""); }
if ($code['freedns8'] != "" ) { exec("wget \"".$code['freedns8'] ."\""); }
if ($code['freedns9'] != "" ) { exec("wget \"".$code['freedns9'] ."\""); }
if ($code['freedns10'] != "" ) { exec("wget \"".$code['freedns10'] ."\""); }
if ($code['freedns11'] != "" ) { exec("wget \"".$code['freedns11'] ."\""); }
if ($code['freedns12'] != "" ) { exec("wget \"".$code['freedns12'] ."\""); }
}
$sql = "UPDATE lastip SET lastip='$remoteip' WHERE 'lastip'!='$remoteip' && 'lastip'!=''";
if (!mysql_query($sql,$con2))
{
die('Error: ' . mysql_error());
}
include "closedb.php";
}
if ($ip['lastip'] == $remoteip && $remoteip != "") {
echo "<I>No update necessary.</I> <BR><BR>\n\n";
}
if ($remoteip == "") {
echo("Not detectable. \n\n Trying Again in 18 Seconds. Standby. | Attempt ".($rcnt+1)."/3 \n\n");
sleep(18);
}
else {
echo("<B>Finished!</B>");
$done=1;
}
$rcnt++;
}
if (!$done) echo("Failed to retrieve i.p. address. Check Your configuration settings. \n\n");
include "footer.php";
?>