News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1232735742:v:use_geshi-1:v:type-php

Started by SleePy, Jan 23, 2009, 06:35 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

SleePy

<?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;
?>

SleePy

<?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;
?>