From: Nico Kaiser Date: Tue, 18 Jun 2013 13:49:05 +0000 (+0200) Subject: PHP 5.3 X-Git-Tag: v1.0.0~13 X-Git-Url: http://git.neszt.hu/?a=commitdiff_plain;h=ca6eb2957b80c797fd9bf6aba892fe08d3c41fd6;p=Dyndns%2F.git PHP 5.3 --- diff --git a/TODO.txt b/TODO.txt deleted file mode 100644 index 21ebd29..0000000 --- a/TODO.txt +++ /dev/null @@ -1,8 +0,0 @@ -TODO -==== - -- Implement Wildcards -- Implement NOCHG -- Implement more features from DynDNS.org -- Provide Apache templates (for mod_rewrite, etc.) - diff --git a/htdocs/classes/DyndnsHelper.class.php b/htdocs/Dyndns/Helper.php similarity index 98% rename from htdocs/classes/DyndnsHelper.class.php rename to htdocs/Dyndns/Helper.php index fa87048..89df79e 100644 --- a/htdocs/classes/DyndnsHelper.class.php +++ b/htdocs/Dyndns/Helper.php @@ -1,12 +1,14 @@ */ -class DyndnsHelper +class Helper { /** * Check valid IP address diff --git a/htdocs/classes/DyndnsHosts.class.php b/htdocs/Dyndns/Hosts.php similarity index 94% rename from htdocs/classes/DyndnsHosts.class.php rename to htdocs/Dyndns/Hosts.php index cca9282..211aba7 100644 --- a/htdocs/classes/DyndnsHosts.class.php +++ b/htdocs/Dyndns/Hosts.php @@ -1,12 +1,14 @@ */ -class DyndnsHosts +class Hosts { /** * Filename of the hosts file (dyndns.hosts) @@ -74,7 +76,7 @@ class DyndnsHosts return false; } - if (! DyndnsHelper::checkValidHost($hostname)) { + if (! Helper::checkValidHost($hostname)) { $this->debug('Invalid host: ' . $hostname); return false; } @@ -86,7 +88,7 @@ class DyndnsHosts 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; } @@ -145,11 +147,11 @@ class DyndnsHosts $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; } diff --git a/htdocs/classes/Dyndns.class.php b/htdocs/Dyndns/Server.php similarity index 88% rename from htdocs/classes/Dyndns.class.php rename to htdocs/Dyndns/Server.php index 81e97ab..460aea6 100644 --- a/htdocs/classes/Dyndns.class.php +++ b/htdocs/Dyndns/Server.php @@ -1,8 +1,6 @@ */ -class Dyndns +class Server { /** * Storage for all configuration variables, set in config.php @@ -59,16 +57,16 @@ class Dyndns 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'); @@ -133,7 +131,7 @@ class Dyndns { foreach ($this->hostnames as $hostname) { // check if the hostname is valid FQDN - if (! DyndnsHelper::checkValidHost($hostname)) { + if (! Helper::checkValidHost($hostname)) { $this->returnCode('notfqdn'); } @@ -183,6 +181,6 @@ class Dyndns 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"; } } diff --git a/htdocs/classes/DyndnsUsers.class.php b/htdocs/Dyndns/Users.php similarity index 97% rename from htdocs/classes/DyndnsUsers.class.php rename to htdocs/Dyndns/Users.php index 49b4321..bd0946c 100644 --- a/htdocs/classes/DyndnsUsers.class.php +++ b/htdocs/Dyndns/Users.php @@ -1,12 +1,14 @@ */ -class DyndnsUsers +class Users { private $userFile; diff --git a/htdocs/index.php b/htdocs/index.php index 23691ad..49a5ff8 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -14,11 +14,15 @@ */ 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();