+++ /dev/null
-TODO
-====
-
-- Implement Wildcards
-- Implement NOCHG
-- Implement more features from DynDNS.org
-- Provide Apache templates (for mod_rewrite, etc.)
-
<?php
+namespace Dyndns;
+
/**
* Helper functions.
*
* @package Dyndns
* @author Nico Kaiser <nico@kaiser.me>
*/
-class DyndnsHelper
+class Helper
{
/**
* Check valid IP address
<?php
+namespace Dyndns;
+
/**
* Host database.
*
* @package Dyndns
* @author Nico Kaiser <nico@kaiser.me>
*/
-class DyndnsHosts
+class Hosts
{
/**
* Filename of the hosts file (dyndns.hosts)
return false;
}
- if (! DyndnsHelper::checkValidHost($hostname)) {
+ if (! Helper::checkValidHost($hostname)) {
$this->debug('Invalid host: ' . $hostname);
return false;
}
if (is_array($this->hosts)) {
foreach ($this->hosts as $line) {
if (preg_match("/^(.*?):(.*)/", $line, $matches)) {
- if (DyndnsHelper::compareHosts($matches[1], $hostname, '*') &&
+ if (Helper::compareHosts($matches[1], $hostname, '*') &&
in_array($user, explode(',', strtolower($matches[2])))) {
return true;
}
$key = $this->getConfig('bind.key');
// sanitiy checks
- if (! DyndnsHelper::checkValidHost($server)) {
+ if (! Helper::checkValidHost($server)) {
$this->debug('ERROR: Invalid bind.server config value');
return false;
}
- if (! DyndnsHelper::checkValidHost($zone)) {
+ if (! Helper::checkValidHost($zone)) {
$this->debug('ERROR: Invalid bind.zone config value');
return false;
}
<?php
-
-require_once(dirname(__FILE__) . '/DyndnsHelper.class.php');
-require_once(dirname(__FILE__) . '/DyndnsHosts.class.php');
-require_once(dirname(__FILE__) . '/DyndnsUsers.class.php');
+
+namespace Dyndns;
/**
* Simple Dynamic DNS server.
* @package Dyndns
* @author Nico Kaiser <nico@kaiser.me>
*/
-class Dyndns
+class Server
{
/**
* Storage for all configuration variables, set in config.php
public function init()
{
- $this->users = new DyndnsUsers($this->config['userFile']);
- $this->hosts = new DyndnsHosts($this->config['hostsFile']);
+ $this->users = new Users($this->config['userFile']);
+ $this->hosts = new Hosts($this->config['hostsFile']);
$this->checkHttpMethod();
$this->checkAuthentication();
// Get IP address, fallback to REMOTE_ADDR
- $this->myIp = DyndnsHelper::getMyIp();
+ $this->myIp = Helper::getMyIp();
if (array_key_exists('myip', $_REQUEST)) {
- if (DyndnsHelper::checkValidIp($_REQUEST['myip'])) {
+ if (Helper::checkValidIp($_REQUEST['myip'])) {
$this->myIp = $_REQUEST['myip'];
} else {
$this->debug('Invalid parameter myip. Using default REMOTE_ADDR');
{
foreach ($this->hostnames as $hostname) {
// check if the hostname is valid FQDN
- if (! DyndnsHelper::checkValidHost($hostname)) {
+ if (! Helper::checkValidHost($hostname)) {
$this->returnCode('notfqdn');
}
private function debug($message)
{
- $this->debugBuffer .= date('M j G:i:s') . ' Dyndns: ' . $message . "\n";
+ $this->debugBuffer .= @date('M j G:i:s') . ' Dyndns: ' . $message . "\n";
}
}
<?php
+namespace Dyndns;
+
/**
* User database.
*
* @package Dyndns
* @author Nico Kaiser <nico@kaiser.me>
*/
-class DyndnsUsers
+class Users
{
private $userFile;
*/
error_reporting(E_ALL);
-require_once(dirname(__FILE__) . '/classes/Dyndns.class.php');
-$GLOBALS['dyndns'] =& new Dyndns();
-$dyndns =& $GLOBALS['dyndns'];
+require_once __DIR__ . '/Dyndns/Helper.php';
+require_once __DIR__ . '/Dyndns/Hosts.php';
+require_once __DIR__ . '/Dyndns/Users.php';
+require_once __DIR__ . '/Dyndns/Server.php';
-@include(dirname(__FILE__). '/config.php');
+$GLOBALS['dyndns'] = new Dyndns\Server();
+$dyndns = $GLOBALS['dyndns'];
+
+require __DIR__ . '/config.php';
$dyndns->init();