Ruby -vs- PHP Showcase: nsupdate script

These are the source code files for the Ruby -vs- PHP Showcase: nsupdate script Read the full story in my blog.

Source codes

Config files

<?php
# $Id: nsupdate-defs.php.sample,v 1.1 2005/12/26 18:07:41 chip Exp $
# $Source: /home/chip/src/web-nsupdate/RCS/nsupdate-defs.php.sample,v $

#
# Default pathname to the TSIG key generated by dnssec-keygen(8).
#
# *** You MUST adjust DEFAULT_NSKEY and point it to the key you generated
# *** when installing web-nsupdate.
#
define("DEFAULT_NSKEY", "/usr/local/lib/web-nsupdate/Kweb-nsupdate.+157+61241.key");

#
# Default nameserver to which the update will be sent.
#
define("DEFAULT_NAMESERVER", "localhost");

#
# Default TTL value (seconds) to use for the host record.
#
define("DEFAULT_TTL", 3600);

#
# Convenience function for creating simple $Hosts_Table[] entries.
#
function _HOSTKEY($value) { return array("key" => $value); }

#
# Lookup table of passwords associated with hosts to update.
# The available parameters are:
#   * key - Password the host uses to authenticate the update (REQUIRED).
#   * nskey - Path to the TSIG key for this host (default $DEFAULT_NSKEY).
#   * nameserver - Host to which update is sent (default $DEFAULT_NAMESERVER).
#   * ttl - Default TTL value to use for this host. (default $DEFAULT_TTL).
# The _HOSTKEY() function may be used for the common case of assigning
# a key and defaulting all the other values.
#
$Hosts_Table = array(

	# *** You MUST add entries for your DDNS clients here, one entry
	# *** per client.  I recommend adding a test entry (say
	# *** "test.example.com") that does not correspond to a real host.

	# simple example, three hosts, each assigned a password
	"host1.example.com" => _HOSTKEY("fowCofyud"),
	"host2.example.com" => _HOSTKEY("Jinsevish7"),
	"host3.example.com" => _HOSTKEY("AvFafEmray"),

	# complicated example, with everything set
	"host4.example.com" => array(
		"key" => "edyokJevFi",
		"nskey" => "/etc/bind/Khost4.example.com.+157+25458.key",
		"nameserver" => "ns.example.net",
		"ttl" => "300",
	),

);

?>