| Explanation of variables that need to be defined:
- NAMED_CONF_PATH - This should be set to the full path of your
named.conf file. Note that if you are writing a web application, your
webserver must have read and write access to named.conf file. If this
doesn't send thoughts of big security holes through your mind, then
you should probably not be using this class. You may want to read the
security information.
- NAMED_CONF_MASTER_ADD_FILE - Personally, I separate the BIND server
configuration from the zone definitions. This is the file to which the
class will add new zones.
- NAMED_CONF_SLAVE_ADD_FILE - This is not used yet.
- NAMED_CONF_PATH_PARSED - This file contains a very primitive cache
of the zones hosted on your name server. If the class detects that
your named.conf has been updated by hand, it will automatically regenerate
this file.
- NAMED_DIR - This is the base directory of your BIND installation. This
should be set to the same value as the "directory" option in the named.conf
file.
- LOCK_DIR - This should be set to the directory that the class can use
to lock zone files when it writes them.
- DEFAULT_PRIMARY_NAMESERVER - The primary nameserver to configure by
default for new zones.
- DEFAULT_SECONDARY_NAMESERVER - The secondary nameserver to configure by
default for new zones.
- DEFAULT_CONTACT_EMAIL - The contact email address for the SOA record to configure by
default for new zones.
- DEFAULT_PRIMARY_MX - The primary mail exchanger to configure by
default for new zones.
- DEFAULT_SECONDARY_MX - The secondary mail exchanger to configure by
default for new zones.
Using the class:
To create an instance of the zone class simply do the following:
$zone = new ZONE("mydomain.com");
This will load the zone into the class automatically. After the zone is loaded, you
can use the resetRR() and getRR() functions to loop through the resource
records. RR records are stored as an array of objects that belong to the zone class.
The getRR() function will return an RR object containing the information for that
resource record. The RR object is defined as such:
class RR {
var $id;
var $lhs;
var $ttl;
var $type;
var $rhs;
}
The RR object contains a sub-object named $rhs. This object contains the data that
is stored on the right hand side of the resource record. The $type variable tells you
what type of resource record (ie. MX, A, NS, etc.) is stored in the object. The $rhs
variable stores an object of $type (ie, there is a class named SOA, NS, MX, etc.).
... so ...
$zone = new ZONE("mydomain.com");
$zone->resetRR();
while ($rr = getRR())
{
if ($rr->type == "MX")
{
echo $rr->lhs;
echo "$preference: $hostname";
}
}
... would output a list of all the mail exchangers defined in the zone. It is important
to notice that that the data stored in the $type variable defines how your application
should handle the object in the $rhs variable.
Sufficiently confused? I don't blame you. I'll be releasing better documentation
as soon as possible.
|