<?php
/*
Note: This file requires the dns_addresses.php and sync_dns.php files to work.
Purpose:
The purpose of this script is to sync dns from one server to another when using Mircosoft Server (2003/2008). The dns_addresses.php script provides the encoded information for sync_dns.php to issue out commands with.
Setup:
sync_dns.php is best left in a place outside the web root while dns_addresses.php should be in the web root somewhere.
sync_dns.php should be setup with a scheduled task/crontab to automatically run on a set time (you setup that).
*/
// The folder of where the dns records are stored in plain text.
$file_location = 'C:\windows\system32\dns';
/***************** DO NOTE EDIT BELOW ***************/
// Get the files
$files = scandir($file_location);
// Get the cache file
$cache = file_get_contents($file_location . '\\.cache.web';
$cache = unserialize(base64_decode($cache);
if (!is_array($cache) || (isset($_GET['all']))
$cache = array();
// Remove some naughty files.
foreach($files as $key => $file)
if (in_array($file, array('.', '..')) || in_array($file, $cache))
unset($files[$key]);
// clean up the indexes again
sort($files);
// Get our new cache going.
$cache = array_merge($files, $cache);
// Now send it on its way.
echo base64_encode(serialize($files));
// Update our cache
file_put_contents($file_location . '\\.cache.web', base64_encode(serialize($cache)));
// Gutten Tag.
exit;
?>
<?php
/*
Note: This file requires the dns_addresses.php and sync_dns.php files to work.
Purpose:
The purpose of this script is to sync dns from one server to another when using Mircosoft Server (2003/2008). The dns_addresses.php script provides the encoded information for sync_dns.php to issue out commands with.
Setup:
sync_dns.php is best left in a place outside the web root while dns_addresses.php should be in the web root somewhere.
sync_dns.php should be setup with a scheduled task/crontab to automatically run on a set time (you setup that).
*/
// The folder of where the dns records are stored in plain text.
$file_location = 'C:\\windows\\system32\\dns';
/***************** DO NOTE EDIT BELOW ***************/
// Get the files
$files = scandir($file_location);
// Get the cache file
$cache = file_get_contents($file_location . '\\.cache.web';
$cache = unserialize(base64_decode($cache);
if (!is_array($cache) || (isset($_GET['all']))
$cache = array();
// Remove some naughty files.
foreach($files as $key => $file)
if (in_array($file, array('.', '..')) || in_array($file, $cache))
unset($files[$key]);
// clean up the indexes again
sort($files);
// Get our new cache going.
$cache = array_merge($files, $cache);
// Now send it on its way.
echo base64_encode(serialize($files));
// Update our cache
file_put_contents($file_location . '\\.cache.web', base64_encode(serialize($cache)));
// Gutten Tag.
exit;
?>
<?php
/*
Note: This file requires the dns_addresses.php and sync_dns.php files to work.
Purpose:
The purpose of this script is to sync dns from one server to another when using Mircosoft Server (2003/2008). The dns_addresses.php script provides the encoded information for sync_dns.php to issue out commands with.
Setup:
sync_dns.php is best left in a place outside the web root while dns_addresses.php should be in the web root somewhere.
sync_dns.php should be setup with a scheduled task/crontab to automatically run on a set time (you setup that).
*/
// The address of the server. This can be a private address.
$server_address = '192.168.0.1';
// The real ip of the server. This MUST be a world reachable address in order for dns to function.
$real_server_address = '134.39.158.130';
// The port (usually 80).
$server_port = 80;
// What file to get.
$desination_file = 'dns_addresses.php';
/***************** DO NOTE EDIT BELOW ***************/
// Try to find the remote server
$server = fsocketopen($server_address, $server_port);
// No server, Oh my.
if (!$server)
exit('Unable to contact remote server');
// Send needed request headers.
$headers = "GET /" . $desination_file . " HTTP/1.1\r\n"
. "Host: www.dns1.dns.cts\r\n"
. "Connection: Close\r\n\r\n";
frwite($server, $headers);
// Get a response!
$data = '';
while (!feof($server))
$data .= fgets($fp, 128);
fclose($server);
// Attempt to validate our data.
$date = unserialize(base64_decode($data));
// Your ugly!
if (!is_array($data))
exit('Unexpected data returned');
// Now for the fun.
foreach ($data as $file)
{
// strip .dns off it
if (substr(-4) != '.dns'))
continue;
else
$file = substr(0, -4);
// send out my command.
shell_exec('dnscmd /ZoneAdd ' . $file . ' /Stub ' . $real_server_address);
}
// Gutten Tag.
exit;
?>