(So users can update multiple hosts, and a host can be updated by multiple users).
-The location of these files must be specified in "config.php". For security reasons, don't place
-them in your Document root, otherwise every Web user can read them.
+### Installation via Composer
+
+ # Install Composer
+ curl -sS https://getcomposer.org/installer | php
+
+ # Add Dyndns as a dependency
+ php composer.phar require nicokaiser/dyndns:*
+
+Then you can create a simple `index.php` with the configuration:
+
+```php
+<?php
+
+require 'vendor/autoload.php';
+
+$dyndns = new Dyndns\Server();
+
+// Configuration
+$dyndns
+ ->setConfig('hostsFile', __DIR__ . '/../conf/dyndns.hosts') // hosts database
+ ->setConfig('userFile', __DIR__ . '/../conf/dyndns.user') // user database
+ ->setConfig('debug', true) // enable debugging
+ ->setConfig('debugFile', '/tmp/dyndns.log') // debug file
+ ->setConfig('bind.keyfile', __DIR__ . '/../conf/dyn.example.com.key') // secret key for BIND nsupdate ("<keyname>:<secret>")
+ ->setConfig('bind.server', 'localhost') // address of the BIND server
+ ->setConfig('bind.zone', 'dyndns.example.com') // BIND zone for the updates
+ ->setConfig('bind.ttl', '300') // TTL for DNS entries
+;
+
+$dyndns->init();
+```
### Usage
--- /dev/null
+{
+ "name": "nicokaiser/dyndns",
+ "description": "A simple dynamic DNS that updates an existing BIND",
+ "keywords": ["dns", "dyndns"],
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Nico Kaiser",
+ "email": "nico@kaiser.me",
+ "homepage": "http://kaiser.me"
+ }
+ ],
+ "autoload": {
+ "psr-0": {
+ "Dyndns": "src/",
+ }
+ }
+}
--- /dev/null
+<?php
+
+require 'vendor/autoload.php';
+
+$dyndns = new Dyndns\Server();
+
+// Configuration
+$dyndns
+ ->setConfig('hostsFile', __DIR__ . '/../conf/dyndns.hosts') // hosts database
+ ->setConfig('userFile', __DIR__ . '/../conf/dyndns.user') // user database
+ ->setConfig('debug', true) // enable debugging
+ ->setConfig('debugFile', '/tmp/dyndns.log') // debug file
+ ->setConfig('bind.keyfile', __DIR__ . '/../conf/dyn.example.com.key') // secret key for BIND nsupdate ("<keyname>:<secret>")
+ ->setConfig('bind.server', 'localhost') // address of the BIND server
+ ->setConfig('bind.zone', 'dyndns.example.com') // BIND zone for the updates
+ ->setConfig('bind.ttl', '300') // TTL for DNS entries
+;
+
+$dyndns->init();
/**
* Helper functions.
- *
- * @package Dyndns
- * @author Nico Kaiser <nico@kaiser.me>
*/
class Helper
{
/**
* Host database.
- *
- * @package Dyndns
- * @author Nico Kaiser <nico@kaiser.me>
*/
class Hosts
{
/**
* Simple Dynamic DNS server.
- *
- * @package Dyndns
- * @author Nico Kaiser <nico@kaiser.me>
*/
class Server
{
// Return "good" code as everything seems to be ok now
$this->returnCode('good');
+
+ return $this;
}
public function setConfig($key, $value)
{
$this->config[$key] = $value;
+ return $this;
}
public function getConfig($key)
/**
* User database.
- *
- * @package Dyndns
- * @author Nico Kaiser <nico@kaiser.me>
*/
class Users
{
+++ /dev/null
-<?php
-
-@ini_set('display_errors', 0);
-
-if (!isset($dyndns) || !method_exists($dyndns, 'setConfig')) {
- exit;
-}
-
-/*
- * Location of the hosts database
- */
-$dyndns->setConfig('hostsFile', __DIR__ . '/../conf/dyndns.hosts');
-
-/*
- * Location of the user database
- */
-$dyndns->setConfig('userFile', __DIR__ . '/../conf/dyndns.user');
-
-/*
- * Enable debugging?
- */
-$dyndns->setConfig('debug', true);
-
-/*
- * Debug filename
- */
-$dyndns->setConfig('debugFile', '/tmp/dyndns.log');
-
-/*
- * Secret Key for BIND nsupdate
- * <keyname>:<secret>
- */
-$dyndns->setConfig('bind.keyfile', __DIR__ . '/../conf/dyn.example.com.key');
-
-/*
- * Address of the BIND server. You can specify any remote DNS server here,
- * if the server allows you to update data using bind.key
- */
-$dyndns->setConfig('bind.server', 'localhost');
-
-/*
- * The BIND zone which retrieves the updates
- */
-$dyndns->setConfig('bind.zone', 'dyndns.example.com');
-
-/*
- * Dynamic DNS entries will get this TTL
- */
-$dyndns->setConfig('bind.ttl', '300');
+++ /dev/null
-<?php
-
-/**
- * This script takes the same parameters as the original members.dyndns.org
- * server does. It can update a BIND DNS server.
- *
- * The syntax is described here:
- * http://www.dyndns.com/developers/specs/syntax.html
- *
- * Remember: This script must be run as
- * http://members.dyndns.org/nic/update
- *
- * @author Nico Kaiser <nico@kaiser.me>
- */
-
-error_reporting(E_ALL);
-
-require_once __DIR__ . '/lib/Dyndns/Helper.php';
-require_once __DIR__ . '/lib/Dyndns/Hosts.php';
-require_once __DIR__ . '/lib/Dyndns/Users.php';
-require_once __DIR__ . '/lib/Dyndns/Server.php';
-
-$GLOBALS['dyndns'] = new Dyndns\Server();
-$dyndns = $GLOBALS['dyndns'];
-
-require __DIR__ . '/config.php';
-
-$dyndns->init();