/**
* ipupdate.php
*
* @author marvin@marvinmarcelo.com
*
* Update script zoneedit.com
*/
$lookupserv = array(
"http://www.whatismyip.com/tools/ip-address-lookup.asp",
"http://www.hostip.info/",
"http://www.tracemyip.org/index.php",
"http://www.kloth.net/services/dig.php",
"http://www.ip2location.com/"
);
// file where html source from wget
$tmpfile = "/home/youraccountpath/.updatezone/html";
// IP lookup site
$iplookupurl = $lookupserv[rand(0, 4)];
// file to hold current IP
$ipfile = "/home/youraccountpath/.updatezone/ip";
// logging
$logfile = "/home/youraccountpath/.updatezone/log";
$log = fopen($logfile, "a");
fwrite($log, "[" . date("Y-m-d H:i:s") . "] " . __FILE__ . " started \n");
exec("/usr/bin/wget -O - $iplookupurl > $tmpfile");
fwrite($log, "[" . date("Y-m-d H:i:s") . "] wget $iplookupurl \n");
$html = join("", file($tmpfile));
if(preg_match('/\b(?:\d{1,3}\.){3}\d{1,3}\b/', $html, $matches))
{
$ip = $matches[0];
fwrite($log, "[" . date("Y-m-d H:i:s") . "] QUERY $ip\n");
if(!file_exists($ipfile))
{
file_put_contents($ipfile, "[nothing]");
}
$oldip = trim(join("", file($ipfile)));
if($ip != $oldip)
{
$fp = fopen($ipfile, "w");
fwrite($fp, $ip);
fclose($fp);
$u = base64_decode("hashedusername"); /* username */
$p = base64_decode("hashedpassword"); /* password */
exec("/usr/bin/lynx -source -auth=$u:$p 'http://dynamic.zoneedit.com/auth/dynamic.html?host=mydomain.com'");
fwrite($log, "[" . date("Y-m-d H:i:s") . "] UPDATED from $oldip to $ip\n");
}
fclose($log);
}
ZoneEdit is free. I think, that’s 5 zones for free account.
You might also need to install lynx and php5-cli, just type this in the shell, if you’re privileged to do so.
sudo apt-get install lynx php-cli
