From: Roland Haeder Date: Thu, 3 Sep 2015 19:56:03 +0000 (+0200) Subject: Merge branch 'latest-core/crawler' X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eae1435d1703cfe6049509c13e4bdd6800f9179b;hp=280fca59f8ed35ddde36a794c7a9f4991911e46a;p=hub.git Merge branch 'latest-core/crawler' --- diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index a44051c98..ad4d8626a 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -194,6 +194,15 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica $requestInstance->setRequestElement('command', $commandName); } // END - if + // Is the responseType 'html' ? + if ($responseType == 'html') { + // The language system is needed for this + $languageInstance = ObjectFactory::createObjectByConfiguredName('language_system_class'); + + // And set it here + $this->setLanguageInstance($languageInstance); + } // END - if + // Get a controller resolver $resolverClass = self::convertToClassName($this->getAppShortName() . '_' . $responseType . '_controller_resolver'); $resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this)); @@ -204,12 +213,15 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // Launch the hub main routine here $this->getControllerInstance()->handleRequest($requestInstance, $responseInstance); - // -------------------------- Shutdown phase -------------------------- - // Shutting down the hub by saying "good bye" to all connected peers - // and other hubs, flushing all queues and caches. - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown in progress, main loop exited.'); - $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); + // Only for console requests as this is the actual daemon + if ($responseType == 'console') { + // -------------------------- Shutdown phase -------------------------- + // Shutting down the hub by saying "good bye" to all connected peers + // and other hubs, flushing all queues and caches. + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown in progress, main loop exited.'); + $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); + } // END - if } /** diff --git a/application/hub/classes/.htaccess b/application/hub/classes/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/apt-proxy/.htaccess b/application/hub/classes/apt-proxy/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/apt-proxy/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/apt-proxy/class_ b/application/hub/classes/apt-proxy/class_ new file mode 100644 index 000000000..2ec43314b --- /dev/null +++ b/application/hub/classes/apt-proxy/class_ @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???AptProxy extends BaseNodeAptProxy implements AptProxyter { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $proxyInstance An instance of a AptProxyter class + */ + public final static function createNode???AptProxy () { + // Get new instance + $proxyInstance = new Node???AptProxy(); + + // Return the prepared instance + return $proxyInstance; + } + + /** + * Method to "bootstrap" the apt-proxy. This step does also apply provided + * command-line arguments stored in the request instance. You should now + * get it from calling $this->getRequestInstance(). + * + * @return void + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + $this->partialStub('Please implement this method.'); + } + + /** + * Add some apt-proxy-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/apt-proxy/class_BaseNodeAptProxy.php b/application/hub/classes/apt-proxy/class_BaseNodeAptProxy.php new file mode 100644 index 000000000..c372b2e26 --- /dev/null +++ b/application/hub/classes/apt-proxy/class_BaseNodeAptProxy.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeAptProxy extends BaseHubSystem { + /** + * Whether this apt-proxy is active + */ + private $isActive = FALSE; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Enables/disables the apt-proxy (just sets a flag) + * + * @param $version Version number of this apt-proxy + * @return void + */ + public final function enableIsActive ($isActive = TRUE) { + $this->isActive = (bool) $isActive; + } + + /** + * Determines whether the apt-proxy is active + * + * @return $isActive Whether the apt-proxy is active + */ + public final function isActive () { + return $this->isActive; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/apt-proxy/console/.htaccess b/application/hub/classes/apt-proxy/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/apt-proxy/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/apt-proxy/console/class_NodeConsoleAptProxy.php b/application/hub/classes/apt-proxy/console/class_NodeConsoleAptProxy.php new file mode 100644 index 000000000..06c91a534 --- /dev/null +++ b/application/hub/classes/apt-proxy/console/class_NodeConsoleAptProxy.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeConsoleAptProxy extends BaseNodeAptProxy implements AptProxy, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $proxyInstance An instance of a AptProxy class + */ + public final static function createNodeConsoleAptProxy () { + // Get new instance + $proxyInstance = new NodeConsoleAptProxy(); + + // Return the prepared instance + return $proxyInstance; + } + + /** + * Method to "bootstrap" the apt-proxy. This step does also apply provided + * command-line arguments stored in the request instance. You should now + * get it from calling $this->getRequestInstance(). + * + * @return void + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + // Get the app instance (for shortening our code) + $app = $this->getApplicationInstance(); + + // Output all lines + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - An apt-proxy connection helper'); + self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2012 Apt-Proxy Developer Team'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); + self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); + self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + } + + /** + * Add some apt-proxy-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/blocks/.htaccess b/application/hub/classes/blocks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/blocks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/blocks/class_ b/application/hub/classes/blocks/class_ new file mode 100644 index 000000000..0053d45cc --- /dev/null +++ b/application/hub/classes/blocks/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Block extends BaseBlock implements === { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $blockInstance An instance of a === class + */ + public final static function create???Block () { + // Get new instance + $blockInstance = new ???Block(); + + // Return the prepared instance + return $blockInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/blocks/class_BaseBlock.php b/application/hub/classes/blocks/class_BaseBlock.php new file mode 100644 index 000000000..9425bf744 --- /dev/null +++ b/application/hub/classes/blocks/class_BaseBlock.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseBlock extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/blocks/miner/.htaccess b/application/hub/classes/blocks/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/blocks/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/blocks/miner/class_HashBlock.php b/application/hub/classes/blocks/miner/class_HashBlock.php new file mode 100644 index 000000000..ef8e3f979 --- /dev/null +++ b/application/hub/classes/blocks/miner/class_HashBlock.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HashBlock extends BaseBlock implements Minable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $blockInstance An instance of a Minable class + */ + public final static function createHashBlock () { + // Get new instance + $blockInstance = new HashBlock(); + + // Return the prepared instance + return $blockInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/chains/.htaccess b/application/hub/classes/chains/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/chains/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/chains/class_PackageFilterChain.php b/application/hub/classes/chains/class_PackageFilterChain.php new file mode 100644 index 000000000..c79b62ef9 --- /dev/null +++ b/application/hub/classes/chains/class_PackageFilterChain.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageFilterChain extends FilterChain { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $chainInstance An instance of this class + */ + public static final function createPackageFilterChain () { + // Get a new instance + $chainInstance = new PackageFilterChain(); + + // Return the prepared instance + return $chainInstance; + } + + /** + * Processes the given raw message content through all filters + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + * @todo This may be slow if a message with a lot tags arrived + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Get all filters and "run" them + foreach ($this->getFilters() as $filterInstance) { + // Try to process it + try { + $filterInstance->processMessage($messageData, $packageInstance); + } catch (FilterChainException $e) { + // This exception can be thrown to just skip any further processing + self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); + break; + } + } // END - foreach + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function postProcessMessage (Receivable $packageInstance) { + // Get all filters and "run" them + foreach ($this->getPostFilters() as $filterInstance) { + // Try to process it + try { + $filterInstance->postProcessMessage($packageInstance); + } catch (FilterChainException $e) { + // This exception can be thrown to just skip any further processing + self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); + break; + } + } // END - foreach + } +} + +// [EOF] +?> diff --git a/application/hub/classes/chat/.htaccess b/application/hub/classes/chat/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/chat/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/chat/class_ b/application/hub/classes/chat/class_ new file mode 100644 index 000000000..c25b448e3 --- /dev/null +++ b/application/hub/classes/chat/class_ @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???Chat extends BaseNodeChat implements Chatter { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $chatInstance An instance of a Chatter class + */ + public final static function createNode???Chat () { + // Get new instance + $chatInstance = new Node???Chat(); + + // Return the prepared instance + return $chatInstance; + } + + /** + * Method to "bootstrap" the chatter. This step does also apply provided + * command-line arguments stored in the request instance. You should now + * get it from calling $this->getRequestInstance(). + * + * @return void + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + $this->partialStub('Please implement this method.'); + } + + /** + * Add some chatter-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/chat/class_BaseNodeChat.php b/application/hub/classes/chat/class_BaseNodeChat.php new file mode 100644 index 000000000..a7acc995a --- /dev/null +++ b/application/hub/classes/chat/class_BaseNodeChat.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeChat extends BaseHubSystem { + /** + * Whether this Chatter is active + */ + private $isActive = FALSE; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Enables/disables the chatter (just sets a flag) + * + * @param $version Version number of this chatter + * @return void + */ + public final function enableIsActive ($isActive = TRUE) { + $this->isActive = (bool) $isActive; + } + + /** + * Determines whether the chatter is active + * + * @return $isActive Whether the chatter is active + */ + public final function isActive () { + return $this->isActive; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/chat/console/.htaccess b/application/hub/classes/chat/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/chat/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/chat/console/class_NodeConsoleChat.php b/application/hub/classes/chat/console/class_NodeConsoleChat.php new file mode 100644 index 000000000..bdfbaec76 --- /dev/null +++ b/application/hub/classes/chat/console/class_NodeConsoleChat.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeConsoleChat extends BaseNodeChat implements Chatter, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $chatInstance An instance of a Chatter class + */ + public final static function createNodeConsoleChat () { + // Get new instance + $chatInstance = new NodeConsoleChat(); + + // Return the prepared instance + return $chatInstance; + } + + /** + * Method to "bootstrap" the chatter. This step does also apply provided + * command-line arguments stored in the request instance. You should now + * get it from calling $this->getRequestInstance(). + * + * @return void + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + // Get the app instance (for shortening our code) + $app = $this->getApplicationInstance(); + + // Output all lines + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - A telnet connection helper'); + self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2012 Chat Developer Team'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); + self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); + self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + } + + /** + * Add some chatter-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/class_ b/application/hub/classes/class_ new file mode 100644 index 000000000..2dea4bd38 --- /dev/null +++ b/application/hub/classes/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ??? extends BaseFrameworkSystem implements === { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $!!!Instance An instance of a === class + */ + public final static function create??? () { + // Get new instance + $!!!Instance = new ???(); + + // Return the prepared instance + return $!!!Instance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/class_Base b/application/hub/classes/class_Base new file mode 100644 index 000000000..f8439da71 --- /dev/null +++ b/application/hub/classes/class_Base @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Base??? extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php new file mode 100644 index 000000000..77bf1c345 --- /dev/null +++ b/application/hub/classes/class_BaseHubSystem.php @@ -0,0 +1,496 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubSystem extends BaseFrameworkSystem { + // Exception codes + const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x900; + const EXCEPTION_CHUNK_ALREADY_ASSEMBLED = 0x901; + const EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED = 0x902; + const EXCEPTION_INVALID_CONNECTION_TYPE = 0x903; + const EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED = 0x904; + const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4 = 0x905; + const EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING = 0x906; + const EXCEPTION_REQUEST_NOT_ACCEPTED = 0x907; + const EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED = 0x908; + const EXCEPTION_MULTIPLE_MESSAGE_SENT = 0x909; + const EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED = 0x90a; + const EXCEPTION_INVALID_UNL = 0x90b; + + // Message status codes + const MESSAGE_STATUS_CODE_OKAY = 'OKAY'; + + /** + * Separator for all bootstrap node entries + */ + const BOOTSTRAP_NODES_SEPARATOR = ';'; + + /** + * An instance of a node + */ + private $nodeInstance = NULL; + + /** + * A network package handler instance + */ + private $packageInstance = NULL; + + /** + * A Receivable instance + */ + private $receiverInstance = NULL; + + /** + * Listener pool instance + */ + private $listenerPoolInstance = NULL; + + /** + * Fragmenter instance + */ + private $fragmenterInstance = NULL; + + /** + * Assembler instance + */ + private $assemblerInstance = NULL; + + /** + * Info instance + */ + private $infoInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for network package handler instance + * + * @param $packageInstance The network package instance we shall set + * @return void + */ + protected final function setPackageInstance (Deliverable $packageInstance) { + $this->packageInstance = $packageInstance; + } + + /** + * Getter for network package handler instance + * + * @return $packageInstance The network package handler instance we shall set + */ + protected final function getPackageInstance () { + return $this->packageInstance; + } + + /** + * Setter for receiver instance + * + * @param $receiverInstance A Receivable instance we shall set + * @return void + */ + protected final function setReceiverInstance (Receivable $receiverInstance) { + $this->receiverInstance = $receiverInstance; + } + + /** + * Getter for receiver instance + * + * @return $receiverInstance A Receivable instance we shall get + */ + protected final function getReceiverInstance () { + return $this->receiverInstance; + } + + /** + * Setter for listener pool instance + * + * @param $listenerPoolInstance The new listener pool instance + * @return void + */ + protected final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) { + $this->listenerPoolInstance = $listenerPoolInstance; + } + + /** + * Getter for listener pool instance + * + * @return $listenerPoolInstance Our current listener pool instance + */ + public final function getListenerPoolInstance () { + return $this->listenerPoolInstance; + } + + /** + * Setter for fragmenter instance + * + * @param $fragmenterInstance A Fragmentable instance + * @return void + */ + protected final function setFragmenterInstance (Fragmentable $fragmenterInstance) { + $this->fragmenterInstance = $fragmenterInstance; + } + + /** + * Getter for fragmenter instance + * + * @return $fragmenterInstance A Fragmentable instance + */ + protected final function getFragmenterInstance () { + return $this->fragmenterInstance; + } + + /** + * Setter for assembler instance + * + * @param $assemblerInstance An instance of an Assembler class + * @return void + */ + protected final function setAssemblerInstance (Assembler $assemblerInstance) { + $this->assemblerInstance = $assemblerInstance; + } + + /** + * Getter for assembler instance + * + * @return $assemblerInstance An instance of an Assembler class + */ + protected final function getAssemblerInstance () { + return $this->assemblerInstance; + } + + /** + * Setter for info instance + * + * @param $infoInstance A ShareableInfo instance + * @return void + */ + protected final function setInfoInstance (ShareableInfo $infoInstance) { + $this->infoInstance = $infoInstance; + } + + /** + * Getter for info instance + * + * @return $infoInstance An instance of a ShareableInfo class + */ + public final function getInfoInstance () { + return $this->infoInstance; + } + + /** + * Setter for node id + * + * @param $nodeId The new node id + * @return void + */ + protected final function setNodeId ($nodeId) { + // Set it config now + $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId); + } + + /** + * Getter for node id + * + * @return $nodeId Current node id + */ + public final function getNodeId () { + // Get it from config + return $this->getConfigInstance()->getConfigEntry('node_id'); + } + + /** + * Setter for private key + * + * @param $privateKey The new private key + * @return void + */ + protected final function setPrivateKey ($privateKey) { + // Set it config now + $this->getConfigInstance()->setConfigEntry('private_key', (string) $privateKey); + } + + /** + * Getter for private key + * + * @return $privateKey Current private key + */ + public final function getPrivateKey () { + // Get it from config + return $this->getConfigInstance()->getConfigEntry('private_key'); + } + + /** + * Setter for private key hash + * + * @param $privateKeyHash The new private key hash + * @return void + */ + protected final function setPrivateKeyHash ($privateKeyHash) { + // Set it config now + $this->getConfigInstance()->setConfigEntry('private_key_hash', (string) $privateKeyHash); + } + + /** + * Getter for private key hash + * + * @return $privateKeyHash Current private key hash + */ + public final function getPrivateKeyHash () { + // Get it from config + return $this->getConfigInstance()->getConfigEntry('private_key_hash'); + } + + /** + * Setter for session id + * + * @param $sessionId The new session id + * @return void + */ + protected final function setSessionId ($sessionId) { + $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId); + } + + /** + * Getter for session id + * + * @return $sessionId Current session id + */ + public final function getSessionId () { + return $this->getConfigInstance()->getConfigEntry('session_id'); + } + + /** + * Constructs a callable method name from given socket error code. If the + * method is not found, a generic one is used. + * + * @param $errorCode Error code from socket_last_error() + * @return $handlerName Call-back method name for the error handler + * @throws UnsupportedSocketErrorHandlerException If the error handler is not implemented + */ + protected function getSocketErrorHandlerFromCode ($errorCode) { + // Create a name from translated error code + $handlerName = 'socketError' . self::convertToClassName($this->translateSocketErrorCodeToName($errorCode)) . 'Handler'; + + // Is the call-back method there? + if (!method_exists($this, $handlerName)) { + // Please implement this + throw new UnsupportedSocketErrorHandlerException(array($this, $handlerName, $errorCode), self::EXCEPTION_UNSUPPORTED_ERROR_HANDLER); + } // END - if + + // Return it + return $handlerName; + } + + /** + * Handles socket error for given socket resource and peer data. This method + * validates $socketResource if it is a valid resource (see is_resource()) + * but assumes valid data in array $recipientData, except that + * count($recipientData) is always 2. + * + * @param $method Value of __METHOD__ from calling method + * @param $line Value of __LINE__ from calling method + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + * @throws InvalidSocketException If $socketResource is no socket resource + * @throws NoSocketErrorDetectedException If socket_last_error() gives zero back + */ + protected final function handleSocketError ($method, $line, $socketResource, array $unlData) { + // This method handles only socket resources + if (!is_resource($socketResource)) { + // No resource, abort here + throw new InvalidSocketException(array($this, $socketResource), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + // Check UNL array + //* DEBUG-DIE: */ die(__METHOD__ . ':unlData=' . print_r($unlData, TRUE)); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); + + // Get error code for first validation (0 is not an error) + $errorCode = socket_last_error($socketResource); + + // If the error code is zero, someone called this method without an error + if ($errorCode == 0) { + // No error detected (or previously cleared outside this method) + throw new NoSocketErrorDetectedException(array($this, $socketResource), BaseListener::EXCEPTION_NO_SOCKET_ERROR); + } // END - if + + // Get handler (method) name + $handlerName = $this->getSocketErrorHandlerFromCode($errorCode); + + // Call-back the error handler method + call_user_func_array(array($this, $handlerName), array($socketResource, $unlData)); + + // Finally clear the error because it has been handled + socket_clear_error($socketResource); + } + + /** + * Translates socket error codes into our own internal names which can be + * used for call-backs. + * + * @param $errorCode The error code from socket_last_error() to be translated + * @return $errorName The translated name (all lower-case, with underlines) + */ + public function translateSocketErrorCodeToName ($errorCode) { + // Nothing bad happened by default + $errorName = BaseRawDataHandler::SOCKET_CONNECTED; + + // Is the code a number, then we have to change it + switch ($errorCode) { + case 0: // Silently ignored, the socket is connected + break; + + case 11: // "Resource temporary unavailable" + $errorName = BaseRawDataHandler::SOCKET_ERROR_RESOURCE_UNAVAILABLE; + break; + + case 32: // "Broken pipe" + $errorName = BaseRawDataHandler::SOCKET_ERROR_BROKEN_PIPE; + break; + + case 104: // "Connection reset by peer" + $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_RESET_BY_PEER; + break; + + case 107: // "Transport end-point not connected" + case 134: // On some (?) systems for 'transport end-point not connected' + // @TODO On some systems it is 134, on some 107? + $errorName = BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT; + break; + + case 110: // "Connection timed out" + $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_TIMED_OUT; + break; + + case 111: // "Connection refused" + $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_REFUSED; + break; + + case 113: // "No route to host" + $errorName = BaseRawDataHandler::SOCKET_ERROR_NO_ROUTE_TO_HOST; + break; + + case 114: // "Operation already in progress" + $errorName = BaseRawDataHandler::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS; + break; + + case 115: // "Operation now in progress" + $errorName = BaseRawDataHandler::SOCKET_ERROR_OPERATION_IN_PROGRESS; + break; + + default: // Everything else <> 0 + // Unhandled error code detected, so first debug it because we may want to handle it like the others + self::createDebugInstance(__CLASS__)->debugOutput('BASE-HUB[' . __METHOD__ . ':' . __LINE__ . '] UNKNOWN ERROR CODE = ' . $errorCode . ', MESSAGE = ' . socket_strerror($errorCode)); + + // Change it only in this class + $errorName = BaseRawDataHandler::SOCKET_ERROR_UNKNOWN; + break; + } + + // Return translated name + return $errorName; + } + + /** + * Shuts down a given socket resource. This method does only ease calling + * the right visitor. + * + * @param $socketResource A valid socket resource + * @return void + */ + public function shutdownSocket ($socketResource) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM: Shutting down socket resource ' . $socketResource . ' with state ' . $this->getPrintableState() . ' ...'); + + // Set socket resource + $this->setSocketResource($socketResource); + + // Get a visitor instance + $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_socket_visitor_class'); + + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); + + // Call the visitor + $this->accept($visitorInstance); + } + + /** + * Half-shuts down a given socket resource. This method does only ease calling + * an other visitor than shutdownSocket() does. + * + * @param $socketResource A valid socket resource + * @return void + */ + public function halfShutdownSocket ($socketResource) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM: Half-shutting down socket resource ' . $socketResource . ' with state ' . $this->getPrintableState() . ' ...'); + + // Set socket resource + $this->setSocketResource($socketResource); + + // Get a visitor instance + $visitorInstance = ObjectFactory::createObjectByConfiguredName('half_shutdown_socket_visitor_class'); + + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); + + // Call the visitor + $this->accept($visitorInstance); + } + + /** + * "Getter" for a printable state name + * + * @return $stateName Name of the node's state in a printable format + */ + public final function getPrintableState () { + // Default is 'null' + $stateName = 'null'; + + // Get the state instance + $stateInstance = $this->getStateInstance(); + + // Is it an instance of Stateable? + if ($stateInstance instanceof Stateable) { + // Then use that state name + $stateName = $stateInstance->getStateName(); + } // END - if + + // Return result + return $stateName; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/commands/.htaccess b/application/hub/classes/commands/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/commands/console/.htaccess b/application/hub/classes/commands/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/commands/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/commands/console/class_HubConsoleAptProxyCommand.php b/application/hub/classes/commands/console/class_HubConsoleAptProxyCommand.php new file mode 100644 index 000000000..ff7c46385 --- /dev/null +++ b/application/hub/classes/commands/console/class_HubConsoleAptProxyCommand.php @@ -0,0 +1,131 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleAptProxyCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHubConsoleAptProxyCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubConsoleAptProxyCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Try to create a AptProxyActivationTask or so + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a registry and the application instance from it + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + /* + * ----------------------- Bootstrapping phase ------------------------ + * Try to bootstrap the node and pass the request instance to it for + * extra arguments which mostly override config entries or enable special + * features within the hub (none is ready at this development stage) + */ + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); + $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); + + // Get apt-proxy instance + $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); + + // Add some apt-proxy-specific filters + $proxyInstance->addExtraAptProxyFilters(); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); + + /* + * ----------------------------- Main loop ---------------------------- + * This is the main loop. Queried calls should come back here very fast + * so the whole application runs on nice speed. This while-loop goes + * until the apt-proxy is no longer active or all tasks are killed. + */ + while (($proxyInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { + // Handle all tasks here + $handlerInstance->handleTasks(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Should we add some more filters? + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add pre filters + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_php_requirements_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_initializer_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_welcome_teaser_filter')); + + // Add bootstrap filters + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_bootstrap_task_handler_initializer_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_bootstrap_extra_bootstrapping_filter')); + + // This is the last generic boostrap filter + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_bootstrap_generic_activation_filter')); + + // Add shutdown filters + //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_shutdown_task_handler_filter')); + + // This is the last generic shutdown filter + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_shutdown_filter')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/commands/console/class_HubConsoleChatCommand.php b/application/hub/classes/commands/console/class_HubConsoleChatCommand.php new file mode 100644 index 000000000..84776e332 --- /dev/null +++ b/application/hub/classes/commands/console/class_HubConsoleChatCommand.php @@ -0,0 +1,131 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleChatCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHubConsoleChatCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubConsoleChatCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Try to create a ChatActivationTask or so + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a registry and the application instance from it + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + /* + * ----------------------- Bootstrapping phase ------------------------ + * Try to bootstrap the node and pass the request instance to it for + * extra arguments which mostly override config entries or enable special + * features within the hub (none is ready at this development stage) + */ + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); + $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); + + // Get chat instance + $chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Add some chat-specific filters + $chatInstance->addExtraChatFilters(); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); + + /* + * ----------------------------- Main loop ---------------------------- + * This is the main loop. Queried calls should come back here very fast + * so the whole application runs on nice speed. This while-loop goes + * until the chat is no longer active or all tasks are killed. + */ + while (($chatInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { + // Handle all tasks here + $handlerInstance->handleTasks(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Should we add some more filters? + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add pre filters + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('chat_php_requirements_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('chat_initializer_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('chat_welcome_teaser_filter')); + + // Add bootstrap filters + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('chat_bootstrap_task_handler_initializer_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('chat_bootstrap_extra_bootstrapping_filter')); + + // This is the last generic boostrap filter + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('chat_bootstrap_generic_activation_filter')); + + // Add shutdown filters + //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('chat_shutdown_task_handler_filter')); + + // This is the last generic shutdown filter + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('chat_shutdown_filter')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/commands/console/class_HubConsoleCrawlerCommand.php b/application/hub/classes/commands/console/class_HubConsoleCrawlerCommand.php new file mode 100644 index 000000000..1f7d1c704 --- /dev/null +++ b/application/hub/classes/commands/console/class_HubConsoleCrawlerCommand.php @@ -0,0 +1,131 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleCrawlerCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHubConsoleCrawlerCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubConsoleCrawlerCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Try to create a CrawlerActivationTask or so + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a registry and the application instance from it + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + /* + * ----------------------- Bootstrapping phase ------------------------ + * Try to bootstrap the node and pass the request instance to it for + * extra arguments which mostly override config entries or enable special + * features within the hub (none is ready at this development stage) + */ + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); + $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); + + // Get crawler instance + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Add some crawler-specific filters + $crawlerInstance->addExtraCrawlerFilters(); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); + + /* + * ----------------------------- Main loop ---------------------------- + * This is the main loop. Queried calls should come back here very fast + * so the whole application runs on nice speed. This while-loop goes + * until the crawler is no longer active or all tasks are killed. + */ + while (($crawlerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { + // Handle all tasks here + $handlerInstance->handleTasks(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Should we add some more filters? + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add pre filters + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('crawler_php_requirements_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('crawler_initializer_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('crawler_welcome_teaser_filter')); + + // Add bootstrap filters + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('crawler_bootstrap_task_handler_initializer_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('crawler_bootstrap_extra_bootstrapping_filter')); + + // This is the last generic boostrap filter + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('crawler_bootstrap_generic_activation_filter')); + + // Add shutdown filters + //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('crawler_shutdown_task_handler_filter')); + + // This is the last generic shutdown filter + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('crawler_shutdown_filter')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/commands/console/class_HubConsoleCruncherCommand.php b/application/hub/classes/commands/console/class_HubConsoleCruncherCommand.php new file mode 100644 index 000000000..c1a6d0991 --- /dev/null +++ b/application/hub/classes/commands/console/class_HubConsoleCruncherCommand.php @@ -0,0 +1,132 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleCruncherCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHubConsoleCruncherCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubConsoleCruncherCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Try to create a CruncherActivationTask or so + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a registry and the application instance from it + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + /* + * ----------------------- Bootstrapping phase ------------------------ + * Try to bootstrap the node and pass the request instance to it for + * extra arguments which mostly override config entries or enable special + * features within the hub (none is ready at this development stage) + */ + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); + $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); + + // Get cruncher instance + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Add some cruncher-specific filters + $cruncherInstance->addExtraCruncherFilters(); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); + + /* + * ----------------------------- Main loop ---------------------------- + * This is the main loop. Queried calls should come back here very fast + * so the whole application runs on nice speed. This while-loop goes + * until the cruncher is no longer active or all tasks are killed. + */ + while (($cruncherInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { + // Handle all tasks here + $handlerInstance->handleTasks(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Should we add some more filters? + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add pre filters + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('cruncher_php_requirements_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('cruncher_initializer_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('cruncher_welcome_teaser_filter')); + + // Add bootstrap filters + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_task_handler_initializer_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_extra_bootstrapping_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_buffer_queue_initializer_filter')); + + // This is the last generic boostrap filter + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_generic_activation_filter')); + + // Add shutdown filters + //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('cruncher_shutdown_task_handler_filter')); + + // This is the last generic shutdown filter + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('cruncher_shutdown_filter')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/commands/console/class_HubConsoleMainCommand.php b/application/hub/classes/commands/console/class_HubConsoleMainCommand.php new file mode 100644 index 000000000..e92324a3c --- /dev/null +++ b/application/hub/classes/commands/console/class_HubConsoleMainCommand.php @@ -0,0 +1,142 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleMainCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHubConsoleMainCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubConsoleMainCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Try to create a HubActivationTask or so + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a registry and the application instance from it + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + /* + * ----------------------- Bootstrapping phase ------------------------ + * Try to bootstrap the node and pass the request instance to it for + * extra arguments which mostly override config entries or enable special + * features within the hub (none is ready at this development stage) + */ + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); + $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Add some node-specific filters, e.g. announcement + $nodeInstance->addExtraNodeFilters(); + + /* + * -------------------------- Hub activation -------------------------- + * Activates the node by doing some final preparation steps and setting + * the attribute $hubIsActive to TRUE. + */ + $nodeInstance->activateNode($requestInstance, $responseInstance); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); + + /* + * ----------------------------- Main loop ---------------------------- + * This is the main loop. Queried calls should come back here very fast + * so the whole application runs on nice speed. This while-loop goes + * until the hub is no longer active or all tasks are killed. + */ + while (($nodeInstance->isNodeActive()) && ($handlerInstance->hasTasksLeft())) { + // Handle all tasks here + $handlerInstance->handleTasks(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Should we add some more filters? + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add pre filters + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_initializer_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_welcome_teaser_filter')); + + // Add bootstrap filters + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_nodeid_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_sessionid_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_private_key_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_extra_bootstrapping_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_listener_pool_filter')); + + // Add node activation filters + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_task_handler_initializer_filter')); + + // Add shutdown filters + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_flush_node_list_filter')); + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_task_handler_filter')); + + // This is the last generic shutdown filter + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_node_filter')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/commands/console/class_HubConsoleMinerCommand.php b/application/hub/classes/commands/console/class_HubConsoleMinerCommand.php new file mode 100644 index 000000000..83aaf6369 --- /dev/null +++ b/application/hub/classes/commands/console/class_HubConsoleMinerCommand.php @@ -0,0 +1,132 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleMinerCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHubConsoleMinerCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubConsoleMinerCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Try to create a MinerActivationTask or so + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a registry and the application instance from it + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + /* + * ----------------------- Bootstrapping phase ------------------------ + * Try to bootstrap the node and pass the request instance to it for + * extra arguments which mostly override config entries or enable special + * features within the hub (none is ready at this development stage) + */ + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); + $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); + + // Get miner instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Add some miner-specific filters + $minerInstance->addExtraMinerFilters(); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); + + /* + * ----------------------------- Main loop ---------------------------- + * This is the main loop. Queried calls should come back here very fast + * so the whole application runs on nice speed. This while-loop goes + * until the miner is no longer active or all tasks are killed. + */ + while (($minerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { + // Handle all tasks here + $handlerInstance->handleTasks(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Should we add some more filters? + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add pre filters + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_php_requirements_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_initializer_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_welcome_teaser_filter')); + + // Add bootstrap filters + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_task_handler_initializer_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_extra_bootstrapping_filter')); + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_buffer_queue_initializer_filter')); + + // This is the last generic boostrap filter + $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_generic_activation_filter')); + + // Add shutdown filters + //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('miner_shutdown_task_handler_filter')); + + // This is the last generic shutdown filter + $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('miner_shutdown_filter')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/commands/html/.htaccess b/application/hub/classes/commands/html/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/commands/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/commands/html/class_HubHtmlIndexCommand.php b/application/hub/classes/commands/html/class_HubHtmlIndexCommand.php new file mode 100644 index 000000000..e56eeb890 --- /dev/null +++ b/application/hub/classes/commands/html/class_HubHtmlIndexCommand.php @@ -0,0 +1,91 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubHtmlIndexCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHubHtmlIndexCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HubHtmlIndexCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // This command doesn't handle any POST requests, so only handle get request + if ($requestInstance->isPostRequestMethod()) { + // Don't handle this here + $response->sendRequestMethodNotAllowed(); + + // Bail out + exit(); + } // END - if + + /* + * This is a generic HTML request, this means that a regular page with + * header, menu, content and footer shall be send to the client. + */ + $this->sendGenericGetResponse($requestInstance, $responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo 0% done + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add pre filters + //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/communicator/.htaccess b/application/hub/classes/communicator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/communicator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/communicator/class_ b/application/hub/classes/communicator/class_ new file mode 100644 index 000000000..4a7c8f4dd --- /dev/null +++ b/application/hub/classes/communicator/class_ @@ -0,0 +1,50 @@ +node communicator class + * + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2014 !!! Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???NodeCommunicator extends BaseCommunicator implements Communicator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $communicatorInstance An instance of a Communicator class + */ + public final static function create???NodeCommunicator () { + // Get new instance + $communicatorInstance = new ???NodeCommunicator(); + + // Return the prepared instance + return $communicatorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/communicator/class_BaseCommunicator.php b/application/hub/classes/communicator/class_BaseCommunicator.php new file mode 100644 index 000000000..8be2c2aec --- /dev/null +++ b/application/hub/classes/communicator/class_BaseCommunicator.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCommunicator extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init state which sets the state to 'init' + $this->initState(); + } + + /** + * Initializes the communicator's state which sets it to 'init' + * + * @return void + */ + private function initState() { + // Get the state factory and create the initial state. + CommunicatorStateFactory::createCommunicatorStateInstanceByName('init', $this); + } + + /** + * Initializes the executor, whatever it does. + * + * @return void + */ + public function initExecutor (Stateable $stateInstance) { + $this->partialStub('Unfinished method with state ' . $this->getPrintableState() . '.'); + + // This communicator is now fully initialized so change the state + $stateInstance->communicatorHasInitialized(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/communicator/crawler/.htaccess b/application/hub/classes/communicator/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/communicator/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php b/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php new file mode 100644 index 000000000..bfbc4c364 --- /dev/null +++ b/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php @@ -0,0 +1,50 @@ +node communicator class + * + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerNodeCommunicator extends BaseCommunicator implements Communicator, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $communicatorInstance An instance of a Communicator class + */ + public final static function createCrawlerNodeCommunicator () { + // Get new instance + $communicatorInstance = new CrawlerNodeCommunicator(); + + // Return the prepared instance + return $communicatorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/communicator/miner/.htaccess b/application/hub/classes/communicator/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/communicator/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php b/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php new file mode 100644 index 000000000..5ffb67c4c --- /dev/null +++ b/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php @@ -0,0 +1,50 @@ +node communicator class + * + * @author Roland Haeder + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerNodeCommunicator extends BaseCommunicator implements Communicator, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $communicatorInstance An instance of a Communicator class + */ + public final static function createMinerNodeCommunicator () { + // Get new instance + $communicatorInstance = new MinerNodeCommunicator(); + + // Return the prepared instance + return $communicatorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/compressor/.htaccess b/application/hub/classes/compressor/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/compressor/decorator/.htaccess b/application/hub/classes/compressor/decorator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/compressor/decorator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/compressor/decorator/class_NetworkPackageCompressorDecorator.php b/application/hub/classes/compressor/decorator/class_NetworkPackageCompressorDecorator.php new file mode 100644 index 000000000..06957ef60 --- /dev/null +++ b/application/hub/classes/compressor/decorator/class_NetworkPackageCompressorDecorator.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkPackageCompressorDecorator extends BaseHubSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $innerCompressorInstance The inner Compressor class + * @return $compressorInstance An instance of a Compressor class + */ + public static final function createNetworkPackageCompressorDecorator (Compressor $innerCompressorInstance) { + // Get new instance + $compressorInstance = new NetworkPackageCompressorDecorator(); + + // Set the inner compressor class + $compressorInstance->setCompressorInstance($innerCompressorInstance); + + // Return the prepared instance + return $compressorInstance; + } + + /** + * A compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + // Call the inner compressor class + return $this->getCompressorInstance()->compressStream($streamData); + } + + /** + * A decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + // Call the inner compressor class + return $this->getCompressorInstance()->decompressStream($streamData); + } + + /** + * Getter for the file extension of this compressor + * + * @return $string The compressor's file extension + */ + public function getCompressorExtension () { + // Call the inner compressor class + return $this->getCompressorInstance()->getCompressorExtension(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/connectors/.htaccess b/application/hub/classes/connectors/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/connectors/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/connectors/query/.htaccess b/application/hub/classes/connectors/query/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/connectors/query/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/connectors/query/class_ b/application/hub/classes/connectors/query/class_ new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/connectors/query/class_ @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/connectors/query/local/.htaccess b/application/hub/classes/connectors/query/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/connectors/query/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/connectors/queues/.htaccess b/application/hub/classes/connectors/queues/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/connectors/queues/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/connectors/queues/class_ b/application/hub/classes/connectors/queues/class_ new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/connectors/queues/class_ @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/connectors/queues/local/.htaccess b/application/hub/classes/connectors/queues/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/connectors/queues/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/controller/.htaccess b/application/hub/classes/controller/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/controller/console/.htaccess b/application/hub/classes/controller/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/controller/console/class_HubConsoleAptProxyController.php b/application/hub/classes/controller/console/class_HubConsoleAptProxyController.php new file mode 100644 index 000000000..178388f13 --- /dev/null +++ b/application/hub/classes/controller/console/class_HubConsoleAptProxyController.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleAptProxyController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHubConsoleAptProxyController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HubConsoleAptProxyController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/controller/console/class_HubConsoleChatController.php b/application/hub/classes/controller/console/class_HubConsoleChatController.php new file mode 100644 index 000000000..7a92d78de --- /dev/null +++ b/application/hub/classes/controller/console/class_HubConsoleChatController.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleChatController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHubConsoleChatController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HubConsoleChatController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/controller/console/class_HubConsoleCrawlerController.php b/application/hub/classes/controller/console/class_HubConsoleCrawlerController.php new file mode 100644 index 000000000..c351e6c2e --- /dev/null +++ b/application/hub/classes/controller/console/class_HubConsoleCrawlerController.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleCrawlerController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHubConsoleCrawlerController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HubConsoleCrawlerController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/controller/console/class_HubConsoleCruncherController.php b/application/hub/classes/controller/console/class_HubConsoleCruncherController.php new file mode 100644 index 000000000..b478baa73 --- /dev/null +++ b/application/hub/classes/controller/console/class_HubConsoleCruncherController.php @@ -0,0 +1,111 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleCruncherController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHubConsoleCruncherController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HubConsoleCruncherController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/controller/console/class_HubConsoleDefaultNewsController.php b/application/hub/classes/controller/console/class_HubConsoleDefaultNewsController.php new file mode 100644 index 000000000..35c26b32c --- /dev/null +++ b/application/hub/classes/controller/console/class_HubConsoleDefaultNewsController.php @@ -0,0 +1,135 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleDefaultNewsController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap', 'activation','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHubConsoleDefaultNewsController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HubConsoleDefaultNewsController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add news filters to this controller + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } + + /** + * Add a hub activation filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addActivationFilter (Filterable $filterInstance) { + $this->addFilter('activation', $filterInstance); + } + + /** + * Executes all hub activation filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('activation', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/controller/console/class_HubConsoleFuseController.php b/application/hub/classes/controller/console/class_HubConsoleFuseController.php new file mode 100644 index 000000000..1ae5f8a04 --- /dev/null +++ b/application/hub/classes/controller/console/class_HubConsoleFuseController.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleFuseController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHubConsoleFuseController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HubConsoleFuseController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/controller/console/class_HubConsoleMinerController.php b/application/hub/classes/controller/console/class_HubConsoleMinerController.php new file mode 100644 index 000000000..e3e564a7f --- /dev/null +++ b/application/hub/classes/controller/console/class_HubConsoleMinerController.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleMinerController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('bootstrap','shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHubConsoleMinerController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HubConsoleMinerController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Add a bootstrap filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addBootstrapFilter (Filterable $filterInstance) { + $this->addFilter('bootstrap', $filterInstance); + } + + /** + * Executes all bootstrap filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('bootstrap', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/controller/html/.htaccess b/application/hub/classes/controller/html/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/controller/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/crawler/.htaccess b/application/hub/classes/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/crawler/class_ b/application/hub/classes/crawler/class_ new file mode 100644 index 000000000..189379e51 --- /dev/null +++ b/application/hub/classes/crawler/class_ @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???Crawler extends BaseNodeCrawler implements Crawler { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $crawlerInstance An instance of a Crawler class + */ + public final static function createNode???Crawler () { + // Get new instance + $crawlerInstance = new Node???Crawler(); + + // Return the prepared instance + return $crawlerInstance; + } + + /** + * Method to "bootstrap" the crawler. This step does also apply provided + * command-line arguments stored in the request instance. You should now + * get it from calling $this->getRequestInstance(). + * + * @return void + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + $this->partialStub('Please implement this method.'); + } + + /** + * Add some crawler-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/crawler/class_BaseNodeCrawler.php b/application/hub/classes/crawler/class_BaseNodeCrawler.php new file mode 100644 index 000000000..d5ce4a5d8 --- /dev/null +++ b/application/hub/classes/crawler/class_BaseNodeCrawler.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeCrawler extends BaseHubSystem { + /** + * Whether this Crawler is active + */ + private $isActive = FALSE; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Set this crawler instance in registry + Registry::getRegistry()->addInstance('crawler', $this); + + // Init state which sets the state to 'init' + $this->initState(); + } + + /** + * Initializes the node's state which sets it to 'init' + * + * @return void + */ + private function initState() { + // Get the state factory and create the initial state. + CrawlerStateFactory::createCrawlerStateInstanceByName('init'); + } + + /** + * Initializes this crawler instance + * + * @param $stateInstance An instance of a Stateable class + * @return void + * @todo 0% done + */ + public function initCrawler (Stateable $stateInstance) { + // Please implement + $this->partialStub('Unfinished method.'); + } + + /** + * Enables/disables the crawler (just sets a flag) + * + * @param $version Version number of this crawler + * @return void + */ + public final function enableIsActive ($isActive = TRUE) { + $this->isActive = (bool) $isActive; + } + + /** + * Determines whether the crawler is active + * + * @return $isActive Whether the crawler is active + */ + public final function isActive () { + return $this->isActive; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/crawler/console/.htaccess b/application/hub/classes/crawler/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/crawler/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/crawler/console/class_NodeConsoleCrawler.php b/application/hub/classes/crawler/console/class_NodeConsoleCrawler.php new file mode 100644 index 000000000..d1b1cba58 --- /dev/null +++ b/application/hub/classes/crawler/console/class_NodeConsoleCrawler.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeConsoleCrawler extends BaseNodeCrawler implements Crawler, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $crawlerInstance An instance of a Crawler class + */ + public final static function createNodeConsoleCrawler () { + // Get new instance + $crawlerInstance = new NodeConsoleCrawler(); + + // Return the prepared instance + return $crawlerInstance; + } + + /** + * Method to "bootstrap" the crawler. This step does also apply provided + * command-line arguments stored in the request instance. You should now + * get it from calling $this->getRequestInstance(). + * + * @return void + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + // Get the app instance (for shortening our code) + $app = $this->getApplicationInstance(); + + // Output all lines + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('Distributed Crawler v' . $app->getAppVersion()); + self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2014 Crawler Developer Team'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); + self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); + self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + } + + /** + * Add some crawler-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/cruncher/.htaccess b/application/hub/classes/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/cruncher/class_ b/application/hub/classes/cruncher/class_ new file mode 100644 index 000000000..d4b0fb2c4 --- /dev/null +++ b/application/hub/classes/cruncher/class_ @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Hub???Cruncher extends BaseHubCruncher implements CruncherHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set version number + $this->setVersion('x.x'); + } + + /** + * Creates an instance of this hub-cruncher class + * + * @param $requestInstance An instance of a Requestable class + * @return $cruncherInstance An instance of this hub-cruncher class + */ + public final static function createHub???Cruncher (Requestable $requestInstance) { + // Get a new instance + $cruncherInstance = new Hub???Cruncher(); + + // Set the request instance + $cruncherInstance->setRequestInstance($requestInstance); + + // Return the instance + return $cruncherInstance; + } + + /** + * Method to "bootstrap" the cruncher. This step does also apply provided + * command-line arguments stored in the request instance. The regular cruncher + * should communicate with the bootstrap-crunchers at this point. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + // Call generic (parent) bootstrapping method first + parent::doGenericBootstrapping(); + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + $this->partialStub('Please implement this method.'); + } + + /** + * Add some cruncher-specific filters + * + * @return void + */ + public function addExtraHubFilters () { + // Add some filters here + } +} + +// [EOF] +?> diff --git a/application/hub/classes/cruncher/class_BaseHubCruncher.php b/application/hub/classes/cruncher/class_BaseHubCruncher.php new file mode 100644 index 000000000..76feae5d2 --- /dev/null +++ b/application/hub/classes/cruncher/class_BaseHubCruncher.php @@ -0,0 +1,213 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { + /** + * Version information + */ + private $version = 'x.x'; + + /** + * By default no cruncher is active + */ + private $isActive = FALSE; + + /** + * All buffer queue instances (a FIFO) + */ + private $bufferInstance = NULL; + + /** + * Stacker name for incoming queue + */ + const STACKER_NAME_IN_QUEUE = 'in_queue'; + + /** + * Stacker name for outcoming queue + */ + const STACKER_NAME_OUT_QUEUE = 'out_queue'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Set this cruncher instance in registry + Registry::getRegistry()->addInstance('cruncher', $this); + + // Init this cruncher + $this->initCruncher(); + } + + /** + * Initialize the cruncher generically + * + * @return void + */ + private function initCruncher () { + // Init the state + CruncherStateFactory::createCruncherStateInstanceByName('init'); + } + + /** + * Getter for version + * + * @return $version Version number of this cruncher + */ + protected final function getVersion () { + return $this->version; + } + + /** + * Setter for version + * + * @param $version Version number of this cruncher + * @return void + */ + protected final function setVersion ($version) { + $this->version = (string) $version; + } + + /** + * Checks whether the in-buffer queue is filled by comparing it's current + * amount of entries against a threshold. + * + * @return $isFilled Whether the in-buffer is filled + */ + protected function isInBufferQueueFilled () { + // Determine it + $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > $this->getConfigInstance()->getConfigEntry('cruncher_in_buffer_min_threshold')); + + // And return the result + return $isFilled; + } + + /** + * This method fills the in-buffer with (a) test unit(s) which are mainly + * used for development of the crunching part. They must be enabled in + * configuration, or else your cruncher runs out of WUs and waits for more + * to show up. + * + * In this method we already know that the in-buffer is going depleted so + * no need to double-check it here. + * + * @return void + */ + abstract protected function fillInBufferQueueWithTestUnits (); + + /** + * This method fills the in-buffer with (real) WUs which will be crunched + * and the result be sent back to the key producer instance. + * + * @return void + */ + abstract protected function fillInBufferQueueWithWorkUnits (); + + /** + * Enables/disables the cruncher (just sets a flag) + * + * @param $version Version number of this cruncher + * @return void + */ + public final function enableIsActive ($isActive = TRUE) { + $this->isActive = (bool) $isActive; + } + + /** + * Determines whether the cruncher is active + * + * @return $isActive Whether the cruncher is active + */ + public final function isActive () { + return $this->isActive; + } + + /** + * Initializes all buffer queues (mostly in/out). This method is demanded + * by the CruncherHelper interface. + * + * @return void + */ + public function initBufferQueues () { + /* + * Initialize both buffer queues, we can use the FIFO class here + * directly and encapsulate its method calls with protected methods. + */ + $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('cruncher_buffer_stacker_class'); + + // Initialize common stackers, like in/out + $this->bufferInstance->initStacks(array( + self::STACKER_NAME_IN_QUEUE, + self::STACKER_NAME_OUT_QUEUE + )); + + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER: All buffers are now initialized.'); + } + + /** + * This method determines if the in-buffer is going to depleted and if so, + * it fetches more WUs from the network. If no WU can be fetched from the + * network and if enabled, a random test WU is being generated. + * + * This method is demanded from the CruncherHelper interface. + * + * @return void + */ + public function doFetchWorkUnits () { + // Simply check if we have enough WUs left in the in-buffer queue (a FIFO) + if (!$this->isInBufferQueueFilled()) { + // The in-buffer queue needs filling, so head out and get some work + $this->fillInBufferQueueWithWorkUnits(); + + // Is the buffer still not filled and are test-packages allowed? + if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'Y')) { + // Then fill the in-buffer with (one) test-unit(s) + $this->fillInBufferQueueWithTestUnits(); + } // END - if + } // END - if + } + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + * @throws DatabaseUpdateSupportException If this class does not support database updates + * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem + */ + public function updateDatabaseField ($fieldName, $fieldValue) { + // Unfinished + $this->partialStub('Unfinished!'); + return; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/cruncher/mcrypt/.htaccess b/application/hub/classes/cruncher/mcrypt/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/cruncher/mcrypt/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/cruncher/mcrypt/class_HubMcryptCruncher.php b/application/hub/classes/cruncher/mcrypt/class_HubMcryptCruncher.php new file mode 100644 index 000000000..bf684cc6e --- /dev/null +++ b/application/hub/classes/cruncher/mcrypt/class_HubMcryptCruncher.php @@ -0,0 +1,147 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set version number + $this->setVersion('0.0.0'); + } + + /** + * Creates an instance of this hub-cruncher class + * + * @return $cruncherInstance An instance of this hub-cruncher class + */ + public final static function createHubMcryptCruncher () { + // Get a new instance + $cruncherInstance = new HubMcryptCruncher(); + + // Return the instance + return $cruncherInstance; + } + + /** + * This method fills the in-buffer with (a) test unit(s) which are mainly + * used for development of the crunching part. They must be enabled in + * configuration, or else your cruncher runs out of WUs and waits for more + * to show up. + * + * In this method we already know that the in-buffer is going depleted so + * no need to double-check it here. + * + * @return void + */ + protected function fillInBufferQueueWithTestUnits () { + // Are test units enabled? + if ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'N') { + // They are disabled, so skip any further steps + return; + } elseif ($this->getStateInstance()->isCruncherStateVirgin()) { + // No virgin crunchers please, because they usually have no test units ready for crunching + return; + } + + // Get a test-unit generator instance + $generatorInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_generator_class'); + + // We don't need an iterator here because we just need to generate some test units + for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('cruncher_max_text_unit_amount'); $idx++) { + // Get a test unit from it + $unitInstance = $generatorInstance->generateNextUnitInstance(); + + // ... and finally queue it to the in-buffer queue + $this->queueUnitInstanceToInBuffer($unitInstance); + } // END - for + } + + /** + * This method fills the in-buffer with (real) WUs which will be crunched + * and the result be sent back to the key producer instance. + * + * @return void + */ + protected function fillInBufferQueueWithWorkUnits () { + // This cruncher's state must not be one of these: 'virgin' + if ($this->getStateInstance()->isCruncherStateVirgin()) { + // We can silently skip here, until the generation is finished + return; + } // END - if + + // @TODO Implement this method + $this->partialStub('Please implement this method.'); + } + + /** + * Method to "bootstrap" the cruncher. This step does also apply provided + * command-line arguments stored in the request instance. No buffer queue + * will be initialized here, we only do "general" things here. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + // Output all lines + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('MCrypt Cruncher v' . $this->getVersion() . ' is starting ...'); + self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2011 - 2014 Cruncher Developer Team'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); + self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); + self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + } + + /** + * Add some cruncher-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + * @todo 0% done + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + // Add some filters here + $this->partialStub('Please add some cruncher-specific filters, if required.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/database/.htaccess b/application/hub/classes/database/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/database/frontend/.htaccess b/application/hub/classes/database/frontend/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/database/frontend/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/database/frontend/cruncher/.htaccess b/application/hub/classes/database/frontend/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/database/frontend/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php new file mode 100644 index 000000000..9beb90018 --- /dev/null +++ b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherUnitDatabaseWrapper extends BaseDatabaseWrapper implements UnitDatabaseWrapper, Registerable { + // Constants for database table names + const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units'; + + // Constants for database column names + const DB_COLUMN_UNIT_TYPE = 'unit_type'; + const DB_COLUMN_UNIT_STATUS = 'unit_status'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createCruncherUnitDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new CruncherUnitDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_CRUNCHER_UNITS); + + // Return the instance + return $wrapperInstance; + } + + /** + * Checks whether a test unit has been produced + * + * @return $isProduced Whether a test unit has already been produced + */ + public function isTestUnitProduced () { + // Now get a search instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add criteria for looking up already created and available test units + $searchInstance->addCriteria(self::DB_COLUMN_UNIT_TYPE , BaseUnitProducer::UNIT_TYPE_TEST_UNIT); + $searchInstance->addCriteria(self::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE); + $searchInstance->setConfiguredLimit('cruncher_test_unit_max_count'); + + // Search for our units + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Do we have some entries? + $isProduced = $resultInstance->next(); + + // Return it + return $isProduced; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/database/frontend/node/.htaccess b/application/hub/classes/database/frontend/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/database/frontend/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php new file mode 100644 index 000000000..12b8038bd --- /dev/null +++ b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -0,0 +1,682 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implements NodeDhtWrapper, Registerable { + /** + * "Cached" results for dabase for looking for unpublished entries + */ + private $unpublishedEntriesInstance = NULL; + + // Constants for database table names + const DB_TABLE_NODE_DHT = 'node_dht'; + + // Constants for database column names + const DB_COLUMN_NODE_ID = 'node_id'; + const DB_COLUMN_SESSION_ID = 'session_id'; + const DB_COLUMN_EXTERNAL_ADDRESS = 'external_address'; + const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash'; + const DB_COLUMN_NODE_MODE = 'node_mode'; + const DB_COLUMN_ACCEPTED_OBJECTS = 'accepted_object_types'; + const DB_COLUMN_NODE_LIST = 'node_list'; + const DB_COLUMN_PUBLICATION_STATUS = 'publication_status'; + const DB_COLUMN_ANSWER_STATUS = 'answer_status'; + const DB_COLUMN_ACCEPT_BOOTSTRAP = 'accept_bootstrap'; + + // Publication status' + const PUBLICATION_STATUS_PENDING = 'PENDING'; + + // Exception codes + const EXCEPTION_NODE_ALREADY_REGISTERED = 0x800; + const EXCEPTION_NODE_NOT_REGISTERED = 0x801; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createNodeDistributedHashTableDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new NodeDistributedHashTableDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_NODE_DHT); + + // Return the instance + return $wrapperInstance; + } + + /** + * Static getter for an array of all DHT database entries + * + * @return $elements All elements for the DHT dabase + */ + public static final function getAllElements () { + // Create array and ... + $elements = array( + self::DB_COLUMN_NODE_ID, + self::DB_COLUMN_SESSION_ID, + self::DB_COLUMN_EXTERNAL_ADDRESS, + self::DB_COLUMN_PRIVATE_KEY_HASH, + self::DB_COLUMN_NODE_MODE, + self::DB_COLUMN_ACCEPTED_OBJECTS, + self::DB_COLUMN_NODE_LIST + ); + + // ... return it + return $elements; + } + + /** + * Prepares a search instance for given node data + * + * @param $nodeData An array with valid node data + * @return $searchInstance An instance of a SearchCriteria class + */ + private function prepareSearchInstance (array $nodeData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Assert on array elements + assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); + + // Get instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for node id and limit it to one entry + $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $nodeData[self::DB_COLUMN_NODE_ID]); + $searchInstance->setLimit(1); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + + // Return it + return $searchInstance; + } + + /** + * Getter for result instance for unpublished entries + * + * @return $unpublishedEntriesInstance Result instance + */ + public final function getUnpublishedEntriesInstance () { + return $this->unpublishedEntriesInstance; + } + + /** + * Prepares a "local" instance of a StoreableCriteria class with all node + * data for insert/update queries. This data set contains data from *this* + * (local) node. + * + * @return $dataSetInstance An instance of a StoreableCriteria class + */ + private function prepareLocalDataSetInstance () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Get node/request instances + $nodeInstance = NodeObjectFactory::createNodeInstance(); + $requestInstance = ApplicationHelper::getSelfInstance()->getRequestInstance(); + + // Get a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); + + // Get Universal Node Locator and "explode" it + $unlInstance = $nodeInstance->determineUniversalNodeLocator(); + + // Get UNL data from it + $unlData = $unlInstance->getUnlData(); + + // Make sure both is valid + // @TODO Bad check on UNL, better use a proper validator + assert(isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL])); + assert($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] !== 'invalid'); + + // Get an array of all accepted object types + $objectList = $nodeInstance->getListFromAcceptedObjectTypes(); + + // Make sure this is an array + assert(is_array($objectList)); + + // Add public node data + $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_MODE , $requestInstance->getRequestElement('mode')); + $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]); + $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_ID , $nodeInstance->getNodeId()); + $dataSetInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId()); + $dataSetInstance->addCriteria(self::DB_COLUMN_PRIVATE_KEY_HASH, $nodeInstance->getPrivateKeyHash()); + $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList)); + $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($nodeInstance->isAcceptingDhtBootstrap())); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + + // Return it + return $dataSetInstance; + } + + /** + * Checks whether the local (*this*) node is registered in the DHT by + * checking if the external address is found. + * + * @return $isRegistered Whether *this* node is registered in the DHT + */ + public function isLocalNodeRegistered () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Get a search criteria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Get Universal Node Locator and "explode" it + $unlData = $nodeInstance->getUniversalNodeLocatorArray(); + + // Make sure the external address is set and not invalid + // @TODO Bad check on UNL, better use a proper validator + assert(isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL])); + assert($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] != 'invalid'); + + // Add Universal Node Locator/node id as criteria + $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]); + $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID , $nodeInstance->getNodeId()); + $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId()); + $searchInstance->setLimit(1); + + // Query database and get a result instance back + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Cache result of if there is an entry, valid() will tell us if an entry is there + $isRegistered = $resultInstance->valid(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!'); + + // Return result + return $isRegistered; + } + + /** + * Registeres the local (*this*) node with its data in the DHT. + * + * @return void + */ + public function registerLocalNode () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Assert to make sure this method is called with no record in DB (the actual backend of the DHT) + assert(!$this->isLocalNodeRegistered()); + + // Get prepared data set instance + $dataSetInstance = $this->prepareLocalDataSetInstance(); + + // "Insert" this dataset instance completely into the database + $this->queryInsertDataSet($dataSetInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Updates local (*this*) node's data in DHT, this is but not limited to the + * session id, ip number (and/or hostname) and port number. + * + * @return void + */ + public function updateLocalNode () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Assert to make sure this method is called with one record in DB (the actual backend of the DHT) + assert($this->isLocalNodeRegistered()); + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Get search criteria + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for node id and limit it to one entry + $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $nodeInstance->getNodeId()); + $searchInstance->setLimit(1); + + // Get a prepared dataset instance + $dataSetInstance = $this->prepareLocalDataSetInstance(); + + // Set search instance + $dataSetInstance->setSearchInstance($searchInstance); + + // Update DHT database record + $this->queryUpdateDataSet($dataSetInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Finds a node locally by given session id + * + * @param $sessionId Session id to lookup + * @return $nodeData Node data array + */ + public function findNodeLocalBySessionId ($sessionId) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: sessionId=' . $sessionId . ' - CALLED!'); + + // Get search criteria + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for session id and limit it to one entry + $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID, $sessionId); + $searchInstance->setLimit(1); + + // Query database and get a result instance back + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!'); + + // Return result instance + return $resultInstance; + } + + /** + * Registeres a node by given message data. + * + * @param $messageData An array of all message data + * @param $handlerInstance An instance of a HandleableDataSet class + * @return void + */ + public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!'); + + // Get a data set instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); + + // Set primary key (session id) + $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); + + // Add all array elements + $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData); + + // Remove 'node_list' + $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); + + // Run the "INSERT" query + $this->queryInsertDataSet($dataSetInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . '] - EXIT!'); + } + + /** + * Updates an existing entry in node list + * + * @param $messageData An array of all message data + * @param $handlerInstance An instance of a HandleableDataSet class + * @param $searchInstance An instance of LocalSearchCriteria class + * @return void + */ + public function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Get a data set instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); + + // Add search instance + $dataSetInstance->setSearchInstance($searchInstance); + + // Set primary key (session id) + $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); + + // Add all array elements + $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData); + + // Remove 'node_list' + $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); + + // Run the "UPDATE" query + $this->queryUpdateDataSet($dataSetInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Determines whether the given node data is already inserted in the DHT + * + * @param $nodeData An array with valid node data + * @return $isRegistered Whether the given node data is already inserted + */ + public function isNodeRegistered (array $nodeData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Assert on array elements + assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]); + + // Get search criteria + $searchInstance = $this->prepareSearchInstance($nodeData); + + // Query database and get a result instance back + $resultInstance = $this->doSelectByCriteria( + // Search instance + $searchInstance, + // Only look for these array elements ("keys") + array( + self::DB_COLUMN_NODE_ID => TRUE, + self::DB_COLUMN_EXTERNAL_ADDRESS => TRUE + ) + ); + + // Check if there is an entry + $isRegistered = $resultInstance->valid(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!'); + + // Return registration status + return $isRegistered; + } + + /** + * Registers a node with given data in the DHT. If the node is already + * registered this method shall throw an exception. + * + * @param $nodeData An array with valid node data + * @return void + * @throws NodeAlreadyRegisteredException If the node is already registered + */ + public function registerNode (array $nodeData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Assert on array elements + assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); + + // Is the node registered? + if ($this->isNodeRegistered($nodeData)) { + // Throw an exception + throw new NodeAlreadyRegisteredException(array($this, $nodeData), self::EXCEPTION_NODE_ALREADY_REGISTERED); + } // END - if + + // @TODO Unimplemented part + $this->partialStub('nodeData=' . print_r($nodeData, TRUE)); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Updates a node's entry in the DHT with given data. This will enrich or + * just update already exsiting data. If the node is not found this method + * shall throw an exception. + * + * @param $nodeData An array with valid node data + * @return void + * @throws NodeDataMissingException If the node's data is missing + */ + public function updateNode (array $nodeData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Assert on array elements + assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...'); + + // Is the node registered? + if (!$this->isNodeRegistered($nodeData)) { + // No, then throw an exception + throw new NodeDataMissingException(array($this, $nodeData), self::EXCEPTION_NODE_NOT_REGISTERED); + } // END - if + + // Get a search instance + $searchInstance = $this->prepareSearchInstance($nodeData); + + // Get a data set instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); + + // Add search instance + $dataSetInstance->setSearchInstance($searchInstance); + + // Set primary key (session id) + $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: nodeData=' . print_r($nodeData, TRUE)); + + // Add all array elements + $nodeInstance->addArrayToDataSet($dataSetInstance, $nodeData); + + // Remove 'node_list' + $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); + + // Run the "UPDATE" query + $this->queryUpdateDataSet($dataSetInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Checks whether there are unpublished entries + * + * @return $hasUnpublished Whether there are unpublished entries + * @todo Add minimum/maximum age limitations + */ + public function hasUnpublishedEntries () { + // Get search instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add exclusion key which is the publish status + $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PUBLICATION_STATUS, NodeDistributedHashTableDatabaseWrapper::PUBLICATION_STATUS_PENDING); + + // Remember search instance + $this->setSearchInstance($searchInstance); + + // Run the query + $this->unpublishedEntriesInstance = $this->doSelectByCriteria($searchInstance); + + // Check pending entries + $hasUnpublished = $this->unpublishedEntriesInstance->valid(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + + // Return it + return $hasUnpublished; + } + + /** + * Initializes publication of DHT entries. This does only prepare + * publication. The next step is to pickup such prepared entries and publish + * them by uploading to other (recently appeared) DHT members. + * + * @return void + * @todo Add timestamp to dataset instance + */ + public function initEntryPublication () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + /* + * Make sure that hasUnpublishedEntries() has been called first by + * asserting on the "cached" object instance. This "caching" saves some + * needless queries as this method shall be called immediately after + * hasUnpublishedEntries() returns TRUE. + */ + assert($this->unpublishedEntriesInstance instanceof SearchableResult); + + // Result is still okay? + assert($this->unpublishedEntriesInstance->valid()); + + // Remove 'publication_status' + $this->getSearchInstance()->unsetCriteria(self::DB_COLUMN_PUBLICATION_STATUS); + + // Make sure all entries are marked as pending, first get a dataset instance. + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); + + // Add search instance + $dataSetInstance->setSearchInstance($this->getSearchInstance()); + + // Set primary key (node id) + $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); + + // Add criteria (that should be set) + $dataSetInstance->addCriteria(self::DB_COLUMN_PUBLICATION_STATUS, self::PUBLICATION_STATUS_PENDING); + + // Run the "UPDATE" query + $this->queryUpdateDataSet($dataSetInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray(array $data) { + // Currently call only inner method + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); + $data = parent::removeNonPublicDataFromArray($data); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: data[]=' . gettype($data)); + + // Return cleaned data + return $data; + } + + /** + * Find recipients for given package data and exclude the sender + * + * @param $packageData An array of valid package data + * @return $recipients An indexed array with DHT recipients + */ + public function getResultFromExcludedSender (array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Assert on required array field + assert(isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER])); + + // Get max recipients + $maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients'); + + // First creata a search instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Then exclude 'sender' field as the sender is the current (*this*) node + $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); + + // Set limit to maximum DHT recipients + $searchInstance->setLimit($maxRecipients); + + // Get a result instance back from DHT database wrapper. + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + + // Return result instance + return $resultInstance; + } + + /** + * Find recopients by given key/value pair. First look for the key and if it + * matches, compare the value. + * + * @param $key Key to look for + * @param $value Value to compare if key matches + * @return $recipients An indexed array with DHT recipients + */ + public function getResultFromKeyValue ($key, $value) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Get max recipients + $maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients'); + + // First creata a search instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Find the key/value pair + $searchInstance->addCriteria($key, $value); + + // Get a result instance back from DHT database wrapper. + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + + // Return result instance + return $resultInstance; + } + + /** + * Enable DHT bootstrap request acceptance for local node + * + * @return void + */ + public function enableAcceptDhtBootstrap () { + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Enabling DHT bootstrap requests ...'); + + // Is the node already registered? + if ($this->isLocalNodeRegistered()) { + // Just update our record + $this->updateLocalNode(); + } else { + // Register it + $this->registerLocalNode(); + } + } +} + +// [EOF] +?> diff --git a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php new file mode 100644 index 000000000..a4c002022 --- /dev/null +++ b/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php @@ -0,0 +1,186 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements NodeInformationWrapper, Registerable { + // Constants for database table names + const DB_TABLE_NODE_INFORMATION = 'node_data'; + + // Constants for database column names + const DB_COLUMN_NODE_NR = 'node_nr'; + const DB_COLUMN_NODE_ID = 'node_id'; + const DB_COLUMN_SESSION_ID = 'session_id'; + const DB_COLUMN_PRIVATE_KEY = 'private_key'; + const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash'; + const DB_COLUMN_NODE_MODE = 'node_mode'; + const DB_COLUMN_INTERNAL_UNL = 'internal_unl'; + const DB_COLUMN_EXTERNAL_UNL = 'external_unl'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createNodeInformationDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new NodeInformationDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_NODE_INFORMATION); + + // Return the instance + return $wrapperInstance; + } + + /** + * Checks whether there is an entry for given node instance + * + * @param $nodeInstance An instance of a NodeHelper class + * @return $isFound Whether a node id has been found for this node + */ + public function ifNodeDataIsFound (NodeHelper $nodeInstance) { + // Is there cache? + if (!isset($GLOBALS[__METHOD__])) { + // Now get a search criteria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for the node number one which is hard-coded the default + $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1); + $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $nodeInstance->getRequestInstance()->getRequestElement('mode')); + $searchInstance->setLimit(1); + + // Get a result back + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Set result instance in node instance + $nodeInstance->setResultInstance($resultInstance); + + // Is it valid? + $GLOBALS[__METHOD__] = $resultInstance->next(); + } // END - if + + // Return it + return $GLOBALS[__METHOD__]; + } + + /** + * 'Registers' a new node id along with data provided in the node instance. + * This may sound confusing but avoids double code very nicely... + * + * @param $nodeInstance A node instance + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function registerNodeId (BaseHubNode $nodeInstance, Requestable $requestInstance) { + // Get a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); + + // Add registration elements to the dataset + $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); + + // "Insert" this dataset instance completely into the database + $this->queryInsertDataSet($dataSetInstance); + } + + /** + * 'Registers' a new session id along with data provided in the node instance. + * This may sound confusing but avoids double code very nicely... + * + * @param $nodeInstance An instance of a BaseHubNode class + * @param $requestInstance An instance of a Requestable class + * @param $searchInstance An instance of a LocalSearchCriteria class + * @return void + */ + public function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) { + // Get a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); + + // Set search instance + $dataSetInstance->setSearchInstance($searchInstance); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); + + // Add registration elements to the dataset + $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); + + // Update database record + $this->queryUpdateDataSet($dataSetInstance); + } + + /** + * 'Registers' a private key along with data provided in the node instance. + * This may sound confusing but avoids double code very nicely... + * + * @param $nodeInstance An instance of a BaseHubNode class + * @param $requestInstance An instance of a Requestable class + * @param $searchInstance An instance of a LocalSearchCriteria class + * @return void + */ + public function registerPrivateKey (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) { + // Get a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); + + // Set search instance + $dataSetInstance->setSearchInstance($searchInstance); + + // Add registration elements to the dataset + $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); + + // Update database record + $this->queryUpdateDataSet($dataSetInstance); + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray(array $data) { + // Currently call only inner method + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); + $data = parent::removeNonPublicDataFromArray($data); + + // Return cleaned data + return $data; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/database/frontend/states/.htaccess b/application/hub/classes/database/frontend/states/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/database/frontend/states/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php new file mode 100644 index 000000000..64d9f9df8 --- /dev/null +++ b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php @@ -0,0 +1,274 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements LookupablePeerState { + // Exception constants + const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300; + + // Constants for database table names + const DB_TABLE_PEER_LOOKUP = 'peer_states'; + + // Constants for database column names + const DB_COLUMN_PEER_IP = 'peer_ip'; + const DB_COLUMN_PEER_PORT = 'peer_port'; + const DB_COLUMN_PEER_SESSION_ID = 'peer_session_id'; + const DB_COLUMN_PEER_STATE = 'peer_state'; + const DB_COLUMN_SOCKET_ERROR_CODE = 'socket_error_code'; + const DB_COLUMN_SOCKET_ERROR_MSG = 'socket_error_msg'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createPeerStateLookupDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new PeerStateLookupDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_PEER_LOOKUP); + + // Return the instance + return $wrapperInstance; + } + + /** + * "Getter" for a LocalSearchCriteria from given package data's sender + * + * @param $packageData Valid raw package data array + * @return $searchInstance An instance of a LocalSearchCriteria class + */ + private function getSenderSearchInstanceFromPackageData (array $packageData) { + // Get the instance + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: Searching for sender ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add 'sender' as the peer's IP address + $searchInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); + $searchInstance->setLimit(1); + + // Return the instance + return $searchInstance; + } + + /** + * Checks whether given 'sender' is a new peer + * + * @param $packageData Raw package data + * @param $dataSetInstance An optional instance of a StoreableCriteria class + * @return $isNewPeer Whether 'sender' is a new peer to this peer + */ + public function isSenderNewPeer (array $packageData, StoreableCriteria $dataSetInstance = NULL) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: ' . __FUNCTION__ . ' called with packageData()=' . count($packageData) . ' - CALLED!'); + + // Is the package valid? + if (!isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER])) { + // Invalid package found, please report this + $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE)); + } // END - if + + // Get a search criteria instance from package data + $searchInstance = $this->getSenderSearchInstanceFromPackageData($packageData); + + // Is the dataset instance set? + if ($dataSetInstance instanceof StoreableCriteria) { + // Then remember the search instance in it + $dataSetInstance->setSearchInstance($searchInstance); + } // END - if + + // Count the query + $entries = $this->doSelectCountByCriteria($searchInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); + + // Is it there? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: entries=' . $entries); + $isNewPeer = ($entries != 1); + + // Return the result + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!'); + return $isNewPeer; + } + + /** + * Registers a new peer with given package data. We use the session id from it. + * + * @param $packageData Raw package data + * @param $socketResource A valid socket resource + * @return void + * @throws PeerAlreadyRegisteredException If a peer is already registered + */ + public function registerPeerByPackageData (array $packageData, $socketResource) { + // Make sure only new peers can be registered with package data + if (!$this->isSenderNewPeer($packageData)) { + // Throw an exception because this should normally not happen + throw new PeerAlreadyRegisteredException(array($this, $packageData), self::EXCEPTION_PEER_ALREADY_REGISTERED); + } // END - if + + // Generate a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP)); + + // Session ids must be unique + $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID); + + // Add session id + $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); + + // Get peer name + if (!@socket_getpeername($socketResource, $peerName, $peerPort)) { + // Get last error + $lastError = socket_last_error($socketResource); + + // ... and cleartext message from it and put both into criteria + $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_CODE, $lastError); + $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_MSG , socket_strerror($lastError)); + } // END - if + + // Add ip address and port + $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP , $peerName); + $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $peerPort); + + // "Insert" the data set + $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER] . ' has been registered.'); + } + + /** + * Registers the given peer state and raw package data + * + * @param $stateInstance A PeerStateable class instance + * @param $packageData Valid package data array + * @return void + * @throws PeerAlreadyRegisteredException If a peer is already registered + * @todo Unfinished area + */ + public function registerPeerState (PeerStateable $stateInstance, array $packageData) { + // Generate a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP)); + + // Session ids must be unique + $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID); + + // Add session id + $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); + $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_STATE , $stateInstance->getStateName()); + + // Try to resolve sender's session id + $senderData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_SENDER])); + + // Just make sure that 'invalid:invalid' is not being processed + assert(($senderData[0] != 'invalid') && ($senderData[1] != 'invalid') && ($senderData[2] != 'invalid')); + + // Add ip address and port + $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP , $senderData[0]); + $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $senderData[1]); + + // Is this a new peer? + if ($this->isSenderNewPeer($packageData, $dataSetInstance)) { + // "Insert" the data set + $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); + } else { + // Update the data set + $this->queryUpdateDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER] . ' has been registered/updated with state ' . $stateInstance->getStateName()); + } + + /** + * Purges old entries of given socket resource. We use the IP address from that resource. + * + * @param $socketResource A valid socket resource + * @return void + * @throws InvalidSocketException If the socket resource was invalid + * @todo Unfinished area + */ + public function purgeOldEntriesBySocketResource ($socketResource) { + // Get peer name + if (!@socket_getpeername($socketResource, $peerName, $peerPort)) { + // Get last error + $lastError = socket_last_error($socketResource); + + // Doesn't work! + throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: peerName=' . $peerName . ',peerPort=' . $peerPort . ' - UNFINISHED!'); + } + + /** + * Checks whether a given peer state (in helper instance) is same as stored + * in database compared with the one from $helperInstance. + * + * @param $helperInstance An instance of a ConnectionHelper class + * @param $packageData Valid package data array + * @return $isSamePeerState Whether the peer's state is the same + */ + public function isSamePeerState (ConnectionHelper $helperInstance, array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...'); + + // Now get the search instance from given package data + $searchInstance = $this->getSenderSearchInstanceFromPackageData($packageData); + + // With this search instance query the database for the peer and get a result instance + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Do we have an entry? This should always the case + assert($resultInstance->next()); + + // Yes, so get the current (=first) entry from it + $rowData = $resultInstance->current(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE)); + + // Assert on important elements + assert(isset($rowData[self::DB_COLUMN_PEER_STATE])); + + // Now just compare it with given state from helper instance + $isSamePeerState = ($rowData[self::DB_COLUMN_PEER_STATE] == $helperInstance->getPrintableState()); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState)); + + // Return it + return $isSamePeerState; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/decoder/.htaccess b/application/hub/classes/decoder/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/decoder/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/decoder/class_ b/application/hub/classes/decoder/class_ new file mode 100644 index 000000000..a9d980b8b --- /dev/null +++ b/application/hub/classes/decoder/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Decoder extends BaseDecoder implements Decodeable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $decoderInstance An instance of a Decodeable class + */ + public final static function create???Decoder () { + // Get new instance + $decoderInstance = new ???Decoder(); + + // Return the prepared instance + return $decoderInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/decoder/class_BaseDecoder.php b/application/hub/classes/decoder/class_BaseDecoder.php new file mode 100644 index 000000000..ba2a1e43d --- /dev/null +++ b/application/hub/classes/decoder/class_BaseDecoder.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDecoder extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/decoder/package/.htaccess b/application/hub/classes/decoder/package/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/decoder/package/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/decoder/package/class_PackageDecoder.php b/application/hub/classes/decoder/package/class_PackageDecoder.php new file mode 100644 index 000000000..49ba434c5 --- /dev/null +++ b/application/hub/classes/decoder/package/class_PackageDecoder.php @@ -0,0 +1,159 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { + /** + * Name for stacker for received packages + */ + const STACKER_NAME_DECODED_PACKAGE = 'decoded_package'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $handlerInstance An instance of a HandleableChunks class + * @return $decoderInstance An instance of a Decodeable class + */ + public final static function createPackageDecoder (HandleableChunks $handlerInstance) { + // Get new instance + $decoderInstance = new PackageDecoder(); + + // Init stacker for received packages + $handlerInstance->getStackInstance()->initStack(self::STACKER_NAME_DECODED_PACKAGE); + + // Set the handler instance here + $decoderInstance->setHandlerInstance($handlerInstance); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // And set it in this decoder + $decoderInstance->setPackageInstance($packageInstance); + + // Return the prepared instance + return $decoderInstance; + } + + /** + * Checks whether the assoziated stacker for raw package data has some entries left + * + * @return $unhandledDataLeft Whether some unhandled raw package data is left + */ + public function ifUnhandledRawPackageDataLeft () { + // Check it + $unhandledDataLeft = (!$this->getHandlerInstance()->getStackInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA)); + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: unhandledDataLeft=' . intval($unhandledDataLeft)); + return $unhandledDataLeft; + } + + /** + * Handles raw package data by decoding it + * + * @return void + */ + public function handleRawPackageData () { + // Assert on it to make sure the next popNamed() call won't throw an exception + assert($this->ifUnhandledRawPackageDataLeft()); + + // "Pop" the next raw package content + $rawPackageContent = $this->getHandlerInstance()->getStackInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...'); + + // "Decode" the raw package content by using the NetworkPackage instance + $decodedData = $this->getPackageInstance()->decodeRawContent($rawPackageContent); + + // Some checks + assert( + (is_array($decodedData)) && + (isset($decodedData[NetworkPackage::PACKAGE_DATA_SENDER])) && + (isset($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && + (isset($decodedData[NetworkPackage::PACKAGE_DATA_CONTENT])) && + (isset($decodedData[NetworkPackage::PACKAGE_DATA_STATUS])) + ); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); + + // Next get a recipient-discovery instance + $discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance(); + + // ... then disover all recipient (might be only one), this package may shall be forwarded + $discoveryInstance->discoverRawRecipients($decodedData); + + // Check for 'recipient' field (the 'sender' field and others are ignored here) + if ($discoveryInstance->isRecipientListEmpty()) { + // The recipient is this node so next stack it on 'decoded_package' + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...'); + $this->getHandlerInstance()->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData); + } else { + // Forward the package to the next node + $this->getPackageInstance()->forwardRawPackage($decodedData); + } + } + + /** + * Checks whether decoded packages have arrived (for this peer) + * + * @return $ifRawPackagesLeft Whether decoded packages have arrived + */ + public function ifDeocedPackagesLeft () { + // Check it ... + $ifRawPackagesLeft = (!$this->getHandlerInstance()->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE)); + + // ... return it + return $ifRawPackagesLeft; + } + + /** + * Handles received decoded packages internally (recipient is this node) + * + * @return void + */ + public function handleDecodedPackage () { + // Assert on amount + assert($this->ifDeocedPackagesLeft()); + + // Get the next entry (assoziative array) + $decodedData = $this->getHandlerInstance()->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE); + + // Handle it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); + $this->getPackageInstance()->handleRawData($decodedData); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/dht/.htaccess b/application/hub/classes/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/dht/class_ b/application/hub/classes/dht/class_ new file mode 100644 index 000000000..92d40c8f5 --- /dev/null +++ b/application/hub/classes/dht/class_ @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???DhtFacade extends BaseDht implements Distributable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $dhtInstance An instance of a Distributable class + */ + public final static function create??? () { + // Get new instance + $dhtInstance = new ???DhtFacade(); + + // Return the prepared instance + return $dhtInstance; + } + + /** + * Registers/updates an entry in the DHT with given data from $dhtData + * array. Different DHT implemtations may handle this differently as they + * may enrich the data with more meta data. + * + * @param $dhtData A valid array with DHT-related data (e.g. node/peer data) + * @return void + * @todo 0% done + */ + protected function insertDataIntoDht (array $dhtData) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php new file mode 100644 index 000000000..5452bc00e --- /dev/null +++ b/application/hub/classes/dht/class_BaseDht.php @@ -0,0 +1,262 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseDht extends BaseHubSystem implements Distributable { + /** + * "Cached" instance of a publish helper + */ + private $publishHelperInstance = NULL; + + /** + * Stacker name for "INSERT" node data + */ + const STACKER_NAME_INSERT_NODE = 'dht_insert_node'; + const STACKER_NAME_PENDING_PUBLISHING = 'dht_pending_publish'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Get a stacker instance for this DHT + $stackInstance = ObjectFactory::createObjectByConfiguredName('dht_stacker_class'); + + // Set it in this class + $this->setStackInstance($stackInstance); + + // Init all stackers + $this->initStacks(); + + // Get the state factory and create the initial state. + DhtStateFactory::createDhtStateInstanceByName('init', $this); + } + + /** + * Initializes all stackers + * + * @return void + */ + private function initStacks () { + // Initialize all stacker + $this->getStackInstance()->initStacks(array( + self::STACKER_NAME_INSERT_NODE, + self::STACKER_NAME_PENDING_PUBLISHING, + )); + } + + /** + * Registers/updates an entry in the DHT with given data from $dhtData + * array. Different DHT implemtations may handle this differently as they + * may enrich the data with more meta data. + * + * @param $dhtData A valid array with DHT-related data (e.g. node/peer data) + * @return void + */ + protected abstract function insertDataIntoDht (array $dhtData); + + /** + * Updates/refreshes DHT data (e.g. status). + * + * @return void + * @todo Find more to do here + */ + public function updateDhtData () { + // Set some dummy configuration entries, e.g. dht_status + $this->getConfigInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName()); + } + + /** + * Checks whether there are entries in "INSERT" node data stack + * + * @return $isPending Whether there are pending entries + */ + public function ifInsertNodeDataPending () { + // Determine it if it is not empty + $isPending = ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_INSERT_NODE) === FALSE); + + // Return status + return $isPending; + } + + /** + * Inserts a single entry of node data into the DHT + * + * @return void + */ + public function insertSingleNodeData () { + // Get next node data from stack + $nodeData = $this->getStackInstance()->popNamed(self::STACKER_NAME_INSERT_NODE); + + // Make sure $nodeData is really an array and has at least one entry + assert((is_array($nodeData)) && (count($nodeData) > 0)); + + // Insert the data + $this->insertDataIntoDht($nodeData); + } + + /** + * Checks whether there are unpublished entries + * + * @return $hasUnpublished Whether there are unpublished entries + * @todo Add minimum/maximum age limitations + */ + public function hasUnpublishedEntries () { + // Call method on database wrapper + $hasUnpublished = $this->getWrapperInstance()->hasUnpublishedEntries(); + + // Return it + return $hasUnpublished; + } + + /** + * Initializes publication of DHT entries. This does only prepare + * publication. The next step is to pickup such prepared entries and publish + * them by uploading to other (recently appeared) DHT members. + * + * @return void + */ + public function initEntryPublication () { + // Call method on database wrapper + $this->getWrapperInstance()->initEntryPublication(); + + // Get result instance + $resultInstance = $this->getWrapperInstance()->getUnpublishedEntriesInstance(); + + // Make sure the result instance is valid + assert($resultInstance instanceof SearchableResult); + assert($resultInstance->valid()); + + // "Walk" through all entries + while ($resultInstance->next()) { + // Get current entry + $current = $resultInstance->current(); + + // Make sure only valid entries pass + // @TODO Maybe add more small checks? + assert(is_array($current)); + + // ... and push it to the next stack + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] Pushing entry with ' . count($current) . ' elements to stack ' . self::STACKER_NAME_PENDING_PUBLISHING . ' ...'); + $this->getStackInstance()->pushNamed(self::STACKER_NAME_PENDING_PUBLISHING, $current); + } // END - while + } + + /** + * Checks whether there are entries pending publication + * + * @return $isPending Whether there are entries pending publication + */ + public function hasEntriesPendingPublication () { + // Determine it if it is not empty + $isPending = ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PENDING_PUBLISHING) === FALSE); + + // Return status + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] isPending=' . intval($isPending)); + return $isPending; + } + + /** + * Whether this DHT's state is 'booting' + * + * @return $isBooting Whether this DHT is currently booting + */ + public function ifDhtIsBooting () { + // Call state instance + $isBooting = $this->getStateInstance()->ifDhtIsBooting(); + + // Return status + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] isBooting=' . intval($isBooting)); + return $isBooting; + } + + /** + * Publishes next entry found in stack. This method shall also update the + * corresponding dabase entry. + * + * @return void + * @todo Find out if loadDescriptorXml() can be called only once to avoid a lot methods working. + */ + public function publishEntry () { + // This test must not fail + assert($this->hasEntriesPendingPublication()); + + // Is there an instance? + if (!$this->publishHelperInstance instanceof HelpableDht) { + // Get a helper instance + $this->publishHelperInstance = ObjectFactory::createObjectByConfiguredName('dht_publish_entry_helper_class'); + } // END - if + + // Load the announcement descriptor + $this->publishHelperInstance->loadDescriptorXml($this); + + // "Pop" next entry + $entry = $this->getStackInstance()->popNamed(self::STACKER_NAME_PENDING_PUBLISHING); + + // Some sanity-checks + assert(is_array($entry)); + + // Remove any non-public data the database layer desires + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT[' . __METHOD__ . ':' . __LINE__ . ']: Calling this->getWrapperInstance()->removeNonPublicDataFromArray(data) ...'); + $entry = $this->getWrapperInstance()->removeNonPublicDataFromArray($entry); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT[' . __METHOD__ . ':' . __LINE__ . ']: entry[]=' . gettype($entry)); + + // Some sanity-checks again + assert(is_array($entry)); + + // Assign multiple variables + $this->publishHelperInstance->getTemplateInstance()->assignMultipleVariables($entry); + + // "Publish" the descriptor by sending it to the bootstrap/list nodes + $this->publishHelperInstance->sendPackage($this); + } + + /** + * Whether the DHT has fully bootstrapped (after state 'booting') + * + * @return $isFullyBooted Whether the DHT is fully booted + * @todo 0% done + */ + public function hasFullyBootstrapped () { + // Get state and check it + $this->partialStub('Please implement this method.'); + } + + /** + * Enable DHT bootstrap request acceptance for local node + * + * @return void + * @todo Switch flag 'accept_bootstrap' + */ + public function enableAcceptDhtBootstrap () { + // Call method on database wrapper + $this->getWrapperInstance()->enableAcceptDhtBootstrap(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/dht/node/.htaccess b/application/hub/classes/dht/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/dht/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/dht/node/class_NodeDhtFacade.php b/application/hub/classes/dht/node/class_NodeDhtFacade.php new file mode 100644 index 000000000..18d9addbd --- /dev/null +++ b/application/hub/classes/dht/node/class_NodeDhtFacade.php @@ -0,0 +1,386 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $dhtInstance An instance of a Distributable class + */ + public final static function createNodeDhtFacade () { + // Get new instance + $dhtInstance = new NodeDhtFacade(); + + // Get a database wrapper instance + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_dht_db_wrapper_class'); + + // Set it in this class + $dhtInstance->setWrapperInstance($wrapperInstance); + + // Return the prepared instance + return $dhtInstance; + } + + /** + * Registers/updates an entry in the DHT with given data from $dhtData + * array. Different DHT implemtations may handle this differently as they + * may enrich the data with more meta data. + * + * @param $dhtData A valid array with DHT-related data (e.g. node/peer data) + * @return void + * @todo Does this data need to be enriched with more meta data? + */ + protected function insertDataIntoDht (array $dhtData) { + // Check if there is already an entry for given node_id + if ($this->getWrapperInstance()->isNodeRegistered($dhtData)) { + /* + * Update existing record. Please note that this step is not secure + * (e.g. DHT poisoning) it would be good to implement some checks if + * the both node owner trust each other (see sub-project 'DSHT'). + */ + $this->getWrapperInstance()->updateNode($dhtData); + } else { + /* + * Inserts given node data into the DHT. As above, this step does + * currently not perform any security checks. + */ + $this->getWrapperInstance()->registerNode($dhtData); + } + } + + /** + * Initializes the distributed hash table (DHT) + * + * @return void + */ + public function initDht () { + // Is the local node registered? + if ($this->getWrapperInstance()->isLocalNodeRegistered()) { + // Then only update session id + $this->getWrapperInstance()->updateLocalNode(); + } else { + // No, so register it + $this->getWrapperInstance()->registerLocalNode(); + } + + // Change state + $this->getStateInstance()->dhtHasInitialized(); + } + + /** + * Bootstraps the DHT by sending out a message to all available nodes + * (including itself). This step helps the node to get to know more nodes + * which can be queried later for object distribution. + * + * @return void + */ + public function bootstrapDht () { + // Get a helper instance + $helperInstance = ObjectFactory::createObjectByConfiguredName('dht_bootstrap_helper_class'); + + // Load the announcement descriptor + $helperInstance->loadDescriptorXml($this); + + // Compile all variables + $helperInstance->getTemplateInstance()->compileConfigInVariables(); + + // "Publish" the descriptor by sending it to the bootstrap/list nodes + $helperInstance->sendPackage($this); + + // Change state + $this->getStateInstance()->dhtIsBooting(); + } + + /** + * Finds a node locally by given session id + * + * @param $sessionId Session id to lookup + * @return $nodeData Node-data array + */ + public function findNodeLocalBySessionId ($sessionId) { + // Default is empty data array + $nodeData = array(); + + /* + * Call the wrapper to do the job and get back a result instance. There + * will come back zero or one entry from the wrapper. + */ + $resultInstance = $this->getWrapperInstance()->findNodeLocalBySessionId($sessionId); + + // Make sure the result instance is valid + assert($resultInstance instanceof SearchableResult); + + // Is the next entry valid? + if (($resultInstance->valid()) && ($resultInstance->next())) { + /* + * Then load the first entry (more entries are being ignored and + * should not happen). + */ + $nodeData = $resultInstance->current(); + } // END - if + + // Return node data + return $nodeData; + } + + /** + * Registers an other node with this node by given message data. The + * following data must always be present: + * + * - session-id (for finding the node's record together with below data) + * - external-address (hostname or IP number) + * - listen-port (TCP/UDP listen port for inbound connections) + * + * @param $messageArray An array with all minimum message data + * @param $handlerInstance An instance of a HandleableDataSet class + * @param $forceUpdate Optionally force update, don't register (default: register if not found) + * @return void + * @throws NodeSessionIdVerficationException If the node was not found and update is forced + */ + public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, $forceUpdate = FALSE) { + // Get a search criteria class + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, TRUE) . ',handlerInstance=' . $handlerInstance->__toString() . ',forceUpdate=' . intval($forceUpdate) . ',count(getSearchData())=' . count($handlerInstance->getSearchData())); + + // Search for the node's session id and external address/hostname + TCP/UDP listen port + foreach ($handlerInstance->getSearchData() as $key) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',key=' . $key); + + // Is it there? + assert(isset($messageData[$key])); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData[' . $key . ']=' . $messageData[$key]); + + // Add criteria + $searchInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); + } // END - foreach + + // Only one entry is fine + $searchInstance->setLimit(1); + + // Run the query + $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance); + + // Make sure the result instance is valid + assert($resultInstance instanceof SearchableResult); + + // Is there already an entry? + if ($resultInstance->valid()) { + // Entry found, so update it + $this->getWrapperInstance()->updateNodeByMessageData($messageData, $handlerInstance, $searchInstance); + } elseif ($forceUpdate === FALSE) { + // Nothing found, so register it + $this->getWrapperInstance()->registerNodeByMessageData($messageData, $handlerInstance); + } else { + /* + * Do not register non-existent nodes here. This is maybe fatal, + * caused by "stolen" session id and/or not matching address. + */ + throw new NodeSessionIdVerficationException(array($this, $messageData), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING); + } + + // Save last exception + $handlerInstance->setLastException($this->getWrapperInstance()->getLastException()); + } + + /** + * Queries the local DHT data(base) for a node list with all supported + * object types except the node by given session id. + * + * @param $messageData An array with message data from a node_list request + * @param $handlerInstance An instance of a HandleableDataSet class + * @param $excludeKey Array key which should be excluded + * @param $andKey Array of $separator-separated list of elements which all must match + * @param $separator Sepator char (1st parameter for explode() call) + * @return $nodeList An array with all found nodes + */ + public function queryLocalNodeListExceptByMessageData (array $messageData, HandleableDataSet $handlerInstance, $excludeKey, $andKey, $separator) { + // Make sure both keys are there + assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey]))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, TRUE)); + + // Get a search criteria class + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add all keys + foreach (explode($separator, $messageData[$andKey]) as $criteria) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: andKey=' . $andKey . ',criteria=' . $criteria); + + // Add it and leave any 'my-' prefix out + $searchInstance->addChoiceCriteria(str_replace('my-', '', $andKey), $criteria); + } // END - foreach + + // Add exclusion key + $searchInstance->addExcludeCriteria(str_replace('my-', '', $excludeKey), $messageData[$excludeKey]); + + // Only X entries are fine + $searchInstance->setLimit($this->getConfigInstance()->getConfigEntry('node_dht_list_limit')); + + // Run the query + $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance); + + // Make sure the result instance is valid + assert($resultInstance instanceof SearchableResult); + assert($resultInstance->valid()); + + // Init array + $nodeList = array(); + + // Get node list + while ($resultInstance->next()) { + // Get current element (it should be an array, and have at least 1 entry) + $current = $resultInstance->current(); + assert(is_array($current)); + assert(count($current) > 0); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: current(' . count($current) . ')[' . gettype($current) . ']=' . print_r($current, TRUE)); + + /* + * Remove some keys as they should not be published. + */ + unset($current[$this->getWrapperInstance()->getIndexKey()]); + + // Add this entry + array_push($nodeList, $current); + } // END - while + + // Save last exception + $handlerInstance->setLastException($this->getWrapperInstance()->getLastException()); + + // Return node list (array) + return $nodeList; + } + + /** + * Inserts given node list array (from earlier database result produced by + * an other node) into the DHT. This array origins from above method + * queryLocalNodeListExceptByMessageData(). + * + * @param $nodeList An array from an earlier database result instance + * @return void + */ + public function insertNodeList (array $nodeList) { + // If no node is in the list (array), skip the rest of this method + if (count($nodeList) == 0) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: No node record has been returned.'); + + // Abort here + return; + } // END - if + + // Put them all into a stack + foreach ($nodeList as $nodeData) { + // Insert all entries + $this->getStackInstance()->pushNamed(self::STACKER_NAME_INSERT_NODE, $nodeData); + } // END - foreach + } + + /** + * Find recipients for given package data + * + * @param $packageData An array of valid package data + * @return $recipients An indexed array with DHT recipients + */ + public function findRecipientsByPackageData (array $packageData) { + // Query get a result instance back from DHT database wrapper. + $resultInstance = $this->getWrapperInstance()->getResultFromExcludedSender($packageData); + + // Make sure the result instance is valid + assert($resultInstance instanceof SearchableResult); + + // No entries found? + if (!$resultInstance->valid()) { + // Then skip below loop + return array(); + } // END - if + + // Init array + $recipients = array(); + + // Search for all recipients + while ($resultInstance->next()) { + // Get current entry + $current = $resultInstance->current(); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: current=' . print_r($current, TRUE)); + + // Add instance to recipient list + array_push($recipients, $current); + } // END - while + + // Return filled array + return $recipients; + } + + /** + * Finds DHT recipients by given key/value pair + * + * @param $key Key to search for + * @param $value Value to check on found key + * @return $recipiens Array with DHT recipients from given key/value pair + */ + public function findRecipientsByKey ($key, $value) { + // Look for all suitable nodes + $resultInstance = $this->getWrapperInstance()->getResultFromKeyValue($key, $value); + + // Make sure the result instance is valid + assert($resultInstance instanceof SearchableResult); + assert($resultInstance->valid()); + + // Init array + $recipients = array(); + + // "Walk" through all entries + while ($resultInstance->next()) { + // Get current entry + $current = $resultInstance->current(); + + // Add instance to recipient list + array_push($recipients, $current); + } // END - while + + // Return filled array + return $recipients; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/.htaccess b/application/hub/classes/discovery/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/discovery/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/discovery/class_ b/application/hub/classes/discovery/class_ new file mode 100644 index 000000000..fc0d85a69 --- /dev/null +++ b/application/hub/classes/discovery/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class !!!Discovery extends BaseNodeDiscovery implements Discoverable,,,, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function create!!!Discovery () { + // Get an instance of this class + $discoveryInstance = new !!!Discovery(); + + // Return the prepared instance + return $discoveryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/class_BaseNodeDiscovery.php b/application/hub/classes/discovery/class_BaseNodeDiscovery.php new file mode 100644 index 000000000..72c2dd8e2 --- /dev/null +++ b/application/hub/classes/discovery/class_BaseNodeDiscovery.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeDiscovery extends BaseDiscovery implements Discoverable { + /** + * Protected constructor + * + * @param $className Real class name + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/node/.htaccess b/application/hub/classes/discovery/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/discovery/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/discovery/node/class_UniversalNodeLocatorDiscovery.php b/application/hub/classes/discovery/node/class_UniversalNodeLocatorDiscovery.php new file mode 100644 index 000000000..0501bdabc --- /dev/null +++ b/application/hub/classes/discovery/node/class_UniversalNodeLocatorDiscovery.php @@ -0,0 +1,105 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UniversalNodeLocatorDiscovery extends BaseNodeDiscovery implements DiscoverableUniversalNodeLocator, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createUniversalNodeLocatorDiscovery () { + // Get an instance of this class + $discoveryInstance = new UniversalNodeLocatorDiscovery(); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * "Discovers" an instance of a LocateableNode class for given NodeHelper class + * + * @param $nodeInstance An instance of a NodeHelper class + * @return $unlInstance An instance of a LocateableNode class + */ + public function discoverUniversalNodeLocatorByNode (NodeHelper $nodeInstance) { + /* + * First get an instance from the configured hub communication protocol + * type (which is mostly TCP, so you get a TcpProtocolResolver here). + */ + $resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol(); + + // Then resolve the node instance into an UNL instance + $unlInstance = $resolverInstance->resolveUniversalNodeLocatorFromNodeHelper($nodeInstance); + + // ... and return it + return $unlInstance; + } + + /** + * "Discovers" the full universal node locator for given configuration entry + * which should represent the address part of the UNL. In case of an IP + * address, this *must not* include the port number as this is being found + * out for you. + * + * Valid values for $configKey: internal,external + * + * @param $configKey Key for address to get (valid: internal,external) + * @return $unl Universal node locator + */ + public function discoverUniversalNodeLocatorByConfiguredAddress ($configKey) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UNL-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']:configKey=' . $configKey . ' - CALLED!'); + + // Is there cache? + if (!isset($GLOBALS[__METHOD__][$configKey])) { + // Validate config key + assert(($configKey == 'internal') || ($configKey == 'external')); + + /* + * First get an instance from the configured hub communication protocol + * type (which is mostly TCP, so you get a TcpProtocolResolver here). + */ + $resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol(); + + // Get back the full UNL + $GLOBALS[__METHOD__][$configKey] = $resolverInstance->resolveUniversalNodeLocatorFromConfigKey($configKey); + } // END - if + + // Return cached value + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UNL-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']:configKey=' . $configKey . ',unl=' . $GLOBALS[__METHOD__][$configKey] . ' - EXIT!'); + return $GLOBALS[__METHOD__][$configKey]; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/protocol/.htaccess b/application/hub/classes/discovery/protocol/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/discovery/protocol/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/discovery/protocol/class_ProtocolDiscovery.php b/application/hub/classes/discovery/protocol/class_ProtocolDiscovery.php new file mode 100644 index 000000000..82ac8c693 --- /dev/null +++ b/application/hub/classes/discovery/protocol/class_ProtocolDiscovery.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ProtocolDiscovery extends BaseNodeDiscovery implements DiscoverableProtocol, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createProtocolDiscovery () { + // Get an instance of this class + $discoveryInstance = new ProtocolDiscovery(); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Determines the protoctol name + * + * @param $packageData Valid package data + * @return $protocolInstance An instance of a HandleableProtocol class + */ + public static final function determineProtocolByPackageData (array $packageData) { + // First we need a tags instance + $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); + + /* + * We need to decide here which socket (TCP or UDP) should be used for + * the actual data transmission. In this process we will find out if + * the recipient of this package has already a known (registered) socket + * and if so we can re-use it. If there is no socket registered, we try + * to make a new connection to the given Universal Node Locator. + */ + $protocolInstance = $tagsInstance->chooseProtocolFromPackageData($packageData); + + // Return it + return $protocolInstance; + } + + /** + * "Discovers" the protocol type from given raw package data. This is done + * by looking at the 'recipient' field and extract the first part from it. + * + * @param $packageData Raw package data + * @return $protocolType Type of protocol, e.g. 'tcp' for TCP/IPv4 connections + */ + public static final function discoverProtocolByPackageData (array $packageData) { + //* DEBUG: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE)); + + /* + * "Explode" the 'recipient' array element into a new one, giving at + * least two entries: protocol://address + */ + $recipient = explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + + // At least 2 entries must be found + assert(count($recipient) >= 2); + + // Now get the first part (protocol type) and make all lower-case + $protocolType = strtolower($recipient[0]); + + // Return it + // @TODO Add some validation here??? + return $protocolType; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/recipient/.htaccess b/application/hub/classes/discovery/recipient/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/discovery/recipient/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/discovery/recipient/class_ b/application/hub/classes/discovery/recipient/class_ new file mode 100644 index 000000000..6a792f53f --- /dev/null +++ b/application/hub/classes/discovery/recipient/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class !!!RecipientDiscovery extends BaseRecipientDiscovery implements Discoverable,,,Recipient, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function create!!!Discovery () { + // Get an instance of this class + $discoveryInstance = new !!!Discovery(); + + // Return the prepared instance + return $discoveryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/recipient/class_BaseRecipientDiscovery.php b/application/hub/classes/discovery/recipient/class_BaseRecipientDiscovery.php new file mode 100644 index 000000000..9ad0f612e --- /dev/null +++ b/application/hub/classes/discovery/recipient/class_BaseRecipientDiscovery.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseRecipientDiscovery extends BaseNodeDiscovery implements DiscoverableRecipient { + /** + * Protected constructor + * + * @param $className Real class name + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + /* + * Get recipients list instance and set it here for all discovery + * implementations. + */ + $listInstance = RecipientListFactory::createRecipientListInstance(); + $this->setListInstance($listInstance); + } + + /** + * "Getter" for recipient iterator + * + * @return$iteratorInstance An instance of a Iterateable object + */ + public final function getIterator () { + // Get iterator from it + $iteratorInstance = $this->getListInstance()->getIterator(); + + // Return it + return $iteratorInstance; + } + + /** + * Clears all recipients for e.g. another package to deliver. This method + * simply clears the inner list instance. + * + * @return void + */ + public final function clearRecipients () { + // Clear the list + $this->getListInstance()->clearList(); + } + + /** + * Checks whether the recipient list is empty + * + * @return $isEmpty Whether the recipient list is empty + */ + public final function isRecipientListEmpty () { + // Check it ... + $isEmpty = ($this->getListInstance()->count() == 0); + + // Return it + return $isEmpty; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/recipient/dht/.htaccess b/application/hub/classes/discovery/recipient/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/discovery/recipient/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/discovery/recipient/dht/class_DhtRecipientDiscovery.php b/application/hub/classes/discovery/recipient/dht/class_DhtRecipientDiscovery.php new file mode 100644 index 000000000..f090f1d30 --- /dev/null +++ b/application/hub/classes/discovery/recipient/dht/class_DhtRecipientDiscovery.php @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtRecipientDiscovery extends BaseRecipientDiscovery implements DiscoverableDhtRecipient, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createDhtRecipientDiscovery () { + // Get an instance of this class + $discoveryInstance = new DhtRecipientDiscovery(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set it here + $discoveryInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Resolves one or more recipients for a DHT transfer by given package data. + * + * @param $packageData Valid package data array + * @return $recipients An indexed array with DHT recipients + */ + public function resolveRecipientsByPackageData (array $packageData) { + // Use facade to get recipients back + $recipients = $this->getDhtInstance()->findRecipientsByPackageData($packageData); + + // Return it + return $recipients; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/recipient/package/.htaccess b/application/hub/classes/discovery/recipient/package/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/discovery/recipient/package/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php new file mode 100644 index 000000000..72e879400 --- /dev/null +++ b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php @@ -0,0 +1,121 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageRecipientDiscovery extends BaseRecipientDiscovery implements DiscoverableNodeRecipient, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createPackageRecipientDiscovery () { + // Get an instance of this class + $discoveryInstance = new PackageRecipientDiscovery(); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Tries to discover all recipients for given package data + * + * @param $packageData Raw package data array + * @return void + */ + public function discoverRecipients (array $packageData) { + // This must be available + //* DEBUG: */ print $this->__toString() . ': packageData=' . print_r($packageData, TRUE); + assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); + + // First try out the direct recipient (session id) + try { + // Get instance (should not break) + $recipientInstance = ObjectFactory::createObjectByConfiguredName('direct_recipient_class'); + + // Try to solve it + $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData); + } catch (FrameworkException $e) { + // Didn't work, so try the non-generic, depending recipient field itself (this may fail) + try { + // Try to find the right class + $recipientInstance = ObjectFactory::createObjectByConfiguredName(strtolower($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) . '_recipient_class'); + + // And try to solve again + $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData); + } catch (FrameworkException $e) { + // Could not find class, what ever failed + $this->debugInstance($e->getMessage()); + } + } + } + + /** + * Tries to discover all recipients by given decoded package data. + * + * @param $decodedData Raw raw package data array + * @return void + * @todo Add some validation of recipient field, e.g. an Universal Node Locator is found + * @todo Enrich both messages with recipient data + */ + public function discoverRawRecipients (array $decodedData) { + // This must be available + assert(isset($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); + + // First clear all recipients + $this->clearRecipients(); + + // Get a protocol handler back from decoded data + $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($decodedData); + + // Is the 'recipient' field same as this peer's IP? + if ($handlerInstance->isOwnAddress($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) { + /* + * Is same as own external address + TCP/UDP listen port or + * internal address, don't do anything here so other classes found + * an empty recipient list for internal (own) handling of the + * original content. + */ + + // Debug output (may flood) + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' matches own ip (external=' . HubTools::determineOwnExternalAddress() . ' or internal=' . HubTools::determineOwnInternalAddress() . ')'); + } else { + // Debug output (may flood) + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' is different than own external address (' . HubTools::determineOwnExternalAddress() . ') nor internal address (' . HubTools::determineOwnInternalAddress() . '), need to forward (not yet implemented)!'); + + // This package is to be delivered to someone else, so add it + // @TODO Unfinished: $this->getListInstance()->addEntry('unl', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + } + } +} + +// [EOF] +?> diff --git a/application/hub/classes/discovery/recipient/socket/.htaccess b/application/hub/classes/discovery/recipient/socket/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/discovery/recipient/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php new file mode 100644 index 000000000..698c44cb1 --- /dev/null +++ b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php @@ -0,0 +1,206 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageSocketDiscovery extends BaseRecipientDiscovery implements DiscoverableSocket, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createPackageSocketDiscovery () { + // Get an instance of this class + $discoveryInstance = new PackageSocketDiscovery(); + + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Initialized.'); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Tries to dicover the right listener instance + * + * @param $protocolInstance An instance of a HandleableProtocol class + * @param $packageData Raw package data + * @return $listenerInstance An instance of a Listenable instance or null + */ + public function discoverListenerInstance (HandleableProtocol $protocolInstance, array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolInstance=' . $protocolInstance->__toString() . ' - CALLED!'); + + /* + * Get the listener pool instance, we need to lookup the matching + * listener->poolInstance chain there. + */ + $poolInstance = NodeObjectFactory::createNodeInstance()->getListenerPoolInstance(); + + // Init listener instance + $listenerInstance = NULL; + + // Get handler name + $protocolName = $protocolInstance->getProtocolName(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',poolEntriesInstance=' . $poolInstance->getPoolEntriesInstance()->__toString()); + + /* + * Now we need to choose again. It is whether we are speaking with a hub + * or with a client. So just handle it over to all listeners in this + * pool. + */ + foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromList($protocolName) as $listenerInstance) { + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance[' . gettype($listenerInstance) . ']=' . $listenerInstance); + + // Make sure the instance is valid + assert($listenerInstance instanceof Listenable); + + // Does the listener want that package? + if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) { + // This listener likes our package data, so abort here + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is accepting package data.'); + break; + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is NOT accepting package data.'); + } // END - foreach + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: listenerInstance=' . $listenerInstance->__toString()); + + // Return it + return $listenerInstance; + } + + /** + * Tries to discover the right socket for given package data and returns a + * matching socket resource for that protocol. + * + * @param $packageData Raw package data array + * @param $connectionType Type of connection, can be 'incoming' or 'outgoing', *NEVER* 'server'! + * @return $socketResource A valid socket resource or FALSE if an error occured + * @throws NoListGroupException If the procol group is not found in peer list + * @throws NullPointerException If listenerInstance is NULL + * @throws InvalidUnlException If the provided UNL cannot be validated by the protocol handler + */ + public function discoverSocket (array $packageData, $connectionType) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: connectionType=' . $connectionType . ' - CALLED!'); + + // Assert on type and recipient + assert($connectionType != BaseConnectionHelper::CONNECTION_TYPE_SERVER); + assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); + + // Determine protocol instance + $protocolInstance = ProtocolDiscovery::determineProtocolByPackageData($packageData); + + // Is it valid? + assert($protocolInstance instanceof HandleableProtocol); + + // Does the UNL validate? + if (!$protocolInstance->isValidUniversalNodeLocatorByPackageData($packageData)) { + // Not valid, throw exception + throw new InvalidUnlException(array($this, $protocolInstance, $packageData), BaseHubSystem::EXCEPTION_INVALID_UNL); + } // END - if + + // Get the listener instance + $listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageData); + + // If there is no listener who wants to have that package, we simply drop it here + if (is_null($listenerInstance)) { + // Abort with no resource + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('protocolInstance=' . $protocolInstance . ',packageData=' . print_r($packageData, TRUE)); + + /* + * Now we have the listener instance, we can determine the right + * resource to continue. The first step is to get the attached pool + * instance and pass over the whole package data to get the right + * socket. + */ + $socketResource = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData, $connectionType); + + // Debug message + // @TODO FIXME: I don't like these abuse of variables, better strict types + if (is_resource($socketResource)) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',error=' . socket_strerror(socket_last_error($socketResource)) . ',packageData=' . print_r($packageData, TRUE)); + } else { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',packageData=' . print_r($packageData, TRUE)); + } + + // Is it FALSE, the recipient isn't known to us and we have no connection to it + if (($socketResource === FALSE) || (!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) { + // Try to create a new socket resource + try { + // Possibly noisy debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to establish a ' . strtoupper($protocolInstance) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...'); + + // Get a socket resource from our factory (if succeeded) + $socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolInstance); + } catch (SocketConnectionException $e) { + // The connection fails of being established, so log it away + self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage()); + } + } // END - if + + // Try to resolve the socket resource + try { + // Get the helper instance from registry + $helperInstance = Registry::getRegistry()->getInstance('connection'); + + // Possibly noisy debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Going to resolve socket from peer state and given package data ...'); + + // Resolve the peer's state (but ignore return value) + PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketResource); + } catch (InvalidSocketException $e) { + // This cannot be fixed, so log it away + self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage()); + + // Make any failed attempts to 'FALSE' + $socketResource = FALSE; + } + + // And return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, TRUE)); + return $socketResource; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/.htaccess b/application/hub/classes/factories/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/chain/.htaccess b/application/hub/classes/factories/chain/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/chain/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/chain/class_PackageFilterChainFactory.php b/application/hub/classes/factories/chain/class_PackageFilterChainFactory.php new file mode 100644 index 000000000..9cd32b50e --- /dev/null +++ b/application/hub/classes/factories/chain/class_PackageFilterChainFactory.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageFilterChainFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a filter chain by given tags array. + * + * @param $tags An array with tags from a package + * @return $chainInstance An instance of a filter chain class + */ + public static final function createChainByTagsArray (array $tags) { + // Get a registry key from tags array, this does mostly call implode() + $registryKey = Registry::getRegistryKeyFromArray('package_filter_chain', $tags); + + // Is the registry key there? + if (Registry::getRegistry()->instanceExists($registryKey)) { + // Yes, then use that instance + $chainInstance = Registry::getRegistry()->getInstance($registryKey); + } else { + // Initialize a filter chain class + $chainInstance = self::createObjectByConfiguredName('package_filter_chain_class'); + + // "Walk" through all tags entries + foreach ($tags as $tag) { + /* + * Now create a filter instance of this tag. This way all tags + * got rudymentary verified, if an exception is coming here, it + * simply means the tag is not valid. This however should be + * handled some calls before this method is called. + */ + $filterInstance = self::createObjectByConfiguredName('package_tag_' . $tag . '_filter'); + + // Add this filter to the chain + $chainInstance->addFilter($filterInstance); + } // END - foreach + + // Add the finished chain to the registry + Registry::getRegistry()->addInstance($registryKey, $chainInstance); + } + + // Return the chain instance + return $chainInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/chunks/.htaccess b/application/hub/classes/factories/chunks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/chunks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/chunks/class_ChunkHandlerFactory.php b/application/hub/classes/factories/chunks/class_ChunkHandlerFactory.php new file mode 100644 index 000000000..3cda26f3d --- /dev/null +++ b/application/hub/classes/factories/chunks/class_ChunkHandlerFactory.php @@ -0,0 +1,59 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChunkHandlerFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) chunk handler instance + * + * @return $handlerInstance An instance of a chunk handler class + */ + public static final function createChunkHandlerInstance () { + // If there is no handler? + if (Registry::getRegistry()->instanceExists('chunk_handler')) { + // Get handler from registry + $handlerInstance = Registry::getRegistry()->getInstance('chunk_handler'); + } else { + // Get the handler instance + $handlerInstance = self::createObjectByConfiguredName('chunk_handler_class'); + + // Add it to the registry + Registry::getRegistry()->addInstance('chunk_handler', $handlerInstance); + } + + // Return the instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/class_ b/application/hub/classes/factories/class_ new file mode 100644 index 000000000..d23d9641f --- /dev/null +++ b/application/hub/classes/factories/class_ @@ -0,0 +1,59 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Factory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) !!! instance + * + * @return $%%%Instance An instance of a !!! class + */ + public static final function create???Instance () { + // If there is no handler? + if (Registry::getRegistry()->instanceExists('|||')) { + // Get handler from registry + $%%%Instance = Registry::getRegistry()->getInstance('|||'); + } else { + // Get the handler instance + $%%%Instance = self::createObjectByConfiguredName('|||_class'); + + // Add it to the registry + Registry::getRegistry()->addInstance('|||', $%%%Instance); + } + + // Return the instance + return $%%%Instance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/communicator/.htaccess b/application/hub/classes/factories/communicator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/communicator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/communicator/class_CommunicatorFactory.php b/application/hub/classes/factories/communicator/class_CommunicatorFactory.php new file mode 100644 index 000000000..8a7ba8aa7 --- /dev/null +++ b/application/hub/classes/factories/communicator/class_CommunicatorFactory.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014, 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CommunicatorFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton communicator instance. If no instance is found, it fill + * be generated and stored in registry, else the communicator from the + * registry will be returned. + * + * @param $configEntry A configuration entry naming the real class' name + * @parasm $communicatorType Type of the communicator, can currently be 'node' + * @return $communicatorInstance A communicator instance + */ + public static final function createCommunicatorInstance ($configEntry, $communicatorType) { + // If there is no communicator? + if (Registry::getRegistry()->instanceExists($communicatorType . '_communicator')) { + // Get communicator from registry + $communicatorInstance = Registry::getRegistry()->getInstance($communicatorType . '_communicator'); + } else { + // Get the communicator instance + $communicatorInstance = self::createObjectByConfiguredName($configEntry); + + // Add it to the registry + Registry::getRegistry()->addInstance($communicatorType . '_communicator', $communicatorInstance); + } + + // Return the instance + return $communicatorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/decoder/.htaccess b/application/hub/classes/factories/decoder/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/decoder/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/decoder/class_DecoderFactory.php b/application/hub/classes/factories/decoder/class_DecoderFactory.php new file mode 100644 index 000000000..7125c6a9f --- /dev/null +++ b/application/hub/classes/factories/decoder/class_DecoderFactory.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DecoderFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) Decodeable instance + * + * @return $decoderInstance An instance of a Decodeable class + */ + public static final function createPackageDecoderInstance () { + // If there is no handler? + if (Registry::getRegistry()->instanceExists('package_decoder')) { + // Get handler from registry + $decoderInstance = Registry::getRegistry()->getInstance('package_decoder'); + } else { + // Get a chunk handler instance + $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); + + // Get the handler instance + $decoderInstance = self::createObjectByConfiguredName('package_decoder_class', array($handlerInstance)); + + // Add it to the registry + Registry::getRegistry()->addInstance('package_decoder', $decoderInstance); + } + + // Return the instance + return $decoderInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/dht/.htaccess b/application/hub/classes/factories/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/dht/class_DhtObjectFactory.php b/application/hub/classes/factories/dht/class_DhtObjectFactory.php new file mode 100644 index 000000000..6555908a6 --- /dev/null +++ b/application/hub/classes/factories/dht/class_DhtObjectFactory.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtObjectFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) DHT object instance + * + * @param $prefix Prefix for DHT class name and registry key + * @return $dhtInstance An instance of a DHT object class + */ + public static final function createDhtInstance ($prefix) { + // Set instance name + $name = $prefix . '_dht'; + + // If there is no handler? + if (Registry::getRegistry()->instanceExists($name)) { + // Get handler from registry + $dhtInstance = Registry::getRegistry()->getInstance($name); + } else { + // Get the handler instance + $dhtInstance = self::createObjectByConfiguredName($name . '_class'); + + // Add it to the registry + Registry::getRegistry()->addInstance($name, $dhtInstance); + } + + // Return the instance + return $dhtInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/discovery/.htaccess b/application/hub/classes/factories/discovery/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/discovery/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/discovery/class_PackageDiscoveryFactory.php b/application/hub/classes/factories/discovery/class_PackageDiscoveryFactory.php new file mode 100644 index 000000000..ef5725663 --- /dev/null +++ b/application/hub/classes/factories/discovery/class_PackageDiscoveryFactory.php @@ -0,0 +1,61 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageDiscoveryFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton network package instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $discoveryInstance A package discovery instance + */ + public static final function createPackageDiscoveryInstance () { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('package_discovery')) { + // Then use this instance + $discoveryInstance = Registry::getRegistry()->getInstance('package_discovery'); + } else { + // Create a new instance + $discoveryInstance = self::createObjectByConfiguredName('package_recipient_discovery_class'); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('package_discovery', $discoveryInstance); + } + + // Return the instance + return $discoveryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/discovery/class_SocketDiscoveryFactory.php b/application/hub/classes/factories/discovery/class_SocketDiscoveryFactory.php new file mode 100644 index 000000000..6991c7fa5 --- /dev/null +++ b/application/hub/classes/factories/discovery/class_SocketDiscoveryFactory.php @@ -0,0 +1,61 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketDiscoveryFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton network socket instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $discoveryInstance A socket discovery instance + */ + public static final function createSocketDiscoveryInstance () { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('socket_discovery')) { + // Then use this instance + $discoveryInstance = Registry::getRegistry()->getInstance('socket_discovery'); + } else { + // Create a new instance + $discoveryInstance = self::createObjectByConfiguredName('socket_discovery_class'); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('socket_discovery', $discoveryInstance); + } + + // Return the instance + return $discoveryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/fragmenter/.htaccess b/application/hub/classes/factories/fragmenter/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/fragmenter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/handler/.htaccess b/application/hub/classes/factories/handler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/handler/class_MessageTypeHandlerFactory.php b/application/hub/classes/factories/handler/class_MessageTypeHandlerFactory.php new file mode 100644 index 000000000..ce750231f --- /dev/null +++ b/application/hub/classes/factories/handler/class_MessageTypeHandlerFactory.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MessageTypeHandlerFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton message type handler instance. If an instance is + * found in registry, it will be returned, else a new instance is created + * and stored in the same registry entry. + * + * @param $messageType Message type to create an object from + * @return $handlerInstance A message type handler instance + */ + public static final function createMessageTypeHandlerInstance ($messageType) { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('message_type_' . $messageType . '_handler')) { + // Then use this instance + $handlerInstance = Registry::getRegistry()->getInstance('message_type_' . $messageType . '_handler'); + } else { + // Now prepare the tags instance + $handlerInstance = self::createObjectByConfiguredName('message_type_' . $messageType . '_handler_class'); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('message_type_' . $messageType . '_handler', $handlerInstance); + } + + // Return the instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php b/application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php new file mode 100644 index 000000000..880f889bf --- /dev/null +++ b/application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php @@ -0,0 +1,91 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Unfinished stuff + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ProtocolHandlerFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a protocol handler based on given protocol type. This is mostly 'tcp'. + * + * @param $protocolType Protocol type to create/return a protocol handler instance for + * @return $handlerInstance A protocol handler instance + */ + private static function createProtocolHandlerByType ($protocolType) { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists($protocolType . '_protocol_handler')) { + // Then use this instance + $handlerInstance = Registry::getRegistry()->getInstance($protocolType . '_protocol_handler'); + } else { + // Now prepare the tags instance + $handlerInstance = self::createObjectByConfiguredName($protocolType . '_protocol_handler_class'); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance($protocolType . '_protocol_handler', $handlerInstance); + } + + // Return the instance + return $handlerInstance; + } + + /** + * Returns a singleton protocol handler instance from given HubHelper + * instance. If an instance is found in registry, it will be returned, else + * a new instance is created and stored in the same registry entry. + * + * @param $helperInstance An instance of a HubHelper class + * @return $handlerInstance A protocol handler instance + */ + public static final function createProtocolHandlerFromRecipientHelper (HubHelper $helperInstance) { + // Get the protocol type from given helper instance + $protocolType = $helperInstance->determineProtocolType(); + + // Call super factory method + return self::createProtocolHandlerByType($protocolType); + } + + /** + * Creates an instance of a protocol handler from given (raw) package data + * + * @param $packageData An array with raw package data + * @return $handlerInstance A protocol handler instance + */ + public static final function createProtocolHandlerFromPackageData (array $packageData) { + // "Discover" the protocol type + $protocolType = ProtocolDiscovery::discoverProtocolByPackageData($packageData); + + // Call super factory method + return self::createProtocolHandlerByType($protocolType); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/info/.htaccess b/application/hub/classes/factories/info/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/info/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/info/class_ConnectionInfoFactory.php b/application/hub/classes/factories/info/class_ConnectionInfoFactory.php new file mode 100644 index 000000000..fde9a37df --- /dev/null +++ b/application/hub/classes/factories/info/class_ConnectionInfoFactory.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConnectionInfoFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) ShareableInfo instance + * + * @param $protocolName Name of protocol (e.g. 'tcp') + * @param $type Connection type ('listener' or 'helper') + * @return $infoInstance An instance of a ShareableInfo class + */ + public static final function createConnectionInfoInstance ($protocolName, $type) { + // Generate key + $key = 'connection_info_' . $protocolName . '_' . $type; + + // If there is no info? + if (Registry::getRegistry()->instanceExists($key)) { + // Get info from registry + $infoInstance = Registry::getRegistry()->getInstance($key); + } else { + // Get the info instance + $infoInstance = self::createObjectByConfiguredName('connection_info_class'); + + // Add it to the registry + Registry::getRegistry()->addInstance($key, $infoInstance); + } + + // Return the instance + return $infoInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/lists/.htaccess b/application/hub/classes/factories/lists/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/lists/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/lists/class_RecipientListFactory.php b/application/hub/classes/factories/lists/class_RecipientListFactory.php new file mode 100644 index 000000000..c94b18c83 --- /dev/null +++ b/application/hub/classes/factories/lists/class_RecipientListFactory.php @@ -0,0 +1,61 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RecipientListFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton network package instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $listInstance A recipient list instance + */ + public static final function createRecipientListInstance () { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('recipient_list')) { + // Then use this instance + $listInstance = Registry::getRegistry()->getInstance('recipient_list'); + } else { + // Create a new instance + $listInstance = self::createObjectByConfiguredName('recipient_list_class'); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('recipient_list', $listInstance); + } + + // Return the instance + return $listInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/node/.htaccess b/application/hub/classes/factories/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/node/class_NodeObjectFactory.php b/application/hub/classes/factories/node/class_NodeObjectFactory.php new file mode 100644 index 000000000..39baf65e9 --- /dev/null +++ b/application/hub/classes/factories/node/class_NodeObjectFactory.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeObjectFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) NodeHelper instance + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return $nodeInstance An instance of a NodeHelper class + * @throws FactoryRequiredParameterException If not all parameters are set and no instance 'node' is set. + */ + public static final function createNodeInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) { + // Get new factory instance + $factoryInstance = new NodeObjectFactory(); + + // If there is no handler? + if (Registry::getRegistry()->instanceExists('node')) { + // Get handler from registry + $nodeInstance = Registry::getRegistry()->getInstance('node'); + } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) { + // The default node-mode is from our configuration + $nodeMode = $factoryInstance->getConfigInstance()->getConfigEntry('node_default_mode'); + + // Is the node 'mode' parameter set? + if ($requestInstance->isRequestElementSet('mode')) { + // Then use this which overrides the config entry temporarily + $nodeMode = $requestInstance->getRequestElement('mode'); + } else { + // Set it for easier re-usage + $requestInstance->setRequestElement('mode', $nodeMode); + } + + // Now convert the node-mode in a class name + $className = 'Hub' . $factoryInstance->convertToClassName($nodeMode) . 'Node'; + + // Get the node instance + $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); + + // Get a registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Set the app instance + $nodeInstance->setApplicationInstance($applicationInstance); + + // Add node-specific filters + $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); + + // Add it to the registry + Registry::getRegistry()->addInstance('node', $nodeInstance); + } else { + // Throw an exception here + throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER); + } + + // Return the instance + return $nodeInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/package/.htaccess b/application/hub/classes/factories/package/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/package/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/package/assembler/.htaccess b/application/hub/classes/factories/package/assembler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/package/assembler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/package/assembler/class_PackageAssemblerFactory.php b/application/hub/classes/factories/package/assembler/class_PackageAssemblerFactory.php new file mode 100644 index 000000000..43bccf466 --- /dev/null +++ b/application/hub/classes/factories/package/assembler/class_PackageAssemblerFactory.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageAssemblerFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton assembler instance. If no instance is found, it fill + * be generated and stored in registry, else the assembler from the + * registry will be returned. + * + * @param $packageInstance An instance of a Receivable instance + * @return $assemblerInstance An instance of a Assembler instance + */ + public static final function createAssemblerInstance (Receivable $packageInstance) { + // If there is no assembler? + if (Registry::getRegistry()->instanceExists('package_assembler')) { + // Get assembler from registry + $assemblerInstance = Registry::getRegistry()->getInstance('package_assembler'); + } else { + // Get the assembler instance + $assemblerInstance = self::createObjectByConfiguredName('package_assembler_class', array($packageInstance)); + + // Add it to the registry + Registry::getRegistry()->addInstance('package_assembler', $assemblerInstance); + } + + // Return the instance + return $assemblerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/package/class_NetworkPackageFactory.php b/application/hub/classes/factories/package/class_NetworkPackageFactory.php new file mode 100644 index 000000000..725c6768b --- /dev/null +++ b/application/hub/classes/factories/package/class_NetworkPackageFactory.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkPackageFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton network package instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $packageInstance A network package instance + */ + public static final function createNetworkPackageInstance () { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('network_package')) { + // Then use this instance + $packageInstance = Registry::getRegistry()->getInstance('network_package'); + } else { + /* + * Prepare the compressor for our package, ZLIB should be fine but we + * keep it open here so you can experiment with the settings and don't + * need to touch this code. + */ + $compressorInstance = self::createObjectByConfiguredName('raw_package_compressor_class'); + + // Prepare the decorator compressor (for later flawless and easy updates) + $compressorInstance = self::createObjectByConfiguredName('deco_package_compressor_class', array($compressorInstance)); + + /* + * Now prepare the network package for delivery so only need to do this + * once just before the "big announcement loop". + */ + $packageInstance = self::createObjectByConfiguredName('network_package_class', array($compressorInstance)); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('network_package', $packageInstance); + } + + // Return the instance + return $packageInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/package/fragmenter/.htaccess b/application/hub/classes/factories/package/fragmenter/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/package/fragmenter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/package/fragmenter/class_FragmenterFactory.php b/application/hub/classes/factories/package/fragmenter/class_FragmenterFactory.php new file mode 100644 index 000000000..53ccc271a --- /dev/null +++ b/application/hub/classes/factories/package/fragmenter/class_FragmenterFactory.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FragmenterFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton fragmenter instance. If no instance is found, it fill + * be generated and stored in registry, else the fragmenter from the + * registry will be returned. + * + * @param $fragmenterType The fragmenter's type + * @return $fragmenterInstance A fragmenter instance + */ + public static final function createFragmenterInstance ($fragmenterType) { + // If there is no fragmenter? + if (Registry::getRegistry()->instanceExists($fragmenterType . '_fragmenter')) { + // Get fragmenter from registry + $fragmenterInstance = Registry::getRegistry()->getInstance($fragmenterType . '_fragmenter'); + } else { + // Get the fragmenter instance + $fragmenterInstance = self::createObjectByConfiguredName($fragmenterType . '_fragmenter_class'); + + // Add it to the registry + Registry::getRegistry()->addInstance($fragmenterType . '_fragmenter', $fragmenterInstance); + } + + // Return the instance + return $fragmenterInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/producer/.htaccess b/application/hub/classes/factories/producer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/producer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/producer/class_ProducerFactory.php b/application/hub/classes/factories/producer/class_ProducerFactory.php new file mode 100644 index 000000000..91a6f9b1e --- /dev/null +++ b/application/hub/classes/factories/producer/class_ProducerFactory.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ProducerFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton producer instance. If no instance is found, it fill + * be generated and stored in registry, else the producer from the + * registry will be returned. + * + * @param $configEntry A configuration entry naming the real class' name + * @parasm $producerType Type of the producer, can be 'key', 'test_unit', etc. + * @return $producerInstance A producer instance + */ + public static final function createProducerInstance ($configEntry, $producerType) { + // If there is no producer? + if (Registry::getRegistry()->instanceExists($producerType . '_producer')) { + // Get producer from registry + $producerInstance = Registry::getRegistry()->getInstance($producerType . '_producer'); + } else { + // Get the producer instance + $producerInstance = self::createObjectByConfiguredName($configEntry); + + // Add it to the registry + Registry::getRegistry()->addInstance($producerType . '_producer', $producerInstance); + } + + // Return the instance + return $producerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/registry/.htaccess b/application/hub/classes/factories/registry/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/registry/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/registry/class_ObjectTypeRegistryFactory.php b/application/hub/classes/factories/registry/class_ObjectTypeRegistryFactory.php new file mode 100644 index 000000000..23dae6b51 --- /dev/null +++ b/application/hub/classes/factories/registry/class_ObjectTypeRegistryFactory.php @@ -0,0 +1,59 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ObjectTypeRegistryFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton object type regsitry. + * + * @return $registryInstance A registry for object types + */ + public static final function createObjectTypeRegistryInstance () { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('object_type_registry')) { + // Then use this instance + $registryInstance = Registry::getRegistry()->getInstance('object_type_registry'); + } else { + // Now prepare the tags instance + $registryInstance = self::createObjectByConfiguredName('node_object_type_registry_class'); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('object_type_registry', $registryInstance); + } + + // Return the instance + return $registryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/resolver/.htaccess b/application/hub/classes/factories/resolver/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/resolver/class_ProtocolResolverFactory.php b/application/hub/classes/factories/resolver/class_ProtocolResolverFactory.php new file mode 100644 index 000000000..c2e4fe424 --- /dev/null +++ b/application/hub/classes/factories/resolver/class_ProtocolResolverFactory.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ProtocolResolverFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) ProtocolResolver instance + * + * @return $resolverInstance An instance of a ProtocolResolver class + */ + public static final function createResolverFromConfiguredProtocol () { + // Get the configured protocol + $protocolName = FrameworkConfiguration::getSelfInstance()->getConfigEntry('hub_communication_protocol_type'); + + // If there is no handler? + if (Registry::getRegistry()->instanceExists($protocolName . '_protocol_resolver')) { + // Get handler from registry + $resolverInstance = Registry::getRegistry()->getInstance($protocolName . '_protocol_resolver'); + } else { + // Get the handler instance + $resolverInstance = self::createObjectByConfiguredName($protocolName . '_protocol_resolver_class'); + + // Add it to the registry + Registry::getRegistry()->addInstance($protocolName . '_protocol_resolver', $resolverInstance); + } + + // Return the instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/scanner/.htaccess b/application/hub/classes/factories/scanner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/scanner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/scanner/class_ScannerObjectFactory.php b/application/hub/classes/factories/scanner/class_ScannerObjectFactory.php new file mode 100644 index 000000000..d6f0129f2 --- /dev/null +++ b/application/hub/classes/factories/scanner/class_ScannerObjectFactory.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ScannerObjectFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) Scanner instance + * + * @param $taskInstance An instance of a class with an Taskable interface + * @return $sourceInstance An instance of a Scanner class + */ + public static final function createScannerInstance (Taskable $taskInstance) { + // Get new factory instance + $factoryInstance = new ScannerObjectFactory(); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Get scanner type for given task instance by searching it in task handler + $scannerType = $handlerInstance->searchTask($taskInstance); + + // Only let registered tasks pass + assert(!empty($scannerType)); + + // If there is no handler? + if (Registry::getRegistry()->instanceExists('scanner_' . $scannerType)) { + // Get handler from registry + $scannerInstance = Registry::getRegistry()->getInstance('scanner_' . $scannerType); + } else { + // Get the scanner instance + $scannerInstance = ObjectFactory::createObjectByConfiguredName($scannerType); + + // Add it to the registry + Registry::getRegistry()->addInstance('scanner_' . $scannerType, $scannerInstance); + } + + // Return the instance + return $scannerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/socket/.htaccess b/application/hub/classes/factories/socket/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php new file mode 100644 index 000000000..42e7a7af6 --- /dev/null +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates a valid socket resource from given packae data and protocol + * + * @param $packageData Raw package data + * @param $protocolInstance An instance of a HandleableProtocol class + * @return $socketResource Socket resource + */ + public static function createSocketFromPackageData (array $packageData, HandleableProtocol $protocolInstance) { + // Get an instance + $factoryInstance = new SocketFactory(); + + // Construct registry key + $registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]; + + // Debug message + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to find a socket with registryKey=' . $registryKey); + + // Is the key there? + if (Registry::getRegistry()->instanceExists($registryKey)) { + // Get container instance + $containerInstance = Registry::getRegistry()->getInstance($registryKey); + + // Get socket back + $socketResource = $containerInstance->getSocketResource(); + + // Debug message + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.'); + } else { + // Construct configuration entry for object factory and get it + $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolInstance->getProtocolName() . '_connection_helper_class'); + + // Debug message + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Going to use class ' . $className . ' for creating a socket resource ...'); + + // And call the static method + $socketResource = call_user_func($className . '::createConnectionFromPackageData', $packageData); + + // Debug message + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Created socket ' . $socketResource . '(' . gettype($socketResource) . ') from class ' . $className . '.'); + + // Construct container class, this won't be reached if an exception is thrown + $containerInstance = self::CreateObjectByConfiguredName('socket_container_class', array($socketResource, NULL, $packageData)); + + // Register it with the registry + Registry::getRegistry()->addInstance($registryKey, $containerInstance); + + // Debug message + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Socket is now registered in registry.'); + } + + // Return the resource + return $socketResource; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/source/.htaccess b/application/hub/classes/factories/source/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/source/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/source/units/.htaccess b/application/hub/classes/factories/source/units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/source/units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/source/units/class_UnitSourceFactory.php b/application/hub/classes/factories/source/units/class_UnitSourceFactory.php new file mode 100644 index 000000000..dcb967c1b --- /dev/null +++ b/application/hub/classes/factories/source/units/class_UnitSourceFactory.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnitSourceFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable and singleton unit source + * + * @param $unitType Type of the unit source + * @return $sourceInstance A UnitSource class instance + */ + public static final function createUnitSourceInstance ($unitType) { + // Do we have cache? + if (!Registry::getRegistry()->instanceExists($unitType . '_unit_source')) { + // Then construct the class' configuraton entry + $className = '' . $unitType . '_unit_source_class'; + + // Get a class from that configuration entry + $sourceInstance = self::createObjectByConfiguredName($className); + + // Add it to the registry + Registry::getRegistry()->addInstance($unitType . '_unit_source', $sourceInstance); + } else { + // Get it from registry + $sourceInstance = Registry::getRegistry()->getInstance($unitType . '_unit_source'); + } + + // For any purposes, return the source instance + return $sourceInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/source/url/.htaccess b/application/hub/classes/factories/source/url/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/source/url/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/source/url/class_UrlSourceObjectFactory.php b/application/hub/classes/factories/source/url/class_UrlSourceObjectFactory.php new file mode 100644 index 000000000..fe2025fab --- /dev/null +++ b/application/hub/classes/factories/source/url/class_UrlSourceObjectFactory.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UrlSourceObjectFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) UrlSource instance + * + * @param $taskInstance An instance of a class with an Taskable interface + * @return $sourceInstance An instance of a UrlSource class + */ + public static final function createUrlSourceInstance (Taskable $taskInstance) { + // Get new factory instance + $factoryInstance = new UrlSourceObjectFactory(); + + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Get source type by looking for given task instance in task handler + $sourceType = $handlerInstance->searchTask($taskInstance); + + // Only let registered tasks pass + assert(!empty($sourceType)); + + // If there is no handler? + if (Registry::getRegistry()->instanceExists('source_' . $sourceType)) { + // Get handler from registry + $sourceInstance = Registry::getRegistry()->getInstance('source_' . $sourceType); + } else { + // Get the source instance + $sourceInstance = ObjectFactory::createObjectByConfiguredName($sourceType . '_class'); + + // Add it to the registry + Registry::getRegistry()->addInstance('source_' . $sourceType, $sourceInstance); + } + + // Return the instance + return $sourceInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/states/.htaccess b/application/hub/classes/factories/states/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/communicator/.htaccess b/application/hub/classes/factories/states/communicator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/communicator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php b/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php new file mode 100644 index 000000000..d0fbf8342 --- /dev/null +++ b/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014, 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CommunicatorStateFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable communicator state and sets it in the + * given communicator instance. + * + * @param $stateName Name of the state + * @param $communicatorInstance A Communicator class instance + * @return $stateInstance A Stateable class instance + */ + public static final function createCommunicatorStateInstanceByName ($stateName, Communicator $communicatorInstance) { + // Then construct the class' configuraton entry + $className = 'communicator_' . $stateName . '_state_class'; + + // Get a class from that configuration entry + $stateInstance = self::createObjectByConfiguredName($className, array($communicatorInstance)); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Communicator state has changed from ' . $communicatorInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Once we have that state, set it in the communicator instance + $communicatorInstance->setStateInstance($stateInstance); + + // Update communicator data + $communicatorInstance->updateCommunicatorData(); + + // For any purposes, return the state instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/states/crawler/.htaccess b/application/hub/classes/factories/states/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/crawler/class_CrawlerStateFactory.php b/application/hub/classes/factories/states/crawler/class_CrawlerStateFactory.php new file mode 100644 index 000000000..4b0eb52fb --- /dev/null +++ b/application/hub/classes/factories/states/crawler/class_CrawlerStateFactory.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014, 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerStateFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable crawler state and sets it in the + * given crawler instance. + * + * @param $stateName Name of the state + * @return $stateInstance A Stateable class instance + */ + public static final function createCrawlerStateInstanceByName ($stateName) { + // Then construct the class' configuraton entry + $className = 'crawler_' . $stateName . '_state_class'; + + // Get a class from that configuration entry + $stateInstance = self::createObjectByConfiguredName($className); + + // Get crawler instance + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Crawler state has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Once we have that state, set it in the crawler instance + $crawlerInstance->setStateInstance($stateInstance); + + // Update crawler data + $crawlerInstance->updateCrawlerData(); + + // For any purposes, return the state instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/states/cruncher/.htaccess b/application/hub/classes/factories/states/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/cruncher/class_CruncherStateFactory.php b/application/hub/classes/factories/states/cruncher/class_CruncherStateFactory.php new file mode 100644 index 000000000..8701aa589 --- /dev/null +++ b/application/hub/classes/factories/states/cruncher/class_CruncherStateFactory.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherStateFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable cruncher state and sets it in the + * given cruncher instance. + * + * @param $stateName Name of the state + * @param $cruncherInstance A CruncherHelper class instance + * @return $stateInstance A Stateable class instance + */ + public static final function createCruncherStateInstanceByName ($stateName) { + // Then construct the class' configuraton entry + $className = 'cruncher_' . $stateName . '_state_class'; + + // Get cruncher instance from registry + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Get a class from that configuration entry + $stateInstance = self::createObjectByConfiguredName($className); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Cruncher state has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Once we have that state, set it in the cruncher instance + $cruncherInstance->setStateInstance($stateInstance); + + // For any purposes, return the state instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/states/dht/.htaccess b/application/hub/classes/factories/states/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/dht/class_DhtStateFactory.php b/application/hub/classes/factories/states/dht/class_DhtStateFactory.php new file mode 100644 index 000000000..dfa1eade3 --- /dev/null +++ b/application/hub/classes/factories/states/dht/class_DhtStateFactory.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtStateFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable DHT state and sets it in the + * given DHT instance. + * + * @param $stateName Name of the state + * @param $dhtInstance A Distributable class instance + * @return $stateInstance A Stateable class instance + */ + public static final function createDhtStateInstanceByName ($stateName, Distributable $dhtInstance) { + // Then construct the class' configuraton entry + $className = 'dht_' . $stateName . '_state_class'; + + // Get a class from that configuration entry + $stateInstance = self::createObjectByConfiguredName($className, array($dhtInstance)); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: DHT state has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Once we have that state, set it in the DHT instance + $dhtInstance->setStateInstance($stateInstance); + + // Update DHT data + $dhtInstance->updateDhtData(); + + // For any purposes, return the state instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/states/miner/.htaccess b/application/hub/classes/factories/states/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/miner/class_MinerStateFactory.php b/application/hub/classes/factories/states/miner/class_MinerStateFactory.php new file mode 100644 index 000000000..2b2a7e02f --- /dev/null +++ b/application/hub/classes/factories/states/miner/class_MinerStateFactory.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerStateFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable miner state and sets it in the + * given miner instance. + * + * @param $stateName Name of the state + * @return $stateInstance A Stateable class instance + */ + public static final function createMinerStateInstanceByName ($stateName) { + // Then construct the class' configuraton entry + $className = 'miner_' . $stateName . '_state_class'; + + // Get miner instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Get a class from that configuration entry + $stateInstance = self::createObjectByConfiguredName($className); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Miner state has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Once we have that state, set it in the miner instance + $minerInstance->setStateInstance($stateInstance); + + // For any purposes, return the state instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/states/node/.htaccess b/application/hub/classes/factories/states/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/node/class_NodeStateFactory.php b/application/hub/classes/factories/states/node/class_NodeStateFactory.php new file mode 100644 index 000000000..46212da4f --- /dev/null +++ b/application/hub/classes/factories/states/node/class_NodeStateFactory.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeStateFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a configurable node state and sets it in the + * given node instance. + * + * @param $stateName Name of the state + * @param $nodeInstance An instance of a NodeHelper class (optional) + * @return $stateInstance A Stateable class instance + */ + public static final function createNodeStateInstanceByName ($stateName, NodeHelper $nodeInstance = NULL) { + // Then construct the class' configuraton entry + $className = 'node_' . $stateName . '_state_class'; + + // Is the node instance set? + if (is_null($nodeInstance)) { + // Get node instance from registry + $nodeInstance = NodeObjectFactory::createNodeInstance(); + } // END - if + + // Get a class from that configuration entry + $stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance)); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('NODE-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Node state has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Once we have that state, set it in the node instance + $nodeInstance->setStateInstance($stateInstance); + + // Update node data + $nodeInstance->updateNodeData(); + + // For any purposes, return the state instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/states/peer/.htaccess b/application/hub/classes/factories/states/peer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/states/peer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/states/peer/class_PeerStateFactory.php b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php new file mode 100644 index 000000000..dea14b8ed --- /dev/null +++ b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php @@ -0,0 +1,160 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PeerStateFactory extends ObjectFactory { + /** + * Static lookup table instance + */ + private static $tableInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton getter for lookup table instances, kept public if we need this + * table somewhere else. + * + * @return $tableInstance An instance of a lookup table + */ + public static final function getTableInstance () { + // Is the instance null? + if (is_null(self::$tableInstance)) { + // Get a new one + self::$tableInstance = self::createObjectByConfiguredName('peer_state_lookup_db_wrapper_class'); + } // END - if + + // Return it + return self::$tableInstance; + } + + /** + * Creates a peer state instance based on errorCode if no entry is found in the lookup table + * for the peer given in $packageData 'sender' element or it changes the state if it differs + * from current state. + * + * @param $helperInstance An instance of a ConnectionHelper class + * @param $packageData Raw package data + * @param $socketResource A valid socket resource + * @param $errorCode The last error code + * @return $stateInstance A Stateable class instance + */ + public static final function createPeerStateInstanceBySocketStatusCode (ConnectionHelper $helperInstance, array $packageData, $socketResource, $errorCode) { + // Init state instance, this is better coding practice + $stateInstance = NULL; + + // So first we need our lookup table + $tableInstance = self::getTableInstance(); + + /* + * Now try to purge old entries before looking an entry up. This shall + * make it sure that only accurate entries can be found. + */ + try { + // Purge old entries + $tableInstance->purgeOldEntriesBySocketResource($socketResource); + } catch (InvalidSocketException $e) { + // Just log all errors + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Purging of old entries failed. Message from exception: ' . $e->getMessage()); + } + + // Do we have an entry? + if ($tableInstance->isSenderNewPeer($packageData)) { + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] errorCode=' . $errorCode); + + // Register the new peer with its session id + $tableInstance->registerPeerByPackageData($packageData, $socketResource); + + /* + * It is a new peer so create the state instance based on error + * code and get an instance from it. + */ + $stateInstance = self::createObjectByConfiguredName('peer_' . $errorCode . '_state_class'); + + // And register it with the lookup table + $tableInstance->registerPeerState($stateInstance, $packageData); + } elseif ($tableInstance->isSamePeerState($helperInstance, $packageData)) { + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state unchanged, re-generating old state ...'); + + /* + * The peer's state has noot changed, still we have to return a + * state instance, so generate it here. + */ + $stateInstance = self::createPeerStateInstanceByName($helperInstance->getPrintableState(), $helperInstance); + } else { + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Updating peer state ...'); + + /* + * It is an already known peer but with a changed state. So first + * get an instance of the state. + */ + $stateInstance = self::createObjectByConfiguredName('peer_' . $errorCode . '_state_class'); + + // The peer's state has changed, update database now + $tableInstance->registerPeerState($stateInstance, $packageData); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); + + // Set the state in the helper + $helperInstance->setStateInstance($stateInstance); + + // For any purposes, return the state instance + return $stateInstance; + } + + /** + * Creates an instance of a configurable peer state and sets it in the + * given peer instance. + * + * @param $stateName Name of the state + * @param $helperInstance A ConnectionHelper class instance + * @return $stateInstance A Stateable class instance + */ + public static final function createPeerStateInstanceByName ($stateName, ConnectionHelper $helperInstance) { + // Get a class from a configuration entry + $stateInstance = self::createObjectByConfiguredName('peer_' . $stateName . '_state_class', array($helperInstance)); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); + + // Once we have that state, set it in the peer instance + $helperInstance->setStateInstance($stateInstance); + + // For any purposes, return the state instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/factories/tags/.htaccess b/application/hub/classes/factories/tags/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/factories/tags/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/factories/tags/class_PackageTagsFactory.php b/application/hub/classes/factories/tags/class_PackageTagsFactory.php new file mode 100644 index 000000000..1fde988bf --- /dev/null +++ b/application/hub/classes/factories/tags/class_PackageTagsFactory.php @@ -0,0 +1,61 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageTagsFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton network package instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $packageInstance A network package instance + */ + public static final function createPackageTagsInstance () { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('package_tags')) { + // Then use this instance + $packageInstance = Registry::getRegistry()->getInstance('package_tags'); + } else { + // Now prepare the tags instance + $packageInstance = self::createObjectByConfiguredName('package_tags_class'); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('package_tags', $packageInstance); + } + + // Return the instance + return $packageInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/feature/.htaccess b/application/hub/classes/feature/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/feature/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/feature/hubcoin_reward/.htaccess b/application/hub/classes/feature/hubcoin_reward/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/feature/hubcoin_reward/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php new file mode 100644 index 000000000..5c987420d --- /dev/null +++ b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubcoinRewardFeature extends BaseFeature implements Feature { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Feature class and prepares it for usage + * + * @return $featureInstance An instance of this Feature class + */ + public final static function createHubcoinRewardFeature () { + // Get a new instance + $featureInstance = new HubcoinRewardFeature(); + + // Return the prepared instance + return $featureInstance; + } + + /** + * Checks whether this feature can be made available to other classes. + * + * @return $isAvailable Whether this feature is available + */ + public function isFeatureAvailable () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); + + // Testing this feature is pretty simple: + $isAvailable = (($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === TRUE) && (extension_loaded('scrypt')) && (is_callable('scrypt'))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable))); + + // Return status + return $isAvailable; + } + + /////////////////////////////////////////////////////////////////////////// + // Feature methods + /////////////////////////////////////////////////////////////////////////// + + /** + * Feature method 'generateHash' + * + * @param $data Data to hash + * @return $hash Finished hash + */ + public function featureMethodGenerateHash ($data) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: data()=%d - CALLED!', __METHOD__, __LINE__, strlen($data))); + + // Make sure the feature is available + assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); + + // Call inner class + $hash = Scrypt::hashScrypt($data); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: hash=%s - EXIT!', __METHOD__, __LINE__, $hash)); + + // Return generated hash + return $hash; + } + + /** + * Feature method 'checkHash' + * + * @param $data Data to check hash for + * @param $hash Previously generated hash for valdiation + * @return $isValid Whether the given hash matches a new one from given data + */ + public function featureMethodCheckHash ($data, $hash) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: data()=%d,hash=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $hash)); + + // Make sure the feature is available + assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); + + // Determine it + $isValid = Scrypt::checkScrypt($data, $hash); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: isValid=%d - EXIT!', __METHOD__, __LINE__, intval($isValid))); + + // Return status + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/.htaccess b/application/hub/classes/filter/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/activation/.htaccess b/application/hub/classes/filter/activation/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/activation/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/activation/node/.htaccess b/application/hub/classes/filter/activation/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/activation/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/activation/node/class_NodeActivation b/application/hub/classes/filter/activation/node/class_NodeActivation new file mode 100644 index 000000000..698247588 --- /dev/null +++ b/application/hub/classes/filter/activation/node/class_NodeActivation @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubActivation???Filter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createHubActivation???Filter () { + // Get a new instance + $filterInstance = new HubActivation???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/activation/node/class_NodeActivationAnnouncementFilter.php b/application/hub/classes/filter/activation/node/class_NodeActivationAnnouncementFilter.php new file mode 100644 index 000000000..60b90d1a8 --- /dev/null +++ b/application/hub/classes/filter/activation/node/class_NodeActivationAnnouncementFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeActivationAnnouncementFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeActivationAnnouncementFilter () { + // Get a new instance + $filterInstance = new NodeActivationAnnouncementFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Prepare a self-test task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_announcement_task_class'); + + // Register it + $handlerInstance->registerTask('announcement', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/apt-proxy/.htaccess b/application/hub/classes/filter/apt-proxy/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/apt-proxy/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/apt-proxy/class_AptProxyInitializationFilter.php b/application/hub/classes/filter/apt-proxy/class_AptProxyInitializationFilter.php new file mode 100644 index 000000000..4337e190d --- /dev/null +++ b/application/hub/classes/filter/apt-proxy/class_AptProxyInitializationFilter.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyInitializationFilter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createAptProxyInitializationFilter () { + // Get a new instance + $filterInstance = new AptProxyInitializationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get an instance + $proxyInstance = ObjectFactory::createObjectByConfiguredName('node_console_apt_proxy_class'); + + // Get a registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Set the app instance + $proxyInstance->setApplicationInstance($applicationInstance); + + // Add apt-proxy-specific filters + $proxyInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); + + // Set the apt_proxy instance in registry + Registry::getRegistry()->addInstance('apt_proxy', $proxyInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php b/application/hub/classes/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php new file mode 100644 index 000000000..816a31a01 --- /dev/null +++ b/application/hub/classes/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyPhpRequirementsFilter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createAptProxyPhpRequirementsFilter () { + // Get a new instance + $filterInstance = new AptProxyPhpRequirementsFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If a required PHP function is not available + * @todo Add more test and try to add an extra message to the thrown exception + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // By default, the requirement check is passed and zero checks are failed + $checkPassed = TRUE; + $checksFailed = 0; + + // Socket support is essential... + if (!function_exists('socket_create')) { + // Test failed + $checkPassed = FALSE; + $checksFailed++; + } // END -if + + // Are all tests passed? + if ($checkPassed === FALSE) { + // Throw an exception + throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/apt-proxy/class_AptProxyWelcomeTeaserFilter.php b/application/hub/classes/filter/apt-proxy/class_AptProxyWelcomeTeaserFilter.php new file mode 100644 index 000000000..2e9d815ff --- /dev/null +++ b/application/hub/classes/filter/apt-proxy/class_AptProxyWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyWelcomeTeaserFilter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createAptProxyWelcomeTeaserFilter () { + // Get a new instance + $filterInstance = new AptProxyWelcomeTeaserFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo Handle over the $responseInstance to outputConsoleTeaser() + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); + + // Now output the teaser + $proxyInstance->outputConsoleTeaser(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/.htaccess b/application/hub/classes/filter/bootstrap/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/bootstrap/apt-proxy/.htaccess b/application/hub/classes/filter/bootstrap/apt-proxy/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/apt-proxy/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrap b/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrap new file mode 100644 index 000000000..008987a8f --- /dev/null +++ b/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrap @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyBootstrap???Filter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createAptProxyBootstrap???Filter () { + // Get a new instance + $filterInstance = new AptProxyBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get apt-proxy instance + $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrapExtraBootstrappingFilter.php b/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrapExtraBootstrappingFilter.php new file mode 100644 index 000000000..9fa0b9a80 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrapExtraBootstrappingFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyBootstrapExtraBootstrappingFilter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createAptProxyBootstrapExtraBootstrappingFilter () { + // Get a new instance + $filterInstance = new AptProxyBootstrapExtraBootstrappingFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $proxyInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get apt-proxy instance + $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); + + // Do some extra bootstrapping steps + $proxyInstance->doBootstrapping(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrapGenericActivationFilter.php b/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrapGenericActivationFilter.php new file mode 100644 index 000000000..34021a606 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/apt-proxy/class_AptProxyBootstrapGenericActivationFilter.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyBootstrapGenericActivationFilter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createAptProxyBootstrapGenericActivationFilter () { + // Get a new instance + $filterInstance = new AptProxyBootstrapGenericActivationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Maybe we want to do somthing more here? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a apt-proxy instance + $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); + + // Set the flag + $proxyInstance->enableIsActive(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: apt-proxy has been activated.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/chat/.htaccess b/application/hub/classes/filter/bootstrap/chat/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/chat/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrap b/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrap new file mode 100644 index 000000000..9047bdcbb --- /dev/null +++ b/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrap @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatBootstrap???Filter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createChatBootstrap???Filter () { + // Get a new instance + $filterInstance = new ChatBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get chat instance + $chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrapExtraBootstrappingFilter.php b/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrapExtraBootstrappingFilter.php new file mode 100644 index 000000000..cc7865c57 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrapExtraBootstrappingFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatBootstrapExtraBootstrappingFilter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createChatBootstrapExtraBootstrappingFilter () { + // Get a new instance + $filterInstance = new ChatBootstrapExtraBootstrappingFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $chatInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get chat instance + $chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Do some extra bootstrapping steps + $chatInstance->doBootstrapping(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php b/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php new file mode 100644 index 000000000..afe2bd455 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatBootstrapGenericActivationFilter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createChatBootstrapGenericActivationFilter () { + // Get a new instance + $filterInstance = new ChatBootstrapGenericActivationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Maybe we want to do somthing more here? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a chat instance + $chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Set the flag + $chatInstance->enableIsActive(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The chat console has been activated.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/class_HubBootstrap b/application/hub/classes/filter/bootstrap/class_HubBootstrap new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/filter/bootstrap/class_HubBootstrap @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/filter/bootstrap/crawler/.htaccess b/application/hub/classes/filter/bootstrap/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrap b/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrap new file mode 100644 index 000000000..f0c3fcf4c --- /dev/null +++ b/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrap @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerBootstrap???Filter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCrawlerBootstrap???Filter () { + // Get a new instance + $filterInstance = new CrawlerBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get crawler instance + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrapExtraBootstrappingFilter.php b/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrapExtraBootstrappingFilter.php new file mode 100644 index 000000000..b4c6d8cac --- /dev/null +++ b/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrapExtraBootstrappingFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerBootstrapExtraBootstrappingFilter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCrawlerBootstrapExtraBootstrappingFilter () { + // Get a new instance + $filterInstance = new CrawlerBootstrapExtraBootstrappingFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $crawlerInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get crawler instance + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Do some extra bootstrapping steps + $crawlerInstance->doBootstrapping(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrapGenericActivationFilter.php b/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrapGenericActivationFilter.php new file mode 100644 index 000000000..cfe1b0d20 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/crawler/class_CrawlerBootstrapGenericActivationFilter.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerBootstrapGenericActivationFilter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCrawlerBootstrapGenericActivationFilter () { + // Get a new instance + $filterInstance = new CrawlerBootstrapGenericActivationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Maybe we want to do somthing more here? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a crawler instance + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Set the flag + $crawlerInstance->enableIsActive(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The crawler has been activated.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/cruncher/.htaccess b/application/hub/classes/filter/bootstrap/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrap b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrap new file mode 100644 index 000000000..312c64940 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrap @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherBootstrap???Filter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCruncherBootstrap???Filter () { + // Get a new instance + $filterInstance = new CruncherBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get cruncher instance + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php new file mode 100644 index 000000000..2f7286d87 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherBootstrapBufferQueueInitializerFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCruncherBootstrapBufferQueueInitializerFilter () { + // Get a new instance + $filterInstance = new CruncherBootstrapBufferQueueInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get cruncher instance + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Init all buffer queues + $cruncherInstance->initBufferQueues(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapExtraBootstrappingFilter.php b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapExtraBootstrappingFilter.php new file mode 100644 index 000000000..1d35f5c2c --- /dev/null +++ b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapExtraBootstrappingFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherBootstrapExtraBootstrappingFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCruncherBootstrapExtraBootstrappingFilter () { + // Get a new instance + $filterInstance = new CruncherBootstrapExtraBootstrappingFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $cruncherInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get cruncher instance + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Do some extra bootstrapping steps + $cruncherInstance->doBootstrapping(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php new file mode 100644 index 000000000..72a995949 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherBootstrapGenericActivationFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCruncherBootstrapGenericActivationFilter () { + // Get a new instance + $filterInstance = new CruncherBootstrapGenericActivationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Maybe we want to do somthing more here? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a cruncher instance + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Set the flag + $cruncherInstance->enableIsActive(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The cruncher has been activated.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/miner/.htaccess b/application/hub/classes/filter/bootstrap/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrap b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrap new file mode 100644 index 000000000..b80cc4de2 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrap @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerBootstrap???Filter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createMinerBootstrap???Filter () { + // Get a new instance + $filterInstance = new MinerBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get miner instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php new file mode 100644 index 000000000..3998123b8 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerBootstrapBufferQueueInitializerFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createMinerBootstrapBufferQueueInitializerFilter () { + // Get a new instance + $filterInstance = new MinerBootstrapBufferQueueInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get miner instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Init all buffer queues + $minerInstance->initBufferQueues(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php new file mode 100644 index 000000000..7919af35b --- /dev/null +++ b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerBootstrapExtraBootstrappingFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createMinerBootstrapExtraBootstrappingFilter () { + // Get a new instance + $filterInstance = new MinerBootstrapExtraBootstrappingFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $minerInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get miner instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Do some extra bootstrapping steps + $minerInstance->doBootstrapping(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php new file mode 100644 index 000000000..08d0c7cb0 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerBootstrapGenericActivationFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createMinerBootstrapGenericActivationFilter () { + // Get a new instance + $filterInstance = new MinerBootstrapGenericActivationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo Maybe we want to do somthing more here? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a miner instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Set the flag + $minerInstance->enableIsActive(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The miner has been activated.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/node/.htaccess b/application/hub/classes/filter/bootstrap/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/bootstrap/node/class_NodeBootstrap b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrap new file mode 100644 index 000000000..d0963daf0 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrap @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeBootstrap???Filter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createNodeBootstrap???Filter () { + // Get a new instance + $filterInstance = new NodeBootstrap???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php new file mode 100644 index 000000000..5ddc68ca6 --- /dev/null +++ b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeBootstrapExtraBootstrappingFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeBootstrapExtraBootstrappingFilter () { + // Get a new instance + $filterInstance = new NodeBootstrapExtraBootstrappingFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Do some extra bootstrapping steps + $nodeInstance->doBootstrapping(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php new file mode 100644 index 000000000..5c31c17ba --- /dev/null +++ b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeBootstrapGenerateNodeIdFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeBootstrapGenerateNodeIdFilter () { + // Get a new instance + $filterInstance = new NodeBootstrapGenerateNodeIdFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + /* + * Acquire a hub-id. This step generates on first launch a new one and + * on any later launches it will restore the hub-id from the database. + * A passed 'nickname=xxx' argument will be used to add some + * 'personality' to the hub. + */ + $nodeInstance->bootstrapAcquireNodeId($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php new file mode 100644 index 000000000..f7f3c392d --- /dev/null +++ b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeBootstrapGeneratePrivateKeyFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createNodeBootstrapGeneratePrivateKeyFilter () { + // Get a new instance + $filterInstance = new NodeBootstrapGeneratePrivateKeyFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + /* + * Generate the private key. This will be stored along with the other + * node data. + */ + $nodeInstance->bootstrapGeneratePrivateKey(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php new file mode 100644 index 000000000..63a4ed98d --- /dev/null +++ b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeBootstrapGenerateSessionIdFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeBootstrapGenerateSessionIdFilter () { + // Get a new instance + $filterInstance = new NodeBootstrapGenerateSessionIdFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + /* + * Generate the session id which will only be stored in RAM and kept for + * the whole "session". + */ + $nodeInstance->bootstrapGenerateSessionId(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php new file mode 100644 index 000000000..a6a81669f --- /dev/null +++ b/application/hub/classes/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeBootstrapListenerPoolFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeBootstrapListenerPoolFilter () { + // Get a new instance + $filterInstance = new NodeBootstrapListenerPoolFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Now do something + $nodeInstance->initializeListenerPool(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/chat/.htaccess b/application/hub/classes/filter/chat/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/chat/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/chat/class_ChatInitializationFilter.php b/application/hub/classes/filter/chat/class_ChatInitializationFilter.php new file mode 100644 index 000000000..e47efbbc8 --- /dev/null +++ b/application/hub/classes/filter/chat/class_ChatInitializationFilter.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatInitializationFilter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createChatInitializationFilter () { + // Get a new instance + $filterInstance = new ChatInitializationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get an instance + $chatInstance = ObjectFactory::createObjectByConfiguredName('node_console_chat_class'); + + // Get a registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Set the app instance + $chatInstance->setApplicationInstance($applicationInstance); + + // Add chat-specific filters + $chatInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); + + // Set the chat instance in registry + Registry::getRegistry()->addInstance('chat', $chatInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/chat/class_ChatPhpRequirementsFilter.php b/application/hub/classes/filter/chat/class_ChatPhpRequirementsFilter.php new file mode 100644 index 000000000..e794a6635 --- /dev/null +++ b/application/hub/classes/filter/chat/class_ChatPhpRequirementsFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Teama + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatPhpRequirementsFilter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createChatPhpRequirementsFilter () { + // Get a new instance + $filterInstance = new ChatPhpRequirementsFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If a required PHP function is not available + * @todo Add more test and try to add an extra message to the thrown exception + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // By default, the requirement check is passed and zero checks are failed + $checkPassed = TRUE; + $checksFailed = 0; + + // Socket support is essential... + if (!function_exists('socket_create')) { + // Test failed + $checkPassed = FALSE; + $checksFailed++; + } // END -if + + // Are all tests passed? + if ($checkPassed === FALSE) { + // Throw an exception + throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/chat/class_ChatWelcomeTeaserFilter.php b/application/hub/classes/filter/chat/class_ChatWelcomeTeaserFilter.php new file mode 100644 index 000000000..c724ec9d1 --- /dev/null +++ b/application/hub/classes/filter/chat/class_ChatWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatWelcomeTeaserFilter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createChatWelcomeTeaserFilter () { + // Get a new instance + $filterInstance = new ChatWelcomeTeaserFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo Handle over the $responseInstance to outputConsoleTeaser() + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Now output the teaser + $chatInstance->outputConsoleTeaser(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_ b/application/hub/classes/filter/class_ new file mode 100644 index 000000000..a19a0646b --- /dev/null +++ b/application/hub/classes/filter/class_ @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Hub!!!???Filter extends BaseHubFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createHub!!!???Filter () { + // Get a new instance + $filterInstance = new Hub!!!???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_BaseAptProxyFilter.php b/application/hub/classes/filter/class_BaseAptProxyFilter.php new file mode 100644 index 000000000..90056ed28 --- /dev/null +++ b/application/hub/classes/filter/class_BaseAptProxyFilter.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseAptProxyFilter extends BaseHubFilter { + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_BaseChatFilter.php b/application/hub/classes/filter/class_BaseChatFilter.php new file mode 100644 index 000000000..3b29df085 --- /dev/null +++ b/application/hub/classes/filter/class_BaseChatFilter.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseChatFilter extends BaseHubFilter { + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_BaseCrawlerFilter.php b/application/hub/classes/filter/class_BaseCrawlerFilter.php new file mode 100644 index 000000000..3a964eefc --- /dev/null +++ b/application/hub/classes/filter/class_BaseCrawlerFilter.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCrawlerFilter extends BaseHubFilter { + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_BaseCruncherFilter.php b/application/hub/classes/filter/class_BaseCruncherFilter.php new file mode 100644 index 000000000..bba974144 --- /dev/null +++ b/application/hub/classes/filter/class_BaseCruncherFilter.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCruncherFilter extends BaseHubFilter { + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_BaseHubFilter.php b/application/hub/classes/filter/class_BaseHubFilter.php new file mode 100644 index 000000000..6346a60ec --- /dev/null +++ b/application/hub/classes/filter/class_BaseHubFilter.php @@ -0,0 +1,126 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubFilter extends BaseFilter { + /** + * Array with all data XML nodes (which hold the actual data) and their values + */ + protected $dataXmlNodes = array(); + + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * InvalidXmlNodeException - If an invalid XML node has been found (e.g. + * wrong/out-dated template used) + * XmlNodeMismatchException - Again might be caused by invalid XML node + * usage + * XmlParserException - If the XML message is damaged or not + * well-formed + * + * @param $messageType Type of message + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + * @todo Exceptions from renderXmlContent() are currently unhandled + */ + protected function genericProcessMessage ($messageType, array $messageData, Receivable $packageInstance) { + // Make sure the wanted element is there + assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_MESSAGE])); + assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_SENDER])); + assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_HASH])); + assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_TAGS])); + + // Get a template instance from the factory + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_' . $messageType . '_template_class'); + + // Get message content + $messageContent = $messageData[NetworkPackage::PACKAGE_CONTENT_MESSAGE]; + + // And render the XML content (aka message) + $templateInstance->renderXmlContent($messageContent); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent); + + /* + * The template system now stores all required data as 'general' + * variables, so simply get them. If there is an invalid XML node + * inside the message, the above method call will cause exceptions. + */ + foreach ($this->dataXmlNodes as $key => $dummy) { + // Call it + $value = $templateInstance->readXmlData($key); + + /* + * If value is NULL, a variable hasn't been found. This could mean + * that *this* node is running an out-dated software or the other + * peer is using an out-dated $messageType.xml template. + */ + if (is_null($value)) { + // Output a warning + self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.'); + + // Skip this part, don't write NULLs to the array + continue; + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value); + + // Set it now + $this->dataXmlNodes[$key] = $value; + } // END - foreach + + // Construct an array for pushing it on next stack + $messageArray = array( + // Message data itself + NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes, + // Message type (which is $messageType) + NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType, + // Message sender + NetworkPackage::MESSAGE_ARRAY_SENDER => $messageData[NetworkPackage::PACKAGE_CONTENT_SENDER], + // Package hash + NetworkPackage::MESSAGE_ARRAY_HASH => $messageData[NetworkPackage::PACKAGE_CONTENT_HASH], + // Package tags + NetworkPackage::MESSAGE_ARRAY_TAGS => $messageData[NetworkPackage::PACKAGE_CONTENT_TAGS], + ); + + // Push the processed message back on stack + $packageInstance->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_BaseMinerFilter.php b/application/hub/classes/filter/class_BaseMinerFilter.php new file mode 100644 index 000000000..bfad26404 --- /dev/null +++ b/application/hub/classes/filter/class_BaseMinerFilter.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMinerFilter extends BaseHubFilter { + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/class_BaseNodeFilter.php b/application/hub/classes/filter/class_BaseNodeFilter.php new file mode 100644 index 000000000..2fbb3f836 --- /dev/null +++ b/application/hub/classes/filter/class_BaseNodeFilter.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeFilter extends BaseHubFilter { + /** + * Protected constructor + * + * @param $className Real name of class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/console/.htaccess b/application/hub/classes/filter/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/console/class_Console b/application/hub/classes/filter/console/class_Console new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/filter/console/class_Console @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/filter/crawler/.htaccess b/application/hub/classes/filter/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/crawler/class_CrawlerInitializationFilter.php b/application/hub/classes/filter/crawler/class_CrawlerInitializationFilter.php new file mode 100644 index 000000000..570346eec --- /dev/null +++ b/application/hub/classes/filter/crawler/class_CrawlerInitializationFilter.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerInitializationFilter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCrawlerInitializationFilter () { + // Get a new instance + $filterInstance = new CrawlerInitializationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get an instance + $crawlerInstance = ObjectFactory::createObjectByConfiguredName('node_console_crawler_class'); + + // Get a registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Set the app instance + $crawlerInstance->setApplicationInstance($applicationInstance); + + // Add crawler-specific filters + $crawlerInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/crawler/class_CrawlerPhpRequirementsFilter.php b/application/hub/classes/filter/crawler/class_CrawlerPhpRequirementsFilter.php new file mode 100644 index 000000000..f144b03e8 --- /dev/null +++ b/application/hub/classes/filter/crawler/class_CrawlerPhpRequirementsFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Teama + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerPhpRequirementsFilter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCrawlerPhpRequirementsFilter () { + // Get a new instance + $filterInstance = new CrawlerPhpRequirementsFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If a required PHP function is not available + * @todo Add more test and try to add an extra message to the thrown exception + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // By default, the requirement check is passed and zero checks are failed + $checkPassed = TRUE; + $checksFailed = 0; + + // Socket support is essential... + if (!function_exists('socket_create')) { + // Test failed + $checkPassed = FALSE; + $checksFailed++; + } // END -if + + // Are all tests passed? + if ($checkPassed === FALSE) { + // Throw an exception + throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/crawler/class_CrawlerWelcomeTeaserFilter.php b/application/hub/classes/filter/crawler/class_CrawlerWelcomeTeaserFilter.php new file mode 100644 index 000000000..51579ddf9 --- /dev/null +++ b/application/hub/classes/filter/crawler/class_CrawlerWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerWelcomeTeaserFilter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCrawlerWelcomeTeaserFilter () { + // Get a new instance + $filterInstance = new CrawlerWelcomeTeaserFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo Handle over the $responseInstance to outputConsoleTeaser() + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Now output the teaser + $crawlerInstance->outputConsoleTeaser(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/cruncher/.htaccess b/application/hub/classes/filter/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/cruncher/class_Cruncher b/application/hub/classes/filter/cruncher/class_Cruncher new file mode 100644 index 000000000..77aca806b --- /dev/null +++ b/application/hub/classes/filter/cruncher/class_Cruncher @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Cruncher???Filter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createCruncher???Filter () { + // Get a new instance + $filterInstance = new Cruncher???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php b/application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php new file mode 100644 index 000000000..7311542db --- /dev/null +++ b/application/hub/classes/filter/cruncher/class_CruncherInitializationFilter.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherInitializationFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCruncherInitializationFilter () { + // Get a new instance + $filterInstance = new CruncherInitializationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // The default cruncher-mode is from our configuration + $cruncherMode = $this->getConfigInstance()->getConfigEntry('cruncher_default_mode'); + + // Is the cruncher 'mode' parameter set? + if ($requestInstance->isRequestElementSet('mode')) { + // Then use this which overrides the config entry temporarily + $cruncherMode = $requestInstance->getRequestElement('mode'); + } else { + // Set it for easier re-usage + $requestInstance->setRequestElement('mode', $cruncherMode); + } + + // Now convert the cruncher-mode in a class name + $className = 'Hub' . self::convertToClassName($cruncherMode) . 'Cruncher'; + + // And try to instance it + try { + // Get an instance + $cruncherInstance = ObjectFactory::createObjectByName($className); + + // Get a registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Set the app instance + $cruncherInstance->setApplicationInstance($applicationInstance); + + // Add cruncher-specific filters + $cruncherInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); + } catch (ClassNotFoundException $e) { + // This exception means, the cruncher mode is invalid. + // @TODO Can we rewrite this to app_exit() ? + $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: cruncher mode ' . $cruncherMode . ' is invalid.'); + } + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/cruncher/class_CruncherPhpRequirementsFilter.php b/application/hub/classes/filter/cruncher/class_CruncherPhpRequirementsFilter.php new file mode 100644 index 000000000..db4103372 --- /dev/null +++ b/application/hub/classes/filter/cruncher/class_CruncherPhpRequirementsFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherPhpRequirementsFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCruncherPhpRequirementsFilter () { + // Get a new instance + $filterInstance = new CruncherPhpRequirementsFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If a required PHP function is not available + * @todo Add more test and try to add an extra message to the thrown exception + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // By default, the requirement check is passed and zero checks are failed + $checkPassed = TRUE; + $checksFailed = 0; + + // Socket support is essential... + if (!function_exists('socket_create')) { + // Test failed + $checkPassed = FALSE; + $checksFailed++; + } // END -if + + // Are all tests passed? + if ($checkPassed === FALSE) { + // Throw an exception + throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/cruncher/class_CruncherWelcomeTeaserFilter.php b/application/hub/classes/filter/cruncher/class_CruncherWelcomeTeaserFilter.php new file mode 100644 index 000000000..b30d47fb8 --- /dev/null +++ b/application/hub/classes/filter/cruncher/class_CruncherWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherWelcomeTeaserFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCruncherWelcomeTeaserFilter () { + // Get a new instance + $filterInstance = new CruncherWelcomeTeaserFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo Handle over the $responseInstance to outputConsoleTeaser() + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Now output the teaser + $cruncherInstance->outputConsoleTeaser(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/miner/.htaccess b/application/hub/classes/filter/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/miner/class_Miner b/application/hub/classes/filter/miner/class_Miner new file mode 100644 index 000000000..0cf9ced60 --- /dev/null +++ b/application/hub/classes/filter/miner/class_Miner @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Miner???Filter extends BaseminerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createMiner???Filter () { + // Get a new instance + $filterInstance = new Miner???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/miner/class_MinerInitializationFilter.php b/application/hub/classes/filter/miner/class_MinerInitializationFilter.php new file mode 100644 index 000000000..dec2e891d --- /dev/null +++ b/application/hub/classes/filter/miner/class_MinerInitializationFilter.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerInitializationFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createMinerInitializationFilter () { + // Get a new instance + $filterInstance = new MinerInitializationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // The default miner-mode is from our configuration + $minerMode = $this->getConfigInstance()->getConfigEntry('miner_default_mode'); + + // Is the miner 'mode' parameter set? + if ($requestInstance->isRequestElementSet('mode')) { + // Then use this which overrides the config entry temporarily + $minerMode = $requestInstance->getRequestElement('mode'); + } else { + // Set it for easier re-usage + $requestInstance->setRequestElement('mode', $minerMode); + } + + // Now convert the miner-mode in a class name + $className = 'Hub' . self::convertToClassName($minerMode) . 'Miner'; + + // And try to instance it + try { + // Get an instance + $minerInstance = ObjectFactory::createObjectByName($className); + + // Get a registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Set the app instance + $minerInstance->setApplicationInstance($applicationInstance); + + // Add miner-specific filters + $minerInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); + } catch (ClassNotFoundException $e) { + // This exception means, the miner mode is invalid. + // @TODO Can we rewrite this to app_exit() ? + $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: miner mode ' . $minerMode . ' is invalid.'); + } + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php b/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php new file mode 100644 index 000000000..918568833 --- /dev/null +++ b/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerPhpRequirementsFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createMinerPhpRequirementsFilter () { + // Get a new instance + $filterInstance = new MinerPhpRequirementsFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If a required PHP function is not available + * @todo Add more test and try to add an extra message to the thrown exception + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // By default, the requirement check is passed and zero checks are failed + $checkPassed = TRUE; + $checksFailed = 0; + + // Socket support is essential... + if (!function_exists('socket_create')) { + // Test failed + $checkPassed = FALSE; + $checksFailed++; + } // END -if + + // If scrypt() is not found (ext-scrypt) then the "Hubcoins reward" is not working + if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) { + // Mark it as working + self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt and a callable scrypt() function found. "Hubcoin reward" feature possible.'); + $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); + } else { + // Not working (not all have ext-scrypt installed + self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt not found or scrypt() function not found. "Hubcoin reward" feature disabled.'); + } + + // Are all tests passed? + if ($checkPassed === FALSE) { + // Throw an exception + throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/miner/class_MinerWelcomeTeaserFilter.php b/application/hub/classes/filter/miner/class_MinerWelcomeTeaserFilter.php new file mode 100644 index 000000000..e671de20a --- /dev/null +++ b/application/hub/classes/filter/miner/class_MinerWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerWelcomeTeaserFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createMinerWelcomeTeaserFilter () { + // Get a new instance + $filterInstance = new MinerWelcomeTeaserFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo Handle over the $responseInstance to outputConsoleTeaser() + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Now output the teaser + $minerInstance->outputConsoleTeaser(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/node/.htaccess b/application/hub/classes/filter/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/node/class_Node b/application/hub/classes/filter/node/class_Node new file mode 100644 index 000000000..149bd2723 --- /dev/null +++ b/application/hub/classes/filter/node/class_Node @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???Filter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createNode???Filter () { + // Get a new instance + $filterInstance = new Node???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/node/class_NodeInitializationFilter.php b/application/hub/classes/filter/node/class_NodeInitializationFilter.php new file mode 100644 index 000000000..f15806bfa --- /dev/null +++ b/application/hub/classes/filter/node/class_NodeInitializationFilter.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeInitializationFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeInitializationFilter () { + // Get a new instance + $filterInstance = new NodeInitializationFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Try to instance it by using a factory + try { + // Get an instance + $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance); + } catch (ClassNotFoundException $e) { + // This exception means, the node mode is invalid. + // @TODO Can we rewrite this to app_exit() ? + $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: node mode ' . $nodeMode . ' is invalid.'); + } + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: Node ' . $nodeMode . ' has been added to registry.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php b/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php new file mode 100644 index 000000000..7cba2b5ca --- /dev/null +++ b/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodePhpRequirementsFilter () { + // Get a new instance + $filterInstance = new NodePhpRequirementsFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If a required PHP function is not available + * @todo Add more test and try to add an extra message to the thrown exception + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // By default, the requirement check is passed and zero checks are failed + $checkPassed = TRUE; + $checksFailed = 0; + + // Socket support is essential... + if (!function_exists('socket_create')) { + // Test failed + $checkPassed = FALSE; + $checksFailed++; + } // END - if + + // If scrypt() is not found (ext-scrypt) then the "Hubcoins reward" is not working + if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) { + // Mark it as working + self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt and a callable scrypt() function found. "Hubcoin reward" feature possible.'); + $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); + } else { + // Not working (not all have ext-scrypt installed + self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt not found or scrypt() function not found. "Hubcoin reward" feature disabled.'); + } + + // Are all tests passed? + if ($checkPassed === FALSE) { + // Throw an exception + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/node/class_NodeWelcomeTeaserFilter.php b/application/hub/classes/filter/node/class_NodeWelcomeTeaserFilter.php new file mode 100644 index 000000000..fe3d4551c --- /dev/null +++ b/application/hub/classes/filter/node/class_NodeWelcomeTeaserFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeWelcomeTeaserFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeWelcomeTeaserFilter () { + // Get a new instance + $filterInstance = new NodeWelcomeTeaserFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo Handle over the $responseInstance to outputConsoleTeaser() + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Now output the teaser + $nodeInstance->outputConsoleTeaser(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/.htaccess b/application/hub/classes/filter/shutdown/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/shutdown/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/shutdown/apt-proxy/.htaccess b/application/hub/classes/filter/shutdown/apt-proxy/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/shutdown/apt-proxy/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/shutdown/apt-proxy/class_AptProxyShutdownFilter.php b/application/hub/classes/filter/shutdown/apt-proxy/class_AptProxyShutdownFilter.php new file mode 100644 index 000000000..2887c191f --- /dev/null +++ b/application/hub/classes/filter/shutdown/apt-proxy/class_AptProxyShutdownFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyShutdownFilter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createAptProxyShutdownFilter () { + // Get a new instance + $filterInstance = new AptProxyShutdownFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); + + // Shutdown the apt-proxy. This should be the last line + $proxyInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/chat/.htaccess b/application/hub/classes/filter/shutdown/chat/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/shutdown/chat/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/shutdown/chat/class_ChatShutdownFilter.php b/application/hub/classes/filter/shutdown/chat/class_ChatShutdownFilter.php new file mode 100644 index 000000000..04a397aed --- /dev/null +++ b/application/hub/classes/filter/shutdown/chat/class_ChatShutdownFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatShutdownFilter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createChatShutdownFilter () { + // Get a new instance + $filterInstance = new ChatShutdownFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Shutdown the chat. This should be the last line + $chatInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/class_HubShutdown b/application/hub/classes/filter/shutdown/class_HubShutdown new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/filter/shutdown/class_HubShutdown @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/filter/shutdown/crawler/.htaccess b/application/hub/classes/filter/shutdown/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/shutdown/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/shutdown/crawler/class_CrawlerShutdownFilter.php b/application/hub/classes/filter/shutdown/crawler/class_CrawlerShutdownFilter.php new file mode 100644 index 000000000..97f48da7a --- /dev/null +++ b/application/hub/classes/filter/shutdown/crawler/class_CrawlerShutdownFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerShutdownFilter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCrawlerShutdownFilter () { + // Get a new instance + $filterInstance = new CrawlerShutdownFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Shutdown the crawler. This should be the last line + $crawlerInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/cruncher/.htaccess b/application/hub/classes/filter/shutdown/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/shutdown/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/shutdown/cruncher/class_CruncherShutdownFilter.php b/application/hub/classes/filter/shutdown/cruncher/class_CruncherShutdownFilter.php new file mode 100644 index 000000000..e116d09c1 --- /dev/null +++ b/application/hub/classes/filter/shutdown/cruncher/class_CruncherShutdownFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherShutdownFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCruncherShutdownFilter () { + // Get a new instance + $filterInstance = new CruncherShutdownFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Shutdown the cruncher. This should be the last line + $cruncherInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/miner/.htaccess b/application/hub/classes/filter/shutdown/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/shutdown/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/shutdown/miner/class_MinerShutdownFilter.php b/application/hub/classes/filter/shutdown/miner/class_MinerShutdownFilter.php new file mode 100644 index 000000000..8481f1dd6 --- /dev/null +++ b/application/hub/classes/filter/shutdown/miner/class_MinerShutdownFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerShutdownFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createMinerShutdownFilter () { + // Get a new instance + $filterInstance = new MinerShutdownFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Shutdown the miner. This should be the last line + $minerInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/node/.htaccess b/application/hub/classes/filter/shutdown/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/shutdown/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/shutdown/node/class_NodeShutdown b/application/hub/classes/filter/shutdown/node/class_NodeShutdown new file mode 100644 index 000000000..9bf68cae8 --- /dev/null +++ b/application/hub/classes/filter/shutdown/node/class_NodeShutdown @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubShutdown???Filter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createHubShutdown???Filter () { + // Get a new instance + $filterInstance = new HubShutdown???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php b/application/hub/classes/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php new file mode 100644 index 000000000..9f6f3e6a1 --- /dev/null +++ b/application/hub/classes/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeShutdownFlushNodeListFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeShutdownFlushNodeListFilter () { + // Get a new instance + $filterInstance = new NodeShutdownFlushNodeListFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/node/class_NodeShutdownNodeFilter.php b/application/hub/classes/filter/shutdown/node/class_NodeShutdownNodeFilter.php new file mode 100644 index 000000000..be151db10 --- /dev/null +++ b/application/hub/classes/filter/shutdown/node/class_NodeShutdownNodeFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeShutdownNodeFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeShutdownNodeFilter () { + // Get a new instance + $filterInstance = new NodeShutdownNodeFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Shutdown the node. This should be the last line + $nodeInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php b/application/hub/classes/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php new file mode 100644 index 000000000..48d47edfd --- /dev/null +++ b/application/hub/classes/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeShutdownTaskHandlerFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeShutdownTaskHandlerFilter () { + // Get a new instance + $filterInstance = new NodeShutdownTaskHandlerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Shutdown the task manager and all its registered tasks + $handlerInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/tags/.htaccess b/application/hub/classes/filter/tags/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/tags/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/tags/answer/.htaccess b/application/hub/classes/filter/tags/answer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/tags/answer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php b/application/hub/classes/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php new file mode 100644 index 000000000..3c9129bfb --- /dev/null +++ b/application/hub/classes/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageAnnouncementAnswerTagFilter extends BaseNodeFilter implements FilterablePackage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->dataXmlNodes = array( + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => '', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID => '', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => '', + BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '', + ); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPackageAnnouncementAnswerTagFilter () { + // Get a new instance + $filterInstance = new PackageAnnouncementAnswerTagFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Process message in generic way + $this->genericProcessMessage('announcement_answer', $messageData, $packageInstance); + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function postProcessMessage (Receivable $packageInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php b/application/hub/classes/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php new file mode 100644 index 000000000..2b5c4dd75 --- /dev/null +++ b/application/hub/classes/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php @@ -0,0 +1,96 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageDhtBootstrapAnswerTagFilter extends BaseNodeFilter implements FilterablePackage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->dataXmlNodes = array( + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => '', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_LIST => '', + BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '', + ); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPackageDhtBootstrapAnswerTagFilter () { + // Get a new instance + $filterInstance = new PackageDhtBootstrapAnswerTagFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Process message in generic way + $this->genericProcessMessage('dht_bootstrap_answer', $messageData, $packageInstance); + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function postProcessMessage (Receivable $packageInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php b/application/hub/classes/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php new file mode 100644 index 000000000..33d643fac --- /dev/null +++ b/application/hub/classes/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php @@ -0,0 +1,96 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageRequestNodeListAnswerTagFilter extends BaseNodeFilter implements FilterablePackage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->dataXmlNodes = array( + XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID => '', + XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST => '', + BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '', + ); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPackageRequestNodeListAnswerTagFilter () { + // Get a new instance + $filterInstance = new PackageRequestNodeListAnswerTagFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Process message in generic way + $this->genericProcessMessage('request_node_list_answer', $messageData, $packageInstance); + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function postProcessMessage (Receivable $packageInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/tags/class_PackageAnnouncementTagFilter.php b/application/hub/classes/filter/tags/class_PackageAnnouncementTagFilter.php new file mode 100644 index 000000000..7b992b654 --- /dev/null +++ b/application/hub/classes/filter/tags/class_PackageAnnouncementTagFilter.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageAnnouncementTagFilter extends BaseNodeFilter implements FilterablePackage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->dataXmlNodes = array( + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => '', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE => '', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID => '', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => '', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => '', + ); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPackageAnnouncementTagFilter () { + // Get a new instance + $filterInstance = new PackageAnnouncementTagFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * InvalidXmlNodeException - If an invalid XML node has been found (e.g. + * wrong/out-dated template used) + * XmlNodeMismatchException - Again might be caused by invalid XML node + * usage + * XmlParserException - If the XML message is damaged or not + * well-formed + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Process message generic + $this->genericProcessMessage('announcement', $messageData, $packageInstance); + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function postProcessMessage (Receivable $packageInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php b/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php new file mode 100644 index 000000000..c40c2c9e8 --- /dev/null +++ b/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php @@ -0,0 +1,105 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageDhtBootstrapTagFilter extends BaseNodeFilter implements FilterablePackage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->dataXmlNodes = array( + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => '', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => '', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => '', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE => '', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => '', + ); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPackageDhtBootstrapTagFilter () { + // Get a new instance + $filterInstance = new PackageDhtBootstrapTagFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * InvalidXmlNodeException - If an invalid XML node has been found (e.g. + * wrong/out-dated template used) + * XmlNodeMismatchException - Again might be caused by invalid XML node + * usage + * XmlParserException - If the XML message is damaged or not + * well-formed + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Process message generic + $this->genericProcessMessage('dht_bootstrap', $messageData, $packageInstance); + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function postProcessMessage (Receivable $packageInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/tags/class_PackageRequestNodeListTagFilter.php b/application/hub/classes/filter/tags/class_PackageRequestNodeListTagFilter.php new file mode 100644 index 000000000..71c45c448 --- /dev/null +++ b/application/hub/classes/filter/tags/class_PackageRequestNodeListTagFilter.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageRequestNodeListTagFilter extends BaseNodeFilter implements FilterablePackage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init XML nodes array which contains the required data + $this->dataXmlNodes = array( + XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES => '', + XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID => '', + ); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPackageRequestNodeListTagFilter () { + // Get a new instance + $filterInstance = new PackageRequestNodeListTagFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Processes the given raw message content. + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Process messasge generic + $this->genericProcessMessage('request_node_list', $messageData, $packageInstance); + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function postProcessMessage (Receivable $packageInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php b/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php new file mode 100644 index 000000000..bd75e4505 --- /dev/null +++ b/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php @@ -0,0 +1,102 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageSelfConnectTagFilter extends BaseNodeFilter implements FilterablePackage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->dataXmlNodes = array( + XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID => '', + XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID => '', + ); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPackageSelfConnectTagFilter () { + // Get a new instance + $filterInstance = new PackageSelfConnectTagFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Processes the given raw message content. The method renderXmlContent + * may throw (not the method itself) several exceptions: + * + * InvalidXmlNodeException - If an invalid XML node has been found (e.g. + * wrong/out-dated template used) + * XmlNodeMismatchException - Again might be caused by invalid XML node + * usage + * XmlParserException - If the XML message is damaged or not + * well-formed + * + * @param $messageData Raw message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function processMessage (array $messageData, Receivable $packageInstance) { + // Process generic + $this->genericProcessMessage('self_connect', $messageData, $packageInstance); + } + + /** + * Post-processes the stacked message. Do not call popNamed() as then no + * other class can process the message. + * + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! + */ + public function postProcessMessage (Receivable $packageInstance) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/task/.htaccess b/application/hub/classes/filter/task/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/task/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/task/apt-proxy/.htaccess b/application/hub/classes/filter/task/apt-proxy/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/task/apt-proxy/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/task/apt-proxy/class_AptProxyTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/apt-proxy/class_AptProxyTaskHandlerInitializerFilter.php new file mode 100644 index 000000000..17e808a62 --- /dev/null +++ b/application/hub/classes/filter/task/apt-proxy/class_AptProxyTaskHandlerInitializerFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 apt-proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyTaskHandlerInitializerFilter extends BaseAptProxyFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createAptProxyTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new AptProxyTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If the filter chain needs to be interrupted + * @todo 5% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get apt-proxy instance + //$chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + + /* + * Register all tasks: + * + * 1) apt-proxy listener + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('apt_proxy_listener_task_class'); + $handlerInstance->registerTask('apt_proxy_listener', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/task/chat/.htaccess b/application/hub/classes/filter/task/chat/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/task/chat/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php new file mode 100644 index 000000000..85db533fb --- /dev/null +++ b/application/hub/classes/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatTaskHandlerInitializerFilter extends BaseChatFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createChatTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new ChatTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If the filter chain needs to be interrupted + * @todo 5% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get chat instance + //$chatInstance = Registry::getRegistry()->getInstance('chat'); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + + /* + * Register all tasks: + * + * 1) Telnet session listener + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('chat_telnet_listener_task_class'); + $handlerInstance->registerTask('chat_telnet_listener', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/task/crawler/.htaccess b/application/hub/classes/filter/task/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/task/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php new file mode 100644 index 000000000..1a5ee9eb7 --- /dev/null +++ b/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php @@ -0,0 +1,123 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerTaskHandlerInitializerFilter extends BaseCrawlerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCrawlerTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new CrawlerTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If the filter chain needs to be interrupted + * @todo 10% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get crawler instance + //$crawlerInstance = Registry::getRegistry()->getInstance('crawler'); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + + /* + * Register all tasks: + * + * 1) "Communicator" for crawler->node communication + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_node_communicator_task_class'); + $handlerInstance->registerTask('crawler_node_communicator', $taskInstance); + + // 2) Local URL crawler (gets URLs locally and adds them to the analyzer's input stack) + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_local_url_crawler_task_class'); + $handlerInstance->registerTask('crawler_local_url_crawler', $taskInstance); + + // 3) Remote URL crawler (gets URLs locally for other nodes, also includes the crawled URL in local index) + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_remote_url_crawler_task_class'); + $handlerInstance->registerTask('crawler_remote_url_crawler', $taskInstance); + + // 4) Remote-crawl publisher (publishes crawl jobs for remote retrieval) + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_remote_job_publisher_task_class'); + $handlerInstance->registerTask('crawler_remote_job_publisher', $taskInstance); + + // 5) MIME sniffer + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_mime_sniffer_task_class'); + $handlerInstance->registerTask('crawler_mime_sniffer', $taskInstance); + + // 6) Document parser (converts document to meta format) + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_document_parser_task_class'); + $handlerInstance->registerTask('crawler_document_parser', $taskInstance); + + // 7) Document structure analyzer + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_structure_analyzer_task_class'); + $handlerInstance->registerTask('crawler_structure_analyzer', $taskInstance); + + // 8) Snippet extractor + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_snippet_extractor_task_class'); + $handlerInstance->registerTask('crawler_snippet_extractor', $taskInstance); + + // 9) Node ping + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_ping_task_class'); + $handlerInstance->registerTask('crawler_ping', $taskInstance); + + // 10) URL sources + foreach (explode(':', $this->getConfigInstance()->getConfigEntry('crawler_url_stacks')) as $stack) { + // Init task instance + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_url_source_' . $stack . '_task_class'); + + // And register it + $handlerInstance->registerTask('crawler_url_source_' . $stack, $taskInstance); + } // END - foreach + + // 11) Uploaded list scanner (checks for wanted files) + $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_uploaded_list_scanner_task_class'); + $handlerInstance->registerTask('crawler_uploaded_list_scanner', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/task/cruncher/.htaccess b/application/hub/classes/filter/task/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/task/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php new file mode 100644 index 000000000..2d0095ec2 --- /dev/null +++ b/application/hub/classes/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherTaskHandlerInitializerFilter extends BaseCruncherFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createCruncherTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new CruncherTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If the filter chain needs to be interrupted + * @todo 5% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get cruncher instance + //$cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + + // Register all tasks: + // + // 1) A task for fetching WUs (work units) or test units + $taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_work_unit_fetcher_task_class'); + $handlerInstance->registerTask('cruncher_work_unit_fetcher', $taskInstance); + + /* + * 2) A task for generating test units, a if() block could be placed + * around this but that would make this method look a little ugly and + * even more when more "temporary" tasks should be registered. + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_producer_task_class'); + $handlerInstance->registerTask('cruncher_test_unit_producer', $taskInstance); + + /* + * 3) A task for generating keys based on the generated test unit. This + * task will only be executed if the state of the cruncher is one of + * these: 'virgin'. + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_key_producer_task_class'); + $handlerInstance->registerTask('cruncher_key_producer', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/task/miner/.htaccess b/application/hub/classes/filter/task/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/task/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php new file mode 100644 index 000000000..aaa30dbf1 --- /dev/null +++ b/application/hub/classes/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerTaskHandlerInitializerFilter extends BaseMinerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createMinerTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new MinerTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If the filter chain needs to be interrupted + * @todo 5% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get miner instance + //$minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + + // Register all tasks: + // + // 1) A task for fetching blocks from the network + $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_block_fetcher_task_class'); + $handlerInstance->registerTask('miner_block_fetcher', $taskInstance); + + /* + * 2) A task for generating a test "genesis" block. This "block" + * consists of several hashes of famous phrases or "catch lines" from + * free-software authors. + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_test_genesis_block_producer_task_class'); + $handlerInstance->registerTask('miner_test_genesis_block_producer', $taskInstance); + + /* + * 3) A task for generating a real "genesis" block. @TODO Define how a + * real "genesis" block is generated + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_real_genesis_block_producer_task_class'); + $handlerInstance->registerTask('miner_real_genesis_block_producer', $taskInstance); + + /* + * 4) A task for communicating into the locally running 'hub' node. + * This rask will check for new blocks on the mining network and + * tries to claim found blocks. + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_node_communicator_task_class'); + $handlerInstance->registerTask('miner_node_communicator', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/filter/task/node/.htaccess b/application/hub/classes/filter/task/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/filter/task/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/filter/task/node/class_NodeTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/node/class_NodeTaskHandlerInitializerFilter.php new file mode 100644 index 000000000..6b12e4169 --- /dev/null +++ b/application/hub/classes/filter/task/node/class_NodeTaskHandlerInitializerFilter.php @@ -0,0 +1,158 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeTaskHandlerInitializerFilter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNodeTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new NodeTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If the filter chain needs to be interrupted + * @todo Maybe some more tasks needs to be added? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + + // Prepare a package-tags initialization task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class'); + + // Register it + $handlerInstance->registerTask('package_tags_init', $taskInstance); + + // Generate package writer task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_writer_task_class'); + + // Register it as well + $handlerInstance->registerTask('network_package_writer', $taskInstance); + + // Generate package reader task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class'); + + // Network package reader, needs to be delayed a little + $handlerInstance->registerTask('network_package_reader', $taskInstance); + + // Generate socket listener task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_socket_listener_task_class'); + + // Network package reader, needs to be delayed a little + $handlerInstance->registerTask('socket_listener', $taskInstance); + + // Generate package decoder task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_decoder_task_class'); + + // Register it as well + $handlerInstance->registerTask('package_decoder', $taskInstance); + + // Generate chunk assembler task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_chunk_assembler_task_class'); + + // Register it as well + $handlerInstance->registerTask('chunk_assembler', $taskInstance); + + // Generate DHT initialization task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_init_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_init', $taskInstance); + + // Generate DHT query task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_query_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_query', $taskInstance); + + // Generate DHT publication-check task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_publication_check_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_check_publication', $taskInstance); + + // Generate DHT publication task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_publication_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_publication', $taskInstance); + + // Prepare a self-test task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_selfconnect_task_class'); + + // Register it + $handlerInstance->registerTask('self_connect', $taskInstance); + + // Prepare a update-check task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_update_check_task_class'); + + // Register it + $handlerInstance->registerTask('update_check', $taskInstance); + + // Get the list instance here + $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); + + // Prepare a ping task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance)); + + // Register it + $handlerInstance->registerTask('ping', $taskInstance); + + /* + * Allow extra node-depending tasks, e.g. the bootstrapper node needs + * booting its DHT. DHTs are decentralized and are working on + * peer-to-peer basis. + */ + $nodeInstance->addExtraTasks($handlerInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/.htaccess b/application/hub/classes/handler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/answer-status/.htaccess b/application/hub/classes/handler/answer-status/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/answer-status/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/answer-status/announcement/.htaccess b/application/hub/classes/handler/answer-status/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/answer-status/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php new file mode 100644 index 000000000..64425d5b7 --- /dev/null +++ b/application/hub/classes/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php @@ -0,0 +1,134 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->searchData = array( + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + ); + + // Set handler name + $this->setHandlerName('announcement_answer_okay'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createAnnouncementAnswerOkayHandler () { + // Get new instance + $handlerInstance = new AnnouncementAnswerOkayHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles given message data array + * + * @param $messageData An array of message data + * @param $packageInstance An instance of a Receivable class + * @return void + * @todo Do some more here: Handle karma, et cetera? + */ + public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) { + /* + * Query DHT and force update (which will throw an exception if the + * node is not found). + */ + $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); + + // Get handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Generate DHT bootstrap task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_late_bootstrap_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_late_bootstrap', $taskInstance); + + // Get the node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Change state + $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful(); + + // Prepare next message + $this->prepareNextMessage($messageData, $packageInstance); + } + + /** + * Initializes configuration data from given message data array + * + * The following array is being handled over: + * + * my-external-address => 1.2.3.4 + * my-internal-address => 5.6.7.8 + * my-status => reachable + * my-node-id => aaabbbcccdddeeefff123456789 + * my-session-id => aaabbbcccdddeeefff123456789 + * my-tcp-port => 9060 + * my-udp-port => 9060 + * answer-status => OKAY + * message_type => announcement_answer + * + * @param $messageData An array with all message data + * @return void + */ + protected function initMessageConfigurationData (array $messageData) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Get an array of all accepted object types + $objectList = $nodeInstance->getListFromAcceptedObjectTypes(); + + // Add missing (temporary) configuration 'accepted_object_types' + $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList)); + } + + /** + * Removes configuration data with given message data array from global + * configuration. For content of $messageData see method comment above. + * + * @param $messageData An array with all message data + * @return void + */ + protected function removeMessageConfigurationData (array $messageData) { + // Remove temporay configuration + $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/answer-status/class_ b/application/hub/classes/handler/answer-status/class_ new file mode 100644 index 000000000..b792e7b53 --- /dev/null +++ b/application/hub/classes/handler/answer-status/class_ @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Handler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('|||_answer_==='); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function create???Handler () { + // Get new instance + $handlerInstance = new ???Handler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles given message data array + * + * @param $messageData An array of message data + * @return void + */ + public function handleAnswerMessageData (array $messageData) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php b/application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php new file mode 100644 index 000000000..540bb1c45 --- /dev/null +++ b/application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseAnserStatusHandler extends BaseDataHandler { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/answer-status/requests/.htaccess b/application/hub/classes/handler/answer-status/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/answer-status/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php new file mode 100644 index 000000000..128dbc300 --- /dev/null +++ b/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php @@ -0,0 +1,123 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->searchData = array( + XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, + ); + + // Set handler name + $this->setHandlerName('request_node_list_answer_okay'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createRequestNodeListAnswerOkayHandler () { + // Get new instance + $handlerInstance = new RequestNodeListAnswerOkayHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles given message data array + * + * @param $messageData An array of message data + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws NodeSessionIdVerficationException If the provided session id is not matching + * @todo Do some more here: Handle karma, et cetera? + */ + public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) { + // Make sure node-list is found in array + assert(isset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); + + // Save node list + $nodeList = json_decode(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); + + // Make sure it is completely decoded + assert(is_array($nodeList)); + + // ... and remove it as it should not be included now + unset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]); + + // Write node list to DHT + $this->getDhtInstance()->insertNodeList($nodeList); + + /* + * Query DHT and force update (which will throw an exception if the + * node is not found). + */ + $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); + + // Prepare next message ("hello" message to all returned nodes) + //$this->prepareNextMessage($messageData, $packageInstance); + } + + /** + * Initializes configuration data from given message data array + * + * The following array is being handled over: + * + * session-id => aaabbbcccdddeeefff123456789 + * node-list => aabb:ccdd:eeff + * answer-status => OKAY + * message_type => request_node_list_answer + * + * @param $messageData An array with all message data + * @return void + * @todo 0% done + */ + protected function initMessageConfigurationData (array $messageData) { + $this->partialStub('Please implement this method.'); + } + + /** + * Removes configuration data with given message data array from global + * configuration. For content of $messageData see method comment above. + * + * @param $messageData An array with all message data + * @return void + * @todo 0% done + */ + protected function removeMessageConfigurationData (array $messageData) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/chunks/.htaccess b/application/hub/classes/handler/chunks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/chunks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php new file mode 100644 index 000000000..180805cdd --- /dev/null +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -0,0 +1,656 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable { + /** + * Stacker for chunks with final EOP + */ + const STACKER_NAME_CHUNKS_WITH_FINAL_EOP = 'final_chunks'; + const STACKER_NAME_CHUNKS_WITHOUT_FINAL = 'pending_chunks'; + const STACKER_NAME_ASSEMBLED_RAW_DATA = 'chunk_raw_data'; + + /** + * Chunk splits: + * 0 = Hash + * 1 = Serial number + * 2 = Raw data + */ + const CHUNK_SPLITS_INDEX_HASH = 0; + const CHUNK_SPLITS_INDEX_SERIAL = 1; + const CHUNK_SPLITS_INDEX_RAW_DATA = 2; + + /** + * The final array for assembling the original package back together + */ + private $finalPackageChunks = array(); + + /** + * Array of chunk hashes + */ + private $chunkHashes = array(); + + /** + * Raw EOP chunk data in an array: + * + * 0 = Final hash, + * 1 = Hash of last chunk + */ + private $eopChunk = array(); + + /** + * Raw package data + */ + private $rawPackageData = ''; + + /** + * Fragmenter instance, needs to be set here again + */ + private $fragmenterInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('chunk'); + + // Initialize handler + $this->initHandler(); + + // Get a fragmenter instance for later verification of serial numbers (e.g. if all are received) + $fragmenterInstance = FragmenterFactory::createFragmenterInstance('package'); + + // Set it in this handler + $this->fragmenterInstance = $fragmenterInstance; + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a chunk Handler class + */ + public final static function createChunkHandler () { + // Get new instance + $handlerInstance = new ChunkHandler(); + + // Get a FIFO stacker + $stackInstance = ObjectFactory::createObjectByConfiguredName('chunk_handler_stacker_class'); + + // Init all stacker + $stackInstance->initStacks(array( + self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, + self::STACKER_NAME_CHUNKS_WITHOUT_FINAL, + self::STACKER_NAME_ASSEMBLED_RAW_DATA + )); + + // Set the stacker in this handler + $handlerInstance->setStackInstance($stackInstance); + + // Get a crypto instance ... + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // ... and set it in this handler + $handlerInstance->setCryptoInstance($cryptoInstance); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Initializes the handler + * + * @return void + */ + private function initHandler () { + // Noisy debug line: + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Initializing handler ...'); + + // Init finalPackageChunks + $this->finalPackageChunks = array( + // Array for package content + 'content' => array(), + // ... and for the hashes + 'hashes' => array(), + // ... marker for that the final array is complete for assembling all chunks + 'is_complete' => FALSE, + // ... steps done to assemble all chunks + 'assemble_steps' => 0, + ); + + // ... chunkHashes: + $this->chunkHashes = array(); + + // ... eopChunk: + $this->eopChunk = array( + 0 => 'INVALID', + 1 => 'INVALID', + ); + } + + /** + * Checks whether the hash generated from package content is the same ("valid") as given + * + * @param $chunkSplits An array from a splitted chunk + * @return $isValid Whether the hash is "valid" + */ + private function isChunkHashValid (array $chunkSplits) { + // Noisy debug line: + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: chunkSplits=' . print_r($chunkSplits, TRUE)); + + // Assert on some elements + assert(isset($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA])); + assert(isset($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH])); + + // Now hash the raw data again + $chunkHash = $this->getCryptoInstance()->hashString($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA], $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH], FALSE); + + // Check it + $isValid = ($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] === $chunkHash); + + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: chunkHash=' . $chunkHash . ',isValid=' . intval($isValid)); + + // ... and return it + return $isValid; + } + + /** + * Checks whether the given serial number is valid + * + * @param $serialNumber A serial number from a chunk + * @return $isValid Whether the serial number is valid + */ + private function isSerialNumberValid ($serialNumber) { + // Check it + $isValid = ((strlen($serialNumber) == PackageFragmenter::MAX_SERIAL_LENGTH) && ($this->hexval($serialNumber, FALSE) === $serialNumber)); + + // Return result + return $isValid; + } + + /** + * Adds the chunk to the final array which will be used for the final step + * which will be to assemble all chunks back to the original package content + * and for the final hash check. + * + * This method may throw an exception if a chunk with the same serial number + * has already been added to avoid mixing chunks from different packages. + * + * @param $chunkSplits An array from a splitted chunk + * @return void + */ + private function addChunkToFinalArray (array $chunkSplits) { + // Is the serial number (index 1) already been added? + if (isset($this->finalPackageChunks[$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]])) { + // Then throw an exception + throw new ChunkAlreadyAssembledException(array($this, $chunkSplits), self::EXCEPTION_CHUNK_ALREADY_ASSEMBLED); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]); + + // Add the chunk data (index 2) to the final array and use the serial number as index + $this->finalPackageChunks['content'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]; + + // ... and the hash as well + $this->finalPackageChunks['hashes'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]; + } + + /** + * Marks the final array as completed, do only this if you really have all + * chunks together including EOP and "hash chunk". + * + * @return void + */ + private function markFinalArrayAsCompleted () { + /* + * As for now, just set the array element. If any further steps are + * being added, this should always be the last step. + */ + $this->finalPackageChunks['is_complete'] = TRUE; + } + + /** + * Sorts the chunks array by using the serial number as a sorting key. In + * most situations a call of ksort() is enough to accomblish this. So this + * method may only call ksort() on the chunks array. + * + * This method sorts 'content' and 'hashes' so both must have used the + * serial numbers as array indexes. + * + * @return void + */ + private function sortChunksArray () { + // Sort 'content' first + ksort($this->finalPackageChunks['content']); + + // ... then 'hashes' + ksort($this->finalPackageChunks['hashes']); + } + + /** + * Prepares the package assemble by removing last chunks (last shall be + * hash chunk, pre-last shall be EOP chunk) and verify that all serial + * numbers are valid (same as PackageFragmenter class would generate). + * + * @return void + */ + private function preparePackageAssmble () { + // Make sure both arrays have same count (this however should always be TRUE) + assert(count($this->finalPackageChunks['hashes']) == count($this->finalPackageChunks['content'])); + //* DIE: */ exit(__METHOD__ . ':finalPackageChunks='.print_r($this->finalPackageChunks['content'], TRUE)); + + /* + * Remove last element (hash chunk) from 'hashes'. This hash will never + * be needed, so ignore it. + */ + array_pop($this->finalPackageChunks['hashes']); + + // ... and from 'content' as well but save it for later use + $this->chunkHashes = explode(PackageFragmenter::CHUNK_HASH_SEPARATOR, substr(array_pop($this->finalPackageChunks['content']), strlen(PackageFragmenter::HASH_CHUNK_IDENTIFIER))); + + // Remove EOP chunk and keep a copy of it + array_pop($this->finalPackageChunks['hashes']); + $this->eopChunk = explode(PackageFragmenter::CHUNK_HASH_SEPARATOR, substr(array_pop($this->finalPackageChunks['content']), strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER))); + + // Verify all serial numbers + $this->verifyChunkSerialNumbers(); + } + + /** + * Verifies all chunk serial numbers by using a freshly initialized + * fragmenter instance. Do ALWAYS sort the array and array_pop() the hash + * chunk before calling this method to avoid re-requests of many chunks. + * + * @return void + */ + private function verifyChunkSerialNumbers () { + // Debug message + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE)); + + // Get final hash + $finalHash = $this->generateFinalHash(implode('', $this->finalPackageChunks['content'])); + + // Reset the serial number generator + $this->fragmenterInstance->resetSerialNumber($finalHash); + + // "Walk" through all (content) chunks + foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) { + // Get next serial number + $nextSerial = $this->fragmenterInstance->getNextHexSerialNumber($finalHash); + + // Debug output + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial); + + // Is it not the same? Then re-request it + if ($serialNumber != $nextSerial) { + // This is invalid, so remove it + unset($this->finalPackageChunks['content'][$serialNumber]); + unset($this->finalPackageChunks['hashes'][$serialNumber]); + + // And re-request it with valid serial number (and hash chunk) + $this->rerequestChunkBySerialNumber($nextSerial); + } // END - if + } // END - foreach + } + + /** + * Assembles and verifies ("final check") chunks back together to the + * original package (raw data for the start). This method should only be + * called AFTER the EOP and final-chunk chunk have been removed. + * + * @return void + */ + private function assembleAllChunksToPackage () { + // If chunkHashes is not filled, don't continue + assert(count($this->chunkHashes) > 0); + + // Init raw package data string + $this->rawPackageData = ''; + + // That went well, so start assembling all chunks + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Handling ' . count($this->finalPackageChunks['content']) . ' entries ...'); + foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) { + // Assert on 'hash' entry (must always be set) + assert(isset($this->finalPackageChunks['hashes'][$serialNumber])); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $serialNumber . ',hashes=' . $this->finalPackageChunks['hashes'][$serialNumber] . ' - validating ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE) . 'chunkHashes=' . print_r($this->chunkHashes, TRUE)); + + // Is this chunk valid? This should be the case + assert($this->isChunkHashValid(array( + self::CHUNK_SPLITS_INDEX_HASH => $this->finalPackageChunks['hashes'][$serialNumber], + self::CHUNK_SPLITS_INDEX_RAW_DATA => $content + ))); + + // ... and is also in the hash chunk? + assert(in_array($this->finalPackageChunks['hashes'][$serialNumber], $this->chunkHashes)); + + // Verification okay, add it to the raw data + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($content) . ' bytes as raw package data ...'); + $this->rawPackageData .= $content; + } // END - foreach + + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: eopChunk[1]=' . $this->eopChunk[1] . ',index=' . (count($this->chunkHashes) - 2) . ',chunkHashes='.print_r($this->chunkHashes, TRUE)); + + // The last chunk hash must match with the one from eopChunk[1] + assert($this->eopChunk[1] == $this->chunkHashes[count($this->chunkHashes) - 2]); + } + + /** + * Generate final hash if EOP chunk is found, else an assert will happen. + * + * @param $rawPackageData Raw package data + * @return $finalHash Final hash if EOP chunk is found + */ + private function generateFinalHash ($rawPackageData) { + // Make sure the raw package data is given + assert((is_string($rawPackageData)) && (!empty($rawPackageData))); + + // Make sure the EOP chunk is set + assert((isset($this->eopChunk[0])) && (isset($this->eopChunk[1]))); + assert((is_string($this->eopChunk[0])) && (!empty($this->eopChunk[0]))); + + // Hash the raw data + $finalHash = $this->getCryptoInstance()->hashString($rawPackageData, $this->eopChunk[0], FALSE); + + // Return it + return $finalHash; + } + + /** + * Verifies the finally assembled raw package data by comparing it against + * the final hash. + * + * @return void + */ + private function verifyRawPackageData () { + // Generate final hash + $finalHash = $this->generateFinalHash($this->rawPackageData); + + // Is it the same? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: eopChunk[1]=' . $this->eopChunk[1] . ',finalHash=' . $finalHash); + assert($finalHash == $this->eopChunk[0]); + } + + /** + * Checks whether the final (last) chunk is valid + * + * @param $chunks An array with chunks and (hopefully) a valid final chunk + * @return $isValid Whether the final (last) chunk is valid + */ + private function isValidFinalChunk (array $chunks) { + // Default is all fine + $isValid = TRUE; + + // Split the (possible) EOP chunk + $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]); + + // Make sure chunks with only 3 elements are parsed (for details see ChunkHandler) + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE)); + assert(count($chunkSplits) == 3); + + // Validate final chunk + if (substr($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) { + // Not fine + $isValid = FALSE; + } elseif (substr_count($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) { + // CHUNK_HASH_SEPARATOR shall only be found once + $isValid = FALSE; + } + + // Return status + return $isValid; + } + + /** + * Adds all chunks if the last one verifies as a 'final chunk'. + * + * @param $chunks An array with chunks, the last one should be a 'final' + * @return void + * @throws FinalChunkVerificationException If the final chunk does not start with 'EOP:' + */ + public function addAllChunksWithFinal (array $chunks) { + // Try to validate the final chunk + try { + // Validate final chunk + $this->isValidFinalChunk($chunks); + } catch (AssertionException $e) { + // Last chunk is not valid + throw new FinalChunkVerificationException(array($this, $chunks, $e), BaseListener::EXCEPTION_FINAL_CHUNK_VERIFICATION); + } + + // Do we have some pending chunks (no final)? + while (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL)) { + // Then get it first and add it before the EOP chunks + array_unshift($chunks, $this->getStackInstance()->popNamed(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL)); + } // END - while + + // Add all chunks to the FIFO stacker + foreach ($chunks as $chunk) { + // Add the chunk + $this->getStackInstance()->pushNamed(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, $chunk); + } // END - foreach + } + + /** + * Adds all chunks and wait for more (e.g. incomplete transmission) + * + * @param $chunks An array with chunks, the last one should be a 'final' + * @return void + */ + public function addAllChunksWait (array $chunks) { + // Add all chunks to the FIFO stacker + foreach ($chunks as $chunk) { + // Add the chunk + $this->getStackInstance()->pushNamed(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL, $chunk); + } // END - foreach + } + + /** + * Checks whether unhandled chunks are available + * + * @return $unhandledChunks Whether unhandled chunks are left + */ + public function ifUnhandledChunksWithFinalAvailable () { + // Simply check if the stacker is not empty + $unhandledChunks = $this->getStackInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP) === FALSE; + + // Return result + return $unhandledChunks; + } + + /** + * Handles available chunks by processing one-by-one (not all together, + * this would slow-down the whole application) with the help of an + * iterator. + * + * @return void + */ + public function handleAvailableChunksWithFinal () { + // First check if there are undhandled chunks available + assert($this->ifUnhandledChunksWithFinalAvailable()); + + // Get an entry from the stacker + $chunk = $this->getStackInstance()->popNamed(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP); + + // Split the string with proper separator character + $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunk); + + /* + * Make sure three elements are always found: + * 0 = Hash + * 1 = Serial number + * 2 = Raw data + */ + assert(count($chunkSplits) == 3); + + // Is the generated hash from data same ("valid") as given hash? + if (!$this->isChunkHashValid($chunkSplits)) { + // Do some logging + self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Chunk content is not validating against given hash.'); + + // Re-request this chunk (trust the hash in index # 0) + $this->rerequestChunkBySplitsArray($chunkSplits); + + // Don't process this chunk + return; + } // END - if + + // Is the serial number valid (chars 0-9, length equals PackageFragmenter::MAX_SERIAL_LENGTH)? + if (!$this->isSerialNumberValid($chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL])) { + // Do some logging + self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Chunk serial number ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ' for hash ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ' is invalid.'); + + // Re-request this chunk + $this->rerequestChunkBySplitsArray($chunkSplits); + + // Don't process this chunk + return; + } // END - if + + /* + * It is now known that (as long as the hash algorithm has no + * collisions) the content is the same as the sender sends it to this + * peer. + * + * And also the serial number is valid (basicly) at this point. Now the + * chunk can be added to the final array. + */ + $this->addChunkToFinalArray($chunkSplits); + + // Is the stack now empty? + if ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP)) { + // Then mark the final array as complete + $this->markFinalArrayAsCompleted(); + } // END - if + } + + /** + * Checks whether unassembled chunks are available (ready) in final array + * + * @return $unassembledChunksAvailable Whether unassembled chunks are available + */ + public function ifUnassembledChunksAvailable () { + // For now do only check the array element 'is_complete' + $unassembledChunksAvailable = ($this->finalPackageChunks['is_complete'] === TRUE); + + // Return status + return $unassembledChunksAvailable; + } + + /** + * Assembles all chunks (except EOP and "hash chunk") back together to the original package data. + * + * This is done by the following steps: + * + * 1) Sort the final array with ksort(). This will bring the "hash + * chunk" up to the last array index and the EOP chunk to the + * pre-last array index + * 2) Assemble all chunks except two last (see above step) + * 3) While so, do the final check on all hashes + * 4) If the package is assembled back together, hash it again for + * the very final verification. + * + * @return void + */ + public function assembleChunksFromFinalArray () { + // Make sure the final array is really completed + assert($this->ifUnassembledChunksAvailable()); + + // Count up stepping + $this->finalPackageChunks['assemble_steps']++; + + // Do the next step + switch ($this->finalPackageChunks['assemble_steps']) { + case 1: // Sort the chunks array (the serial number shall act as a sorting key) + $this->sortChunksArray(); + break; + + case 2: // Prepare the assemble by removing last two indexes + $this->preparePackageAssmble(); + break; + + case 3: // Assemble all chunks back together to the original package + $this->assembleAllChunksToPackage(); + break; + + case 4: // Verify the raw data by hashing it again + $this->verifyRawPackageData(); + break; + + case 5: // Re-initialize handler to reset it to the old state + $this->initHandler(); + break; + + default: // Invalid step found + self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Invalid step ' . $this->finalPackageChunks['assemble_steps'] . ' detected.'); + break; + } // END - switch + } + + /** + * Checks whether the raw package data has been assembled back together. + * This can be safely assumed when rawPackageData is not empty and the + * collection of all chunks is FALSE (because initHandler() will reset it). + * + * @return $isRawPackageDataAvailable Whether raw package data is available + */ + public function ifRawPackageDataIsAvailable () { + // Check it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: this->rawPackageData()=' . strlen($this->rawPackageData) . ',ifUnassembledChunksAvailable()=' . intval($this->ifUnassembledChunksAvailable())); + $isRawPackageDataAvailable = ((!empty($this->rawPackageData)) && (!$this->ifUnassembledChunksAvailable())); + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: isRawPackageDataAvailable=' . intval($isRawPackageDataAvailable)); + return $isRawPackageDataAvailable; + } + + /** + * Handles the finally assembled raw package data by feeding it into another + * stacker for further decoding/processing. + * + * @return void + */ + public function handledAssembledRawPackageData () { + // Assert to make sure that there is raw package data available + assert($this->ifRawPackageDataIsAvailable()); + + // Then feed it into the next stacker + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($this->rawPackageData) . ' bytes to stack ' . self::STACKER_NAME_ASSEMBLED_RAW_DATA . ' ...'); + $this->getStackInstance()->pushNamed(self::STACKER_NAME_ASSEMBLED_RAW_DATA, $this->rawPackageData); + + // ... and reset it + $this->rawPackageData = ''; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/class_ b/application/hub/classes/handler/class_ new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/handler/class_ @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/handler/class_BaseDataHandler.php b/application/hub/classes/handler/class_BaseDataHandler.php new file mode 100644 index 000000000..7b6b1d7d5 --- /dev/null +++ b/application/hub/classes/handler/class_BaseDataHandler.php @@ -0,0 +1,197 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseDataHandler extends BaseHandler { + /** + * Last exception instance from database layer or NULL (default) + */ + private $lastException = NULL; + + /** + * Array with search criteria elements + */ + protected $searchData = array(); + + /** + * Array with all data XML nodes (which hold the actual data) and their values + */ + protected $messageDataElements = array(); + + /** + * Array for translating message data elements (other node's data mostly) + * into configuration elements. + */ + protected $messageToConfig = array(); + + /** + * Array for copying configuration entries + */ + protected $configCopy = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set it here + $this->setDhtInstance($dhtInstance); + } + + /** + * Getter for search data array + * + * @return $searchData Search data array + */ + public final function getSearchData () { + return $this->searchData; + } + + /** + * Getter for last exception + * + * @return $lastException Last thrown exception + */ + public final function getLastException () { + return $this->lastException; + } + + /** + * Setter for last exception + * + * @param $lastException Last thrown exception + * @return void + */ + public final function setLastException (FrameworkException $exceptionInstance = NULL) { + $this->lastException = $exceptionInstance; + } + + /** + * Prepares a message as answer for given message data for delivery. + * + * @param $messageData An array with all message data + * @param $packageInstance An instance of a Deliverable instance + * @return void + */ + protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to send an answer message for ' . $this->getHandlerName() . ' ...'); + + // Get a helper instance based on this handler's name + $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData)); + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Load descriptor XML + $helperInstance->loadDescriptorXml($nodeInstance); + + /* + * Set missing (temporary) configuration data, mostly it needs to be + * copied from message data array. + */ + $this->initMessageConfigurationData($messageData); + + // Compile any configuration variables + $helperInstance->getTemplateInstance()->compileConfigInVariables(); + + // Deliver the package + $helperInstance->sendPackage($nodeInstance); + + /* + * Remove temporary configuration + */ + $this->removeMessageConfigurationData($messageData); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Answer message has been prepared.'); + } + + /** + * Prepares the next message + * + * @param $messageData An array with all message data + * @param $packageInstance An instance of a Deliverable instance + * @return void + */ + protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to send next message ...'); + + // Get a helper instance based on this handler's name + $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData)); + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Load descriptor XML + $helperInstance->loadDescriptorXml($nodeInstance); + + /* + * Set missing (temporary) configuration data, mostly it needs to be + * copied from message data array. + */ + $this->initMessageConfigurationData($messageData); + + // Compile any configuration variables + $helperInstance->getTemplateInstance()->compileConfigInVariables(); + + // Deliver the package + $helperInstance->sendPackage($nodeInstance); + + /* + * Remove temporary configuration + */ + $this->removeMessageConfigurationData($messageData); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Next message has been prepared.'); + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + */ + abstract protected function initMessageConfigurationData (array $messageData); + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + */ + abstract protected function removeMessageConfigurationData (array $messageData); +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/.htaccess b/application/hub/classes/handler/message-types/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/message-types/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/message-types/announcement/.htaccess b/application/hub/classes/handler/message-types/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/message-types/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php new file mode 100644 index 000000000..6e4b50300 --- /dev/null +++ b/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php @@ -0,0 +1,196 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessageAnnouncementHandler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_announcement'); + + // Init message data array + $this->messageDataElements = array( + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS, + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE, + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID, + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, + ); + + // Init message-data->configuration translation array + $this->messageToConfig = array( + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID => 'your_node_id', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash', + ); + + // Init config-copy array + $this->configCopy = array( + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash', + ); + + // Init array + $this->searchData = array( + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS + ); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessageAnnouncementHandler () { + // Get new instance + $handlerInstance = new NodeMessageAnnouncementHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws AnnouncementNotAcceptedException If this node does not accept announcements + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Is this node accepting announcements? + if (!$nodeInstance->isAcceptingAnnouncements()) { + /* + * This node is not accepting announcements, then someone wants to + * announce his node to a non-bootstrap and non-master node. + */ + throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageData), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED); + } // END - if + + // Register the announcing node with this node + $this->registerNodeByMessageData($messageData); + + // Prepare answer message to be delivered back to the other node + $this->prepareAnswerMessage($messageData, $packageInstance); + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add generic first + parent::addArrayToDataSet($dataSetInstance, $messageData); + + // Add all ements + foreach ($this->messageDataElements as $key) { + // Is it there? + assert(isset($messageData[$key])); + + // Add it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Adding messageData[' . $key . ']=' . $messageData[$key] . ' ...'); + $dataSetInstance->addCriteria($key, $messageData[$key]); + } // END - foreach + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + */ + protected function initMessageConfigurationData (array $messageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); + + // "Walk" throught the translation array + foreach ($this->messageToConfig as $messageKey => $configKey) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); + + // Set the element in configuration + $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]); + } // END - foreach + + // "Walk" throught the config-copy array + foreach ($this->configCopy as $targetKey => $sourceKey) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); + + // Copy from source to targetKey + $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); + } // END - foreach + + // Translate last exception into a status code + $statusCode = $this->getTranslatedStatusFromLastException(); + + // Set it in configuration (temporarily) + $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); + } + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + */ + protected function removeMessageConfigurationData (array $messageData) { + // "Walk" throught the translation array again + foreach ($this->messageToConfig as $dummy => $configKey) { + // Now unset this configuration entry (to save some memory) + $this->getConfigInstance()->unsetConfigEntry($configKey); + } // END - foreach + + // "Walk" throught the config-copy array again + foreach ($this->configCopy as $configKey => $dummy) { + // Now unset this configuration entry (to save some memory again) + $this->getConfigInstance()->unsetConfigEntry($configKey); + } // END - foreach + + // Remove NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS as well + $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/answer/.htaccess b/application/hub/classes/handler/message-types/answer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/message-types/answer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php new file mode 100644 index 000000000..6ccd1619b --- /dev/null +++ b/application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php @@ -0,0 +1,166 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_announcement_answer'); + + // Init message data array + $this->messageDataElements = array( + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, + BaseXmlAnswerTemplateEngine::ANSWER_STATUS, + ); + + // Init message-data->configuration translation array + $this->messageToConfig = array( + /* + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id' + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash' + */ + ); + + // Init config-copy array + $this->configCopy = array( + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash', + ); + + // Init array + $this->searchData = array( + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + ); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessageAnnouncementAnswerHandler () { + // Get new instance + $handlerInstance = new NodeMessageAnnouncementAnswerHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws NoAnnouncementAttemptedException If this node has not attempted to announce itself + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Has this node attempted to announce itself? + if (!$nodeInstance->ifNodeIsAnnouncing()) { + /* + * This node has never announced itself, so it doesn't expect + * announcement answer messages. + */ + throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); + } // END - if + + // Register the announcing node with this node + $this->registerNodeByMessageData($messageData); + + // Handle the answer status element + $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance); + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add generic first + parent::addArrayToDataSet($dataSetInstance, $messageData); + + // Add all ements + foreach ($this->messageDataElements as $key) { + // Is it there? + assert(isset($messageData[$key])); + + /* + * Add it, but remove any 'my-' prefixes as they are not used in + * database layer. + */ + $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); + } // END - foreach + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function initMessageConfigurationData (array $messageData) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function removeMessageConfigurationData (array $messageData) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php new file mode 100644 index 000000000..85c9165e8 --- /dev/null +++ b/application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php @@ -0,0 +1,160 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_announcement_answer'); + + // Init message data array + $this->messageDataElements = array( + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS, + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, + BaseXmlAnswerTemplateEngine::ANSWER_STATUS, + ); + + // Init message-data->configuration translation array + $this->messageToConfig = array( + /* + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id' + */ + ); + + // Init config-copy array + $this->configCopy = array( + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id', + ); + + // Init array + $this->searchData = array( + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + ); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessageDhtBootstrapAnswerHandler () { + // Get new instance + $handlerInstance = new NodeMessageDhtBootstrapAnswerHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws NoDhtBootstrapAttemptedException If this DHT has not attempted to bootstrap + * @todo ~30% done + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Get DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Has this DHT attempted to bootstrap? + if (!$dhtInstance->ifDhtIsBooting()) { + /* + * This DHT has never bootstrapped, so it doesn't expect + * announcement answer messages. + */ + throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED); + } // END - if + + // Unfinished + $this->partialStub('UNHANDLED: messageData=' . print_r($messageData, TRUE)); + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add generic first + parent::addArrayToDataSet($dataSetInstance, $messageData); + + // Add all ements + foreach ($this->messageDataElements as $key) { + // Is it there? + assert(isset($messageData[$key])); + + /* + * Add it, but remove any 'my-' prefixes as they are not used in + * database layer. + */ + $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); + } // END - foreach + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function initMessageConfigurationData (array $messageData) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function removeMessageConfigurationData (array $messageData) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php new file mode 100644 index 000000000..058b9ce55 --- /dev/null +++ b/application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php @@ -0,0 +1,155 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_request_node_list_answer'); + + // Init message data array + $this->messageDataElements = array( + XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, + XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST, + BaseXmlAnswerTemplateEngine::ANSWER_STATUS, + ); + + // Init message-data->configuration translation array + $this->messageToConfig = array( + /* + XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID => 'your_session_id' + */ + ); + + // Init search data array + $this->searchData = array( + XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, + ); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessageRequestNodeListAnswerHandler () { + // Get new instance + $handlerInstance = new NodeMessageRequestNodeListAnswerHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws NoRequestNodeListAttemptedException If this node has not attempted to announce itself + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Has this node attempted to announce itself? + if (!$nodeInstance->ifNodeHasAnnouncementCompleted()) { + /* + * This node has never announced itself, so it doesn't expect + * request-node-list answer messages. + */ + throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); + } // END - if + + // Register the announcing node with this node + $this->registerNodeByMessageData($messageData); + + // Handle the answer status element + $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance); + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add generic first + parent::addArrayToDataSet($dataSetInstance, $messageData); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); + + // Add all ements + foreach ($this->messageDataElements as $key) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData[' . $key . ']=' . $messageData[$key]); + + // Is it there? + assert(isset($messageData[$key])); + + /* + * Add it, but remove any 'my-' prefixes as they are not used in + * database layer. + */ + $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); + } // END - foreach + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function initMessageConfigurationData (array $messageData) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function removeMessageConfigurationData (array $messageData) { + // Please don't call this method + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/class_ b/application/hub/classes/handler/message-types/class_ new file mode 100644 index 000000000..4853fd41d --- /dev/null +++ b/application/hub/classes/handler/message-types/class_ @@ -0,0 +1,115 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessage???Handler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_==='); + + // Init message data array + $this->messageDataElements = array( + Xml???TemplateEngine::!!!_DATA_EXTERNAL_ADDRESS, + Xml???TemplateEngine::!!!_DATA_NODE_STATUS, + Xml???TemplateEngine::!!!_DATA_SESSION_ID, + Xml???TemplateEngine::!!!_DATA_LISTEN_PORT, + ); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessage???Handler () { + // Get new instance + $handlerInstance = new NodeMessage???Handler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Register the announcing node with this node + $this->registerNodeByMessageData($messageData); + + // Prepare answer message to be delivered back to the other node + $this->prepareAnswerMessage($messageData, $packageInstance); + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add all ements + foreach ($this->messageDataElements as $key) { + // Is it there? + assert(isset($messageData[$key])); + + // Add it + $dataSetInstance->addCriteria($key, $messageData[$key]); + } // END - foreach + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + */ + protected function initMessageConfigurationData (array $messageData) { + $this->partialStub('Please implement this method.'); + } + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + */ + protected function removeMessageConfigurationData (array $messageData) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/message-types/class_BaseMessageHandler.php new file mode 100644 index 000000000..936f0178a --- /dev/null +++ b/application/hub/classes/handler/message-types/class_BaseMessageHandler.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseMessageHandler extends BaseDataHandler { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * "Getter" for a translated last exception as a status code + * + * @return $statusCode Translated status code from last exception + */ + protected function getTranslatedStatusFromLastException () { + // Default is all fine + $statusCode = BaseHubSystem::MESSAGE_STATUS_CODE_OKAY; + + // Is the last exception not NULL? + if ($this->getLastException() instanceof FrameworkException) { + // "Determine" the right status code (may differ from exception to exception) + $this->debugInstance('lastException=' . $this->getLastException()->__toString() . ',message=' . $this->getLastException()->getMessage() . ' is not finished!'); + } // END - if + + // Return the status code + return $statusCode; + } + + /** + * Registers an other node with this node by given message data. The + * following data must always be present: + * + * - session-id (for finding the node's record together with below data) + * - external-address (hostname or IP number) + * - listen-port (TCP/UDP listen port for inbound connections) + * + * @param $messageArray An array with all minimum message data + * @return void + */ + protected function registerNodeByMessageData (array $messageData) { + // Check if searchData has entries + assert(count($this->getSearchData()) > 0); + + // Let the DHT facade do the work + $this->getDhtInstance()->registerNodeByMessageData($messageData, $this); + } + + /** + * Posty-handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function postHandleMessageData (array $messageData, Receivable $packageInstance) { + /* + * Feed hash to miner by handling over the whole array as also the + * sender and tags are needed. + */ + $packageInstance->feedHashToMiner($messageData); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/dht/.htaccess b/application/hub/classes/handler/message-types/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/message-types/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php new file mode 100644 index 000000000..0bf5c5964 --- /dev/null +++ b/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -0,0 +1,207 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_dht_bootstrap'); + + // Init message data array + $this->messageDataElements = array( + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS, + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE, + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, + ); + + // Init message-data->configuration translation array + $this->messageToConfig = array( + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id' + ); + + // Init config-copy array + $this->configCopy = array( + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id', + ); + + // Init array + $this->searchData = array( + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + ); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessageDhtBootstrapHandler () { + // Get new instance + $handlerInstance = new NodeMessageDhtBootstrapHandler(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $handlerInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws DhtBootstrapNotAcceptedException If this node does not accept DHT bootstrap requests + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Is this node accepting DHT bootstrap requests? + if (!NodeObjectFactory::createNodeInstance()->isAcceptingDhtBootstrap()) { + /* + * This node is not accepting DHT bootstrap requests. + */ + throw new DhtBootstrapNotAcceptedException(array($this, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED); + } // END - if + + // Register the DHT bootstrap requesting node with this node + $this->registerNodeByMessageData($messageData); + + // Prepare answer message to be delivered back to the other node + $this->prepareAnswerMessage($messageData, $packageInstance); + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add generic first + parent::addArrayToDataSet($dataSetInstance, $messageData); + + // Add all ements + foreach ($this->messageDataElements as $key) { + // Is it there? + assert(isset($messageData[$key])); + + // Add it + $dataSetInstance->addCriteria($key, $messageData[$key]); + } // END - foreach + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + */ + protected function initMessageConfigurationData (array $messageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-BOOTSTRAP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); + + // "Walk" throught the translation array + foreach ($this->messageToConfig as $messageKey => $configKey) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-BOOTSTRAP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); + + // Set the element in configuration + $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]); + } // END - foreach + + // "Walk" throught the config-copy array + foreach ($this->configCopy as $targetKey => $sourceKey) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-BOOTSTRAP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); + + // Copy from source to target key + $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); + } // END - foreach + + // Translate last exception into a status code + $statusCode = $this->getTranslatedStatusFromLastException(); + + // Set it in configuration (temporarily) + $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); + + /* + * Use the DHT instance to get a list of recipients. This means that all + * DHT nodes that accept bootstrap requests are read from the DHT + * database. + */ + $nodeList = $this->getDhtInstance()->findRecipientsByKey(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y'); + + // Make sure it is an array and has at least one entry + assert(is_array($nodeList)); + assert(count($nodeList) > 0); + + // Set it in configuration + $this->getConfigInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList))); + } + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + */ + protected function removeMessageConfigurationData (array $messageData) { + // "Walk" throught the translation array again + foreach ($this->messageToConfig as $dummy => $configKey) { + // Now unset this configuration entry (to save some memory) + $this->getConfigInstance()->unsetConfigEntry($configKey); + } // END - foreach + + // "Walk" throught the config-copy array again + foreach ($this->configCopy as $configKey => $dummy) { + // Now unset this configuration entry (to save some memory again) + $this->getConfigInstance()->unsetConfigEntry($configKey); + } // END - foreach + + // Remove temporary "special" values as well + $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); + $this->getConfigInstance()->unsetConfigEntry('dht_nodes'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/requests/.htaccess b/application/hub/classes/handler/message-types/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/message-types/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php new file mode 100644 index 000000000..92cc25eac --- /dev/null +++ b/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -0,0 +1,176 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_request_node_list'); + + // Init message data array + $this->messageDataElements = array( + XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, + ); + + // Init config-copy array + $this->configCopy = array( + ); + + // Init search data array + $this->searchData = array( + XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, + ); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessageRequestNodeListHandler () { + // Get new instance + $handlerInstance = new NodeMessageRequestNodeListHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + * @throws RequestNotAcceptedException If this node does not accept this request + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Is this node accepting announcements? + if (!$nodeInstance->isAcceptingNodeListRequests()) { + /* + * This node is not accepting node list requests. Throw an + * exception to abort any further processing. + */ + throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_REQUEST_NOT_ACCEPTED); + } // END - if + + // Register the announcing node with this node + $this->registerNodeByMessageData($messageData); + + // Prepare answer message to be delivered back to the other node + $this->prepareAnswerMessage($messageData, $packageInstance); + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add generic first + parent::addArrayToDataSet($dataSetInstance, $messageData); + + // Add all ements + foreach ($this->messageDataElements as $key) { + // Is it there? + assert(isset($messageData[$key])); + + // Add it + $dataSetInstance->addCriteria($key, $messageData[$key]); + } // END - foreach + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + */ + protected function initMessageConfigurationData (array $messageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); + + // "Walk" throught the config-copy array + foreach ($this->configCopy as $targetKey => $sourceKey) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); + + // Copy from source to targetKey + $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); + } // END - foreach + + // Query local DHT for nodes except given session id + $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData( + $messageData, + $this, + XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, + XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, + BaseHubNode::OBJECT_LIST_SEPARATOR + ); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.'); + + // Set it serialized in configuration (temporarily) + $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList))); + + // Translate last exception into a status code + $statusCode = $this->getTranslatedStatusFromLastException(); + + // Set it in configuration (temporarily) + $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); + } + + /** + * Removes configuration data with given message data array from global + * configuration + * + * @param $messageData An array with all message data + * @return void + */ + protected function removeMessageConfigurationData (array $messageData) { + // "Walk" throught the config-copy array again + foreach ($this->configCopy as $configKey => $dummy) { + // Now unset this configuration entry (to save some memory again) + $this->getConfigInstance()->unsetConfigEntry($configKey); + } // END - foreach + + // Remove answer status/node list as well + $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); + $this->getConfigInstance()->unsetConfigEntry('node_list'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/message-types/self-connect/.htaccess b/application/hub/classes/handler/message-types/self-connect/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/message-types/self-connect/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php b/application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php new file mode 100644 index 000000000..e1ac210a2 --- /dev/null +++ b/application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php @@ -0,0 +1,118 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeMessageSelfConnectHandler extends BaseMessageHandler implements HandleableMessage, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('message_self_connect'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createNodeMessageSelfConnectHandler () { + // Get new instance + $handlerInstance = new NodeMessageSelfConnectHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Handles data array of the message + * + * @param $messageData An array with message data to handle + * @param $packageInstance An instance of a Receivable class + * @return void + */ + public function handleMessageData (array $messageData, Receivable $packageInstance) { + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Are node id and session id the same? + if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $nodeInstance->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $nodeInstance->getSessionId())) { + // Both are equal + self::createDebugInstance(__CLASS__)->debugOutput('SELF-CONNECT[' . __METHOD__ . ':' . __LINE__ . ']: Have connected to myself, both node and session id are equal!'); + + // ... and change state + $nodeInstance->getStateInstance()->nodeHasSelfConnected(); + } else { + // Something really horrible happened + // @TODO Throw an exception here instead of dying + $this->debugInstance(__METHOD__ . ': ids mismatching! messageData=' . print_r($messageData, TRUE)); + } + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add generic first + parent::addArrayToDataSet($dataSetInstance, $messageData); + + // Please don't call this method! + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Initializes configuration data from given message data array + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function initMessageConfigurationData (array $messageData) { + // Please don't call this method! + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Removes configuration data with given message data array from global configuration + * + * @param $messageData An array with all message data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected function removeMessageConfigurationData (array $messageData) { + // Please don't call this method! + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/network/.htaccess b/application/hub/classes/handler/network/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/network/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/network/class_ b/application/hub/classes/handler/network/class_ new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/handler/network/class_ @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/handler/network/class_BaseRawDataHandler.php b/application/hub/classes/handler/network/class_BaseRawDataHandler.php new file mode 100644 index 000000000..6c4b37936 --- /dev/null +++ b/application/hub/classes/handler/network/class_BaseRawDataHandler.php @@ -0,0 +1,182 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseRawDataHandler extends BaseHandler { + // Error codes: + // - Socket raw data stream errors + const SOCKET_ERROR_UNKNOWN = 'unknown_error'; // Unknown error (should not happen) + const SOCKET_ERROR_TRANSPORT_ENDPOINT = 'transport_endpoint'; // Transport endpoint has closed + const SOCKET_ERROR_INVALID_BASE64_MODULO = 'base64_modulo'; // Length is not modulo 4 + const SOCKET_ERROR_INVALID_BASE64_MESSAGE = 'base64_message'; // Raw data is not Base64-encoded + const SOCKET_ERROR_UNHANDLED = 'unhandled_package'; // Unhandled raw data (not bad) + const SOCKET_ERROR_CONNECTION_REFUSED = 'connection_refused'; // The name says it: connection refused + const SOCKET_ERROR_CONNECTION_TIMED_OUT = 'connection_timed_out'; // The name says it: connection attempt has timed-out + const SOCKET_ERROR_OPERATION_IN_PROGRESS = 'operation_in_progress'; // 'Operation now in progress' + const SOCKET_ERROR_OPERATION_ALREADY_PROGRESS = 'operation_already_progress'; // 'Operation already in progress' + const SOCKET_ERROR_RESOURCE_UNAVAILABLE = 'resource_unavailable'; // 'Resource temporary unavailable' + const SOCKET_ERROR_NO_ROUTE_TO_HOST = 'no_route_to_host'; // The name says it: no route to host + const SOCKET_ERROR_CONNECTION_RESET_BY_PEER = 'connection_reset_by_peer'; // Connection reset by peer + const SOCKET_ERROR_BROKEN_PIPE = 'broken_pipe'; // Broken pipe + const SOCKET_CONNECTED = 'connected'; // Nothing errorous happens, socket is connected + + // - Package errors + const PACKAGE_ERROR_INVALID_DATA = 'invalid_data'; // Invalid data in package found + const PACKAGE_ERROR_INCOMPLETE_DATA = 'incomplete_data'; // Incomplete data sent (e.g. field is missing) + const PACKAGE_ERROR_INVALID_CONTENT = 'invalid_content'; // Content is invalid (e.g. not well-formed) + const PACKAGE_ERROR_RECIPIENT_MISMATCH = 'recipient_error'; // Recipient is not us + const PACKAGE_LEVEL_CHECK_OKAY = 'checked_package'; // Package is fine + + // Package data + const PACKAGE_RAW_DATA = 'raw_data'; + const PACKAGE_ERROR_CODE = 'error_code'; + + // Start/end marker + const STREAM_START_MARKER = '[[S]]'; + const STREAM_END_MARKER = '[[E]]'; + + /** + * Stacker for raw data + */ + const STACKER_NAME_RAW_DATA = 'raw_data'; + + /** + * Error code from socket + */ + private $errorCode = -1; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Set error code to 'unknown' + $this->setErrorCode(self::SOCKET_ERROR_UNKNOWN); + + // Init stacker instance for processed raw data + $stackInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_stacker_class'); + + // Remember this in this package handler + $this->setStackInstance($stackInstance); + + // Init stacker + $this->initStack(); + } + + /** + * Initializes the stacker for raw data + * + * @return void + */ + protected function initStack () { + $this->getStackInstance()->initStack(self::STACKER_NAME_RAW_DATA); + } + + /** + * Adds given raw data to the raw data stacker + * + * @param $rawData raw data from the socket resource + * @return void + */ + protected function addRawDataToStacker ($rawData) { + /* + * Add the deocoded data and error code to the stacker so other classes + * (e.g. NetworkPackage) can "pop" it from the stacker. + */ + $this->getStackInstance()->pushNamed(self::STACKER_NAME_RAW_DATA, array( + self::PACKAGE_RAW_DATA => $rawData, + self::PACKAGE_ERROR_CODE => $this->getErrorCode() + )); + } + + /** + * Checks whether raw data is pending for further processing. + * + * @return $isPending Whether raw data is pending + */ + public function isRawDataPending () { + // Does the stacker have some entries (not empty)? + $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA)); + + // Return it + return $isPending; + } + + /** + * "Getter" for next raw data from the stacker + * + * @return $rawData Raw data from the stacker + */ + public function getNextRawData () { + // "Pop" the raw data from the stacker + $rawData = $this->getStackInstance()->popNamed(self::STACKER_NAME_RAW_DATA); + + // And return it + return $rawData; + } + + /** + * Checks whether the 'recipient' field matches our own an universal node + * locator. + * + * @param $packageData Raw package data + * @return $matches Whether it matches + * @todo This method will be moved to a better place + */ + protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) { + // Construct own address first + $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator(); + + // Does it match? + $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + + // Return result + return $matches; + } + + /** + * Setter for error code + * + * @param $errorCode The error code we shall set + * @return void + */ + public final function setErrorCode ($errorCode) { + $this->errorCode = $errorCode; + } + + /** + * Getter for error code + * + * @return $errorCode The error code + */ + public final function getErrorCode () { + return $this->errorCode; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/network/tcp/.htaccess b/application/hub/classes/handler/network/tcp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/network/tcp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/network/tcp/class_ b/application/hub/classes/handler/network/tcp/class_ new file mode 100644 index 000000000..96b146f9f --- /dev/null +++ b/application/hub/classes/handler/network/tcp/class_ @@ -0,0 +1,208 @@ +while (count($clients) > 0) { + // create a copy, so $clients doesn't get modified by socket_select() + $read = $clients; + + // get a list of all the clients that have data to be read from + // if there are no clients with data, go to next iteration + $left = @socket_select($read, $write = null, $except = null, 0, 150); + if ($left < 1) { + continue; + } + + // check if there is a client trying to connect + if (in_array($mainSocket, $read)) { + // accept the client, and add him to the $clients array + $new_sock = socket_accept($mainSocket); + $clients[] = $new_sock; + + // send the client a welcome message + socket_write($new_sock, "No noobs, but I'll make an exception. :)\n". + "There are ".(count($clients) - 1)." client(s) connected to the server.\n"); + + socket_getpeername($new_sock, $ip); + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}"); + + // Notify all chatter + if (count($clients) > 2) { + foreach ($clients as $send_sock) { + if ($send_sock != $mainSocket && $send_sock != $new_sock) { + socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n"); + } + } + } + + // remove the listening socket from the clients-with-data array + $key = array_search($mainSocket, $read); + unset($read[$key]); + } + + // loop through all the clients that have data to read from + foreach ($read as $read_sock) { + // Get client data + socket_getpeername($read_sock, $ip); + + // read until newline or 1024 bytes + // socket_read while show errors when the client is disconnected, so silence the error messages + $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ); + + // check if the client is disconnected + if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) { + + // remove client for $clients array + $key = array_search($read_sock, $clients); + unset($clients[$key]); + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1).""); + + // Notify all chatter + if (count($clients) > 1) { + foreach ($clients as $send_sock) { + if ($send_sock != $mainSocket) { + socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n"); + } + } + } + + // continue to the next client to read from, if any + socket_write($read_sock, "Server: Good bye.\n"); + socket_shutdown($read_sock, 2); + socket_close($read_sock); + continue; + } elseif (in_array(trim($data), $shutdown)) { + // Is he allowed to shutdown? + if (!in_array($ip, $masters)) { + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!"); + socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n"); + $data = ""; + continue; + } + + // Close all connections a leave here + foreach ($clients as $client) { + // Send message to client + if ($client !== $mainSocket && $client != $read_sock) { + socket_write($client, "Server: Shutting down! Thank you for joining us.\n"); + } + + // Quit him + socket_shutdown($client, 2); + socket_close($client); + } // end foreach + + // Leave the loop + $data = ""; + $clients = array(); + continue; + } + + // trim off the trailing/beginning white spaces + $data = trim($data); + + // Test for HTML codes + $tags = strip_tags($data); + + // check if there is any data after trimming off the spaces + if (!empty($data) && $tags == $data && count($clients) > 2) { + // Send confirmation to "chatter" + socket_write($read_sock, "\nServer: Message accepted.\n"); + + // send this to all the clients in the $clients array (except the first one, which is a listening socket) + foreach ($clients as $send_sock) { + + // if its the listening sock or the client that we got the message from, go to the next one in the list + if ($send_sock == $mainSocket || $send_sock == $read_sock) + continue; + + // write the message to the client -- add a newline character to the end of the message + socket_write($send_sock, "{$ip}:{$data}\n"); + + } // end of broadcast foreach + } elseif ($tags != $data) { + // HTML codes are not allowed + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!"); + socket_write($read_sock, "Server: HTML is forbidden!\n"); + } elseif ((count($clients) == 2) && ($read_sock != $mainSocket)) { + // No one else will hear the "chatter" + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself."); + socket_write($read_sock, "Server: No one will hear you!\n"); + } + } // end of reading foreach +} + +// close the listening socket +socket_close($mainSocket); + +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Listener extends BaseListener implements Listenable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public final static function create???Listener (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new ???Listener(); + + // Set the application instance + $listenerInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + * @todo 0% done + */ + public function initListener() { + $this->partialStub('Need to implement this method.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + * @todo 0% done + */ + public function doListen() { + $this->partialStub('Need to implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php new file mode 100644 index 000000000..1c8532a4b --- /dev/null +++ b/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php @@ -0,0 +1,124 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { + /** + * Last socket error (default: Success) + */ + private $lastSocketError = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('tcp'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a Networkable class + */ + public static final function createTcpRawDataHandler () { + // Get new instance + $handlerInstance = new TcpRawDataHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Processes raw data from given resource. This is mostly useful for TCP + * package handling and is implemented in the TcpListener class + * + * @param $resource A valid socket resource array + * @return void + */ + public function processRawDataFromResource (array $socketArray) { + // Check the resource + if ((!isset($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])) || (!is_resource($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]))) { + // Throw an exception + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } // END - if + + // Reset error code to unhandled + $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError)); + + /* + * Read the raw data from socket. If you change PHP_BINARY_READ to + * PHP_NORMAL_READ, this line will endless block. This script does only + * provide simultanous threads, not real. + */ + $rawData = socket_read($socketArray[BasePool::SOCKET_ARRAY_RESOURCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); + + // Get socket error code back + $this->lastSocketError = socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); + + // Debug output of read data length + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror($this->lastSocketError)); + //* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: rawData=' . $rawData); + + // Is it valid? + if ($this->lastSocketError == 11) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); + + /* + * Error code 11 (Resource temporary unavailable) can be safely + * ignored on non-blocking sockets. The socket is currently not + * sending any data. + */ + socket_clear_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); + + // Skip any further processing + return; + } elseif (($rawData === FALSE) || ($this->lastSocketError > 0)) { + // Network error or connection lost + $this->setErrorCode($this->lastSocketError); + } elseif (empty($rawData)) { + // The peer did send nothing to us which is now being ignored + return; + } else { + /* + * All is fine at this point. So it is okay to add the raw data to + * the stacker. Here it doesn't matter if the raw data is a + * well-formed BASE64-encoded message with start and markers. This + * will be checked later on. + */ + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($rawData) . ' bytes to stacker ...'); + $this->addRawDataToStacker($rawData); + } + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/network/udp/.htaccess b/application/hub/classes/handler/network/udp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/network/udp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php b/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php new file mode 100644 index 000000000..a0d4cc132 --- /dev/null +++ b/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php @@ -0,0 +1,73 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UdpRawDataHandler extends BaseRawDataHandler implements Networkable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('udp'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a Networkable class + */ + public static final function createUdpRawDataHandler () { + // Get new instance + $handlerInstance = new UdpRawDataHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Processes raw data from given resource. This is mostly useful for UDP + * package handling and is implemented in the UdpListener class + * + * @param $socketArray A valid socket resource array + * @return void + * @throws InvalidResourceException If the given resource is invalid + * @todo 0% + */ + public function processRawDataFromResource (array $socketArray) { + // Check the resource + if ((!isset($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])) || (!is_resource($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]))) { + // Throw an exception + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } // END - if + + // Implement processing here + $this->partialStub('Please implement this method. resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRRAY_CONN_TYPE]); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/protocol/.htaccess b/application/hub/classes/handler/protocol/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/protocol/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/protocol/class_ b/application/hub/classes/handler/protocol/class_ new file mode 100644 index 000000000..665316593 --- /dev/null +++ b/application/hub/classes/handler/protocol/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???ProtocolHandler extends BaseProtocolHandler implements HandleableProtocol, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('|||_protocol'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function create???ProtocolHandler () { + // Get new instance + $handlerInstance = new ???ProtocolHandler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php new file mode 100644 index 000000000..cf085db57 --- /dev/null +++ b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php @@ -0,0 +1,201 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseProtocolHandler extends BaseHandler { + /** + * Whole UNL data array + */ + private $universalNodeLocatorData = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for UNL data array to satify HandleableProtocol + * + * @para $unlData The UNL data array + * @return void + */ + protected final function setUniversalNodeLocatorData (array $unlData) { + // Set new UNL data array + $this->universalNodeLocatorData = $unlData; + } + + /** + * Getter for UNL data array to satify HandleableProtocol + * + * @return $unlData The UNL data array + */ + public final function getUniversalNodeLocatorDataArray () { + // Return UNL data array + return $this->universalNodeLocatorData; + } + + /** + * Validates given UNL very basicly by given regular expression. You + * normally don't need/want to overwrite this method as this is a very basic + * validation only based on a regex. + * + * @param $unl Universal Node Locator to validate + * @return $isValid Whether the UNL is valid + */ + protected final function isValidUniversalNodeLocator ($unl) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',regex=' . $regex . ' - CALLED!'); + + // Very basic regex check + $isValid = (preg_match($this->getRegularExpression(), $unl) === 1); + + // Return result + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: isValid=' . intval($isValid) . ' - EXIT!'); + return $isValid; + } + + /** + * Parses the given UNL by splitting it up in its components. The UNL ... + * + * protocol://address[:port] + * + * ... becomes: + * + * array( + * 'protocol' => 'value', + * 'address' => 'value', + * 'extra' => 'port' + * ) + * + * The value for 'extra' then must be handled by parseUniversalNodeLocator() + * of the individual protocol handler as this is protocol-specific. + * + * @param $unl Universal Node Locator (UNL) to "parse" + * @return $unlData Array with all components of the UNL + */ + protected function parseGenericUniversalNodeLocator ($unl) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ' - CALLED!'); + + // Make sure the UNL is valid + assert($this->isValidUniversalNodeLocator($unl)); + + /* + * "Parse" the UNL "generically", sadly this cannot be done by using preg_match() :-( + * @TODO If you know why, please fix and explain it to me. + */ + $unlParts = explode('://', $unl); + + // Split again the last part as: address:port + $unlParts[1] = explode(':', $unlParts[1]); + + // Now there is an almost useable array which then can be copied to the "real" array. + $unlData = array( + UniversalNodeLocator::UNL_PART_PROTOCOL => $unlParts[0], + UniversalNodeLocator::UNL_PART_ADDRESS => $unlParts[1][0], + UniversalNodeLocator::UNL_PART_EXTRA => $unlParts[1][1] + ); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unlData=' . print_r($unlData, TRUE) . ' - EXIT!'); + + // Return the generic array + return $unlData; + } + + /** + * Gets an element from universalNodeLocatorData array + * + * @param $element Element in universalNodeLocatorData array + * @return $value Found value + */ + protected final function getUniversalNodeLocatorDataElement ($element) { + // Is the element there? + assert(isset($this->universalNodeLocatorData[$element])); + + // Return it + return $this->universalNodeLocatorData[$element]; + } + + /** + * "Getter" for currently saved UNL + * + * @return $unl Currently saved Universal Node Locator + */ + public final function getCurrentUniversalNodeLocator () { + // Construct generic UNL + $unl = sprintf('%s://%s', + $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_PROTOCOL), + $this->getAddressPart() + ); + + // Return it + return $unl; + } + + /** + * Default implementation for returning address part, may not be suitable + * for IPv4/IPv6 protocol handlers. So you have to overwrite (NOT CHANGE!) this method. + * + * @return $address Address part for the final UNL + */ + public function getAddressPart () { + // Return it + return $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_ADDRESS); + } + + /** + * If the found UNL (address) matches own external or internal address + * + * @param $unl UNL to test + * @return $ifMatches Whether the found UNL matches own addresss + */ + public function isOwnAddress ($unl) { + // Get own external UNL + $externalUnl = HubTools::determineOwnExternalAddress(); + + // Get internal UNL + $internalUnl = HubTools::determineOwnInternalAddress(); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',externalUnl=' . $externalUnl . ',internalUnl=' . $internalUnl); + //* DIE-DEBUG: */ die(__METHOD__.':unl=' . $unl . ',this='.print_r($this, TRUE)); + + // Is it the same? + $ifMatches = (($unl === $externalUnl) || ($unl === $internalUnl)); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: ifMatches=' . intval($ifMatches)); + + // Return result + return $ifMatches; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/protocol/ipv4/.htaccess b/application/hub/classes/handler/protocol/ipv4/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/protocol/ipv4/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/protocol/ipv4/class_ b/application/hub/classes/handler/protocol/ipv4/class_ new file mode 100644 index 000000000..665316593 --- /dev/null +++ b/application/hub/classes/handler/protocol/ipv4/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???ProtocolHandler extends BaseProtocolHandler implements HandleableProtocol, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('|||_protocol'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function create???ProtocolHandler () { + // Get new instance + $handlerInstance = new ???ProtocolHandler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php new file mode 100644 index 000000000..686f00685 --- /dev/null +++ b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php @@ -0,0 +1,176 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseIpV4ProtocolHandler extends BaseProtocolHandler { + // Regular expression for validating IP:port UNLs + const UNL_REGEX = '/^([a-z]{1,}):\/\/\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b:(6553[0-5]|655[0-2][0-9]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$/'; + + /** + * Port number + */ + private $port = 0; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Set regex + $this->setRegularExpression(self::UNL_REGEX); + } + + /** + * Setter for port number to satify HandleableProtocol + * + * @para $port The port number + * @return void + */ + protected final function setPort ($port) { + // Set new port number + $this->port = $port; + } + + /** + * Getter for port number to satify HandleableProtocol + * + * @return $port The port number + */ + public final function getPort () { + // Return port number + return $this->port; + } + + /** + * Parses the given UNL by splitting it up in its components. The UNL ... + * + * protocol://address[:port] + * + * ... becomes: + * + * array( + * 'protocol' => 'value', + * 'address' => 'value', + * 'port' => 123 + * ) + * + * @param $unl Universal Node Locator (UNL) to "parse" + * @return $unlData Array with all components of the UNL + */ + protected function parseUniversalNodeLocator ($unl) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ' - CALLED!'); + + // First generic parse + $unlData = parent::parseGenericUniversalNodeLocator($unl); + + /* + * Make sure the generic parts are all there. In case of a rewrite, + * these assertitions will bail out on badly formed arrays. + */ + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_EXTRA])); + + // Copy 'extra' -> 'port' ... + $unlData[UniversalNodeLocator::UNL_PART_PORT] = $unlData[UniversalNodeLocator::UNL_PART_EXTRA]; + + // ... and drop 'extra' + unset($unlData[UniversalNodeLocator::UNL_PART_EXTRA]); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unlData=' . print_r($unlData, TRUE) . ' - EXIT!'); + return $unlData; + } + + /** + * Validates given 'recipient' if it is a valid UNL. This means that the UNL + * can be parsed by the protocol handler. + * + * @param $packageData Valid raw package data + * @return $isValid Whether the UNL can be validated + */ + public function isValidUniversalNodeLocatorByPackageData (array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Is 'recipient' there? + assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); + + // Is the correct handler choosen? + assert(substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($this->getHandlerName())) != $this->getHandlerName()); + + // Default is from generic validation + $isValid = $this->isValidUniversalNodeLocator($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: PACKAGE_DATA_RECIPIENT=' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ',isValid[' . gettype($isValid) . ']=' . intval($isValid)); + + // If this doesn't fail, continue validating the IP:port combination + if ($isValid === TRUE) { + // ... and validate IP:port, first "parse" the UNL + $unlData = $this->parseUniversalNodeLocator($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + + /* + * Make sure the extra field 'port' is there. This may look + * superflious but in case of a rewrite this assert will stop at + * badly formated arrays. + */ + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); + + // Set whole UNL data array + $this->setUniversalNodeLocatorData($unlData); + + // Set port + $this->setPort($unlData[UniversalNodeLocator::UNL_PART_PORT]); + } // END - if + + // Return result + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: isValid=' . intval($isValid) . ' - EXIT!'); + return $isValid; + } + + /** + * This implementation uses it's parent method and combines it with the + * port part to construct a valid address:port combination. + * + * @return $address Address part for the final UNL + */ + public function getAddressPart () { + // Construct address + $address = sprintf('%s:%s', + parent::getAddressPart(), + $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_PORT) + ); + + // Return it + return $address; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/handler/protocol/ipv4/tcp/.htaccess b/application/hub/classes/handler/protocol/ipv4/tcp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/handler/protocol/ipv4/tcp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php b/application/hub/classes/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php new file mode 100644 index 000000000..586199681 --- /dev/null +++ b/application/hub/classes/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php @@ -0,0 +1,54 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TcpProtocolHandler extends BaseIpV4ProtocolHandler implements HandleableProtocol, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler and protocol type + $this->setHandlerName('tcp_protocol'); + $this->setProtocolName('tcp'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function createTcpProtocolHandler () { + // Get new instance + $handlerInstance = new TcpProtocolHandler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/.htaccess b/application/hub/classes/helper/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/class_ b/application/hub/classes/helper/class_ new file mode 100644 index 000000000..e982dd39d --- /dev/null +++ b/application/hub/classes/helper/class_ @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class !!!???Helper extends BaseHubSystemHelper implements Helpable!!! { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_```); + + // Set package tags + $this->setPackageTags(array('???')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function create!!!???Helper () { + // Get new instance + $helperInstance = new !!!???Helper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @return void + */ + public function loadDescriptorXml () { + $this->partialStub('Please implement this method.'); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $|||Instance An instance of a !!!Helper class + * @return void + */ + public function sendPackage (!!!Helper $|||Instance) { + // Sanity check: Is the ||| in the approx. state? (///) + $|||Instance->getStateInstance()->validate!!!StateIs+++(); + + // Compile the template, this inserts the loaded ||| data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/class_BaseHubSystemHelper.php b/application/hub/classes/helper/class_BaseHubSystemHelper.php new file mode 100644 index 000000000..38d6a9c5e --- /dev/null +++ b/application/hub/classes/helper/class_BaseHubSystemHelper.php @@ -0,0 +1,96 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubSystemHelper extends BaseHubSystem implements HubHelper { + /** + * Recipient type + */ + private $recipientType = 'invalid'; + + /** + * Package tags + */ + private $packageTags = array(); + + /** + * Protected constructor + * + * @param $className Name of the concrete class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for recipient type + * + * @return $recipientType Type of a recipient (the helper is made for) + */ + protected final function setRecipientType ($recipientType) { + $this->recipientType = $recipientType; + } + + /** + * Getter for recipient type + * + * @return $recipientType Type of a recipient (the helper is made for) + */ + public final function getRecipientType () { + return $this->recipientType; + } + + /** + * Getter for package tags in a simple array + * + * @return $packageTags An array with all tags for the currently handled package + */ + public final function getPackageTags () { + return $this->packageTags; + } + + /** + * Setter for package tags in a simple array + * + * @param $packageTags An array with all tags for the currently handled package + * @return void + */ + public final function setPackageTags (array $packageTags) { + $this->packageTags = $packageTags; + } + + /** + * Tries to determine the used protocol for this package (this helper is helping to send out) + * + * @return $protocolType Type of protocol to use, usually TCP + * @todo 0% done + */ + public function determineProtocolType () { + die(__METHOD__ . ':' . print_r($this, TRUE)); + // Return it + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/connection/.htaccess b/application/hub/classes/helper/connection/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/connection/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/connection/class_ b/application/hub/classes/helper/connection/class_ new file mode 100644 index 000000000..8d29049ea --- /dev/null +++ b/application/hub/classes/helper/connection/class_ @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???ConnectionHelper extends BaseConnectionHelper implements ConnectionHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set protocol + $this->setProtocolName('!!!'); + } + + /** + * Creates a socket resource ("connection") for given recipient in package data + * + * @param $packageData Raw package data + * @return $socketResource Socket resource + */ + public static function createConnectionFromPackageData (array $packageData) { + die(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php new file mode 100644 index 000000000..78e2db83d --- /dev/null +++ b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php @@ -0,0 +1,349 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseConnectionHelper extends BaseHubSystemHelper implements Registerable { + // Exception codes + const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x9100; + + /** + * Connection type 'incoming' + */ + const CONNECTION_TYPE_INCOMING = 'incoming'; + + /** + * Connection type 'outgoing' + */ + const CONNECTION_TYPE_OUTGOING = 'outgoing'; + + /** + * Connection type 'server' + */ + const CONNECTION_TYPE_SERVER = 'server'; + + /** + * Name of used protocol for this connection + */ + private $connectionType = 'invalid'; + + /** + * (IP) Adress used + */ + private $address = 0; + + /** + * Sent data in bytes + */ + private $sentData = 0; + + /** + * Whether this connection is initialized + */ + private $isInitialized = FALSE; + + /** + * Whether this connection is shutted down + */ + private $shuttedDown = FALSE; + + /** + * Currently queued chunks + */ + private $queuedChunks = array(); + + /** + * Current final hash + */ + private $currentFinalHash = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init state which sets the state to 'init' + $this->initState(); + + // Initialize output stream + $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_output_stream_class'); + + // And add it to this connection helper + $this->setOutputStreamInstance($streamInstance); + + // Get package instance from factory + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // ... and set it here + $this->setPackageInstance($packageInstance); + + // Register this connection helper + Registry::getRegistry()->addInstance('connection', $this); + + // Get the fragmenter instance + $fragmenterInstance = FragmenterFactory::createFragmenterInstance('package'); + + // Set it here + $this->setFragmenterInstance($fragmenterInstance); + } + + /** + * Getter for real class name, overwrites generic method and is final + * + * @return $class Name of this class + */ + public final function __toString () { + // Class name representation + $class = self::getConnectionClassName($this->getAddress(), $this->getConnectionPort(), parent::__toString()); + + // Return it + return $class; + } + + /** + * Getter for connection type + * + * @return $connectionType Name of used protocol in this connection + */ + public final function getConnectionType () { + return $this->connectionType; + } + + /** + * Setter for connection type + * + * @param $connectionType Name of used protocol in this connection + * @return void + */ + protected final function setConnectionType ($connectionType) { + $this->connectionType = $connectionType; + } + + /** + * Getter for IP address + * + * @return $address The IP address + */ + public final function getAddress () { + return $this->address; + } + + /** + * Setter for IP address + * + * @param $address The IP address + * @return void + */ + protected final function setAddress ($address) { + $this->address = $address; + } + + /** + * Setter for isInitialized + * + * @param $isInitialized Name of used protocol in this connection + * @return void + */ + protected final function setIsInitialized ($isInitialized) { + $this->isInitialized = $isInitialized; + } + + /** + * Getter for isInitialized (NOTE: no 'get' prefix for boolean attributes!) + * + * @return $isInitialized Name of used protocol in this connection + */ + protected final function isInitialized () { + return $this->isInitialized; + } + + /** + * Static "getter" for this connection class' name + * + * @param $address IP address + * @param $port Port number + * @param $className Original class name + * @return $class Expanded class name + */ + public static function getConnectionClassName ($address, $port, $className) { + // Construct it + $class = $address . ':' . $port . ':' . $className; + + // ... and return it + return $class; + } + + /** + * Initializes the peer's state which sets it to 'init' + * + * @return void + */ + private function initState() { + // Get the state factory and create the initial state. + PeerStateFactory::createPeerStateInstanceByName('init', $this); + } + + /** + * "Getter" for raw data from a package array. A fragmenter is used which + * will returns us only so many raw data which fits into the back buffer. + * The rest is being held in a back-buffer and waits there for the next + * cycle and while be then sent. + * + * This method does 2 simple steps: + * 1) Request a chunk from set fragmenter instance + * 2) Finally return the chunk (array) to the caller + * + * @param $packageData Raw package data array + * @return $chunkData Raw data chunk + */ + private function getRawDataFromPackageArray (array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: currentFinalHash=' . $this->currentFinalHash); + + // Make sure the final hash is set + assert((is_string($this->currentFinalHash)) && (!empty($this->currentFinalHash))); + + // Get the next raw data chunk from the fragmenter + $rawDataChunk = $this->getFragmenterInstance()->getNextRawDataChunk($this->currentFinalHash); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: rawDataChunk=' . print_r($rawDataChunk, TRUE)); + + // Get chunk hashes and chunk data + $chunkHashes = array_keys($rawDataChunk); + $chunkData = array_values($rawDataChunk); + + // Is the required data there? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('chunkData='.print_r($chunkData, TRUE)); + if ((isset($chunkHashes[0])) && (isset($chunkData[0]))) { + // Remember this chunk as queued + $this->queuedChunks[$chunkHashes[0]] = $chunkData[0]; + + // Return the raw data + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...'); + return $chunkData[0]; + } else { + // Return zero string + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Returning zero bytes from ' . __METHOD__ . '!'); + return ''; + } + } + + /** + * "Accept" a visitor by simply calling it back + * + * @param $visitorInstance A Visitor instance + * @return void + */ + protected final function accept (Visitor $visitorInstance) { + // Just call the visitor + $visitorInstance->visitConnectionHelper($this); + } + + /** + * Sends raw package data to the recipient + * + * @param $packageData Raw package data + * @return void + * @throws InvalidSocketException If we got a problem with this socket + */ + public function sendRawPackageData (array $packageData) { + // The helper's state must be 'connected' + $this->getStateInstance()->validatePeerStateConnected(); + + // Implode the package data array and fragement the resulting string, returns the final hash + $finalHash = $this->getFragmenterInstance()->fragmentPackageArray($packageData, $this); + + // Is the final hash set? + if ($finalHash !== TRUE) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Setting finalHash=' . $finalHash . ',currentFinalHash[' . gettype($this->currentFinalHash) . ']=' . $this->currentFinalHash); + + // Set final hash + $this->currentFinalHash = $finalHash; + } // END - if + + // Reset serial number + $this->getFragmenterInstance()->resetSerialNumber($this->currentFinalHash); + + // Init variables + $rawData = ''; + $dataStream = ' '; + + // Fill sending buffer with data + while (strlen($dataStream) > 0) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE)); + + // Convert the package data array to a raw data stream + $dataStream = $this->getRawDataFromPackageArray($packageData); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...'); + $rawData .= $dataStream; + } // END - while + + // Nothing to sent is bad news, so assert on it + assert(strlen($rawData) > 0); + + // Calculate buffer size + $bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length'); + + // Encode the raw data with our output-stream + $encodedData = $this->getOutputStreamInstance()->streamData($rawData); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[]=' . gettype($this->getSocketResource()) . PHP_EOL); + + // Init array + $encodedDataArray = array( + NetworkPackage::RAW_FINAL_HASH_INDEX => $this->currentFinalHash, + NetworkPackage::RAW_ENCODED_DATA_INDEX => $encodedData, + NetworkPackage::RAW_SENT_BYTES_INDEX => 0, + NetworkPackage::RAW_SOCKET_INDEX => $this->getSocketResource(), + NetworkPackage::RAW_BUFFER_SIZE_INDEX => $bufferSize, + NetworkPackage::RAW_DIFF_INDEX => 0 + ); + + // Calculate difference + $diff = $encodedDataArray[NetworkPackage::RAW_BUFFER_SIZE_INDEX] - strlen($encodedDataArray[NetworkPackage::RAW_ENCODED_DATA_INDEX]); + + // Push raw data to the package's outgoing stack + $this->getPackageInstance()->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); + } + + /** + * Getter for shuttedDown + * + * @return $shuttedDown Whether this connection is shutted down + */ + public final function isShuttedDown () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown)); + return $this->shuttedDown; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/connection/ipv4/.htaccess b/application/hub/classes/helper/connection/ipv4/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/connection/ipv4/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php new file mode 100644 index 000000000..3db9b16c9 --- /dev/null +++ b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php @@ -0,0 +1,335 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseIpV4ConnectionHelper extends BaseConnectionHelper { + /** + * Port number used + */ + private $connectionPort = 0; + + /** + * Protected constructor + * + * @param $className Name of implementing class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for port number to satify HandleableProtocol + * + * @return $connectionPort The port number + */ + public final function getConnectionPort () { + return $this->connectionPort; + } + + /** + * Setter for port number to satify HandleableProtocol + * + * @param $connectionPort The port number + * @return void + */ + protected final function setConnectionPort ($connectionPort) { + $this->connectionPort = $connectionPort; + } + + /** + * Initializes the current connection + * + * @return void + * @throws SocketOptionException If setting any socket option fails + */ + protected function initConnection () { + // Get socket resource + $socketResource = $this->getSocketResource(); + + // Set the option to reuse the port + if (!socket_set_option($socketResource, SOL_SOCKET, SO_REUSEADDR, 1)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); + + // And throw again + // @TODO Move this to the socket error handler + throw new SocketOptionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + /* + * Set socket to non-blocking mode before trying to establish a link to + * it. This is now the default behaviour for all connection helpers who + * call initConnection(); . + */ + if (!socket_set_nonblock($socketResource)) { + // Handle this socket error with a faked recipientData array + $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); + + // And throw again + throw new SocketOptionException(array($helperInstance, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + // Last step: mark connection as initialized + $this->setIsInitialized(TRUE); + } + + /** + * Attempts to connect to a peer by given IP number and port from a valid + * unlData array with currently configured timeout. + * + * @param $unlData Valid UNL data array + * @return $isConnected Whether the connection went fine + * @see Please see http://de.php.net/manual/en/function.socket-connect.php#84465 for original code + * @todo Rewrite the while() loop to a iterator to not let the software stay very long here + */ + protected function connectToPeerByUnlData (array $unlData) { + // Only call this if the connection is initialized by initConnection() + assert($this->isInitialized()); + + // Is unlData complete? + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); + + // Get current time + $time = time(); + + // "Cache" socket resource and timeout config + $socketResource = $this->getSocketResource(); + $timeout = $this->getConfigInstance()->getConfigEntry('socket_timeout_seconds'); + + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Trying to connect to ' . $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] . ':' . $unlData[UniversalNodeLocator::UNL_PART_PORT] . ' with socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' ...'); + + // Try to connect until it is connected + while ($isConnected = !@socket_connect($socketResource, $unlData[UniversalNodeLocator::UNL_PART_ADDRESS], $unlData[UniversalNodeLocator::UNL_PART_PORT])) { + // Get last socket error + $socketError = socket_last_error($socketResource); + + // Skip any errors which may happen on non-blocking connections + if (($socketError == SOCKET_EINPROGRESS) || ($socketError == SOCKET_EALREADY)) { + // Now, is that attempt within parameters? + if ((time() - $time) >= $timeout) { + // Didn't work within timeout + $isConnected = FALSE; + break; + } // END - if + + // Sleep about one second + $this->idle(1000); + } elseif ($socketError != 0) { + // Stop on everything else pronto + $isConnected = FALSE; + break; + } + } // END - while + + // Is the peer connected? + if ($isConnected === TRUE) { + // Connection is fully established here, so change the state. + PeerStateFactory::createPeerStateInstanceByName('connected', $this); + } else { + /* + * There was a problem connecting to the peer (this state is a meta + * state until the error handler has found the real cause). + */ + PeerStateFactory::createPeerStateInstanceByName('problem', $this); + } + + // Return status + return $isConnected; + } + + /** + * Marks this connection as shutted down + * + * @return void + */ + protected final function markConnectionShuttedDown () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $this->__toString() . ' has been marked as shutted down'); + $this->shuttedDown = TRUE; + + // And remove the (now invalid) socket + $this->setSocketResource(FALSE); + } + + // ************************************************************************ + // Socket error handler call-back methods + // ************************************************************************ + + /** + * Handles socket error 'connection timed out', but does not clear it for + * later debugging purposes. + * + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + * @throws SocketConnectionException The connection attempts fails with a time-out + */ + protected function socketErrorConnectionTimedOutHandler ($socketResource, array $unlData) { + // Get socket error code for verification + $socketError = socket_last_error($socketResource); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($socketResource); + + // Throw it again + throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } + + /** + * Handles socket error 'resource temporary unavailable', but does not + * clear it for later debugging purposes. + * + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + * @throws SocketConnectionException The connection attempts fails with a time-out + */ + protected function socketErrorResourceUnavailableHandler ($socketResource, array $unlData) { + // Get socket error code for verification + $socketError = socket_last_error($socketResource); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($socketResource); + + // Throw it again + throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } + + /** + * Handles socket error 'connection refused', but does not clear it for + * later debugging purposes. + * + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + * @throws SocketConnectionException The connection attempts fails with a time-out + */ + protected function socketErrorConnectionRefusedHandler ($socketResource, array $unlData) { + // Get socket error code for verification + $socketError = socket_last_error($socketResource); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($socketResource); + + // Throw it again + throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } + + /** + * Handles socket error 'no route to host', but does not clear it for later + * debugging purposes. + * + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + * @throws SocketConnectionException The connection attempts fails with a time-out + */ + protected function socketErrorNoRouteToHostHandler ($socketResource, array $unlData) { + // Get socket error code for verification + $socketError = socket_last_error($socketResource); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($socketResource); + + // Throw it again + throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } + + /** + * Handles socket error 'operation already in progress' which happens in + * method connectToPeerByUnlData() on timed out connection + * attempts. + * + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + * @throws SocketConnectionException The connection attempts fails with a time-out + */ + protected function socketErrorOperationAlreadyProgressHandler ($socketResource, array $unlData) { + // Get socket error code for verification + $socketError = socket_last_error($socketResource); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Half-shutdown this socket (see there for difference to shutdownSocket()) + $this->halfShutdownSocket($socketResource); + + // Throw it again + throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } + + /** + * Handles socket error 'connection reset by peer', but does not clear it for + * later debugging purposes. + * + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + * @throws SocketConnectionException The connection attempts fails with a time-out + */ + protected function socketErrorConnectionResetByPeerHandler ($socketResource, array $unlData) { + // Get socket error code for verification + $socketError = socket_last_error($socketResource); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($socketResource); + + // Throw it again + throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } + + /** + * Handles socket "error" 'operation now in progress' which can be safely + * passed on with non-blocking connections. + * + * @param $socketResource A valid socket resource + * @param $unlData A valid UNL data array + * @return void + */ + protected function socketErrorOperationInProgressHandler ($socketResource, array $unlData) { + self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Operation is now in progress, this is usual for non-blocking connections and is no bug.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/connection/ipv4/tcp/.htaccess b/application/hub/classes/helper/connection/ipv4/tcp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/connection/ipv4/tcp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php new file mode 100644 index 000000000..682c181bb --- /dev/null +++ b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php @@ -0,0 +1,188 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements ConnectionHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set protocol + $this->setProtocolName('tcp'); + } + + /** + * Creates a half-connected socket resource ("connection") for given + * recipient in package data. After you called this method you still need to + * connect to the other node. + * + * @param $packageData Raw package data + * @return $socketResource Socket resource + * @throws SocketCreationException If the socket could not be created + * @throws SocketOptionException If a socket option could not be set + * @throws SocketConnectionException If a connection could not be opened + * @todo $errorCode/-Message are now in handleSocketError()'s call-back methods + */ + public static function createConnectionFromPackageData (array $packageData) { + // Create an instance + $helperInstance = new TcpConnectionHelper(); + + // Create a socket instance + $socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + + // Is the socket resource valid? + if (!is_resource($socketResource)) { + /* + * Something bad happened, calling handleSocketError() is not + * possible here because that method would throw an + * InvalidSocketException back. + */ + throw new SocketCreationException(array($helperInstance, gettype($socketResource)), BaseListener::EXCEPTION_SOCKET_CREATION_FAILED); + } // END - if + + // Get socket error code for verification + $socketError = socket_last_error($socketResource); + + // Check if there was an error else + if ($socketError > 0) { + // Handle this socket error with a faked recipientData array + $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); + + // Then throw again + throw new SocketCreationException(array($helperInstance, gettype($socketResource), $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_SOCKET_CREATION_FAILED); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Setting socket resource ... (' . gettype($socketResource) . ')'); + + // Set the resource + $helperInstance->setSocketResource($socketResource); + + // Init connection + $helperInstance->initConnection(); + + // @TODO The whole resolving part should be moved out and made more configurable + // Init recipient data + $unlData = array(); + + // Try to solve the recipient + try { + // Get protocol handler back from package data + $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData); + + // Get UNL data + $unlData = $handlerInstance->getUniversalNodeLocatorDataArray(); + + // Make sure it is a valid Universal Node Locator array (3 elements) + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); + + // Set handler instance + $helperInstance->setHandlerInstance($handlerInstance); + } catch (NoValidHostnameException $e) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage()); + + // Is the recipient equal as configured IP + if (substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_address'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_address')) { + // This may connect to shipsimu.org and requests 'ip.php' which will return our external IP address + $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] = HubTools::determineExternalAddress(); + + // Do we have ip:port match? + // @TODO Rewrite this test for UNLs + if (strpos($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], ':') === FALSE) { + // No ip:port! + $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' does not contain ":". Please fix this.'); + } // END - if + + // "explode" the ip:port, so index 1 will be the port number + // @TODO Rewrite this test for UNLs + $recipientArray = explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + + // Add the port + $unlData[UniversalNodeLocator::UNL_PART_PORT] = $recipientArray[UniversalNodeLocator::UNL_PART_PORT]; + } else { + // It doesn't match, we need to take care of this later + $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . '!=' . $helperInstance->getConfigInstance()->getConfigEntry('external_address')); + } + } + + // Set address and maybe port + $helperInstance->setAddress($unlData[UniversalNodeLocator::UNL_PART_ADDRESS]); + $helperInstance->setConnectionPort($unlData[UniversalNodeLocator::UNL_PART_PORT]); + + // Now connect to it + if (!$helperInstance->connectToPeerByUnlData($unlData)) { + // Handle socket error + $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, $unlData); + } // END - if + + // Okay, that should be it. Return it... + return $socketResource; + } + + /** + * Do the shutdown sequence for this connection helper + * + * @return void + * @throws SocketShutdownException If the current socket could not be shut down + * @todo We may want to implement a filter for ease notification of other objects like our pool + */ + public function doShutdown () { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down socket resource ' . $this->getSocketResource()); + + // Clear any previous errors + socket_clear_error($this->getSocketResource()); + + // Call the shutdown function on the currently set socket + if (!socket_shutdown($this->getSocketResource())) { + // Could not shutdown socket, this is fine if e.g. the other side is not connected, so analyse it + if (socket_last_error($this->getSocketResource()) != 107) { + // Something bad happened while we shutdown a socket + throw new SocketShutdownException($this, BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + } // END - if + + // Try to make blocking IO for socket_close() + socket_set_block($this->getSocketResource()); + + // Drop all data (don't sent any on socket closure) + socket_set_option($this->getSocketResource(), SOL_SOCKET, SO_LINGER, array('l_onoff' => 1, 'l_linger' => 0)); + + // Finally close socket to free some resources + socket_close($this->getSocketResource()); + + // Mark this connection as shutted down + $this->markConnectionShuttedDown(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/connection/ipv4/udp/.htaccess b/application/hub/classes/helper/connection/ipv4/udp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/connection/ipv4/udp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/connection/ipv4/udp/class_UdpConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/udp/class_UdpConnectionHelper.php new file mode 100644 index 000000000..4ab6f3b26 --- /dev/null +++ b/application/hub/classes/helper/connection/ipv4/udp/class_UdpConnectionHelper.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UdpConnectionHelper extends BaseIpV4ConnectionHelper implements ConnectionHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set protocol + $this->setProtocolName('udp'); + } + + /** + * Creates a half-connected socket resource ("connection") for given + * recipient in package data. After you called this method you still need to + * connect to the other node. + * + * @param $packageData Raw package data + * @return $socketResource Socket resource + */ + public static function createConnectionFromPackageData (array $packageData) { + $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: Unfinished method, packageData[]=' . count($packageData)); + } + + /** + * Do the shutdown sequence for this connection helper + * + * @return void + * @throws SocketShutdownException If the current socket could not be shut down + * @todo Implement a filter for ease notification of other objects like the pool + */ + public function doShutdown () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/dht/.htaccess b/application/hub/classes/helper/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php new file mode 100644 index 000000000..1fc25af21 --- /dev/null +++ b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_DHT); + + // Set package tags + $this->setPackageTags(array('dht_bootstrap')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createDhtBootstrapHelper () { + // Get new instance + $helperInstance = new DhtBootstrapHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the announcement descriptor for parsing + * + * @param $dhtInstance An instance of a Distributable class + * @return void + */ + public function loadDescriptorXml (Distributable $dhtInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with DHT boostrap ...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_bootstrap_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $dhtInstance An instance of a Distributable class + * @return void + */ + public function sendPackage (Distributable $dhtInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + /* + * Sanity check: Is the DHT in the approx. state? 'init' for bootstrap + * nodes and 'virgin' for all others. + */ + $dhtInstance->getStateInstance()->validateDhtStateIsVirginOrInit(); + + // Compile the template, this inserts the loaded dht data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + //* DEBUG: */ die(__METHOD__ . ':dhtInstance=' . print_r($dhtInstance, TRUE)); + $packageInstance->enqueueRawDataFromTemplate($this); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php b/application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php new file mode 100644 index 000000000..b4cd7cedf --- /dev/null +++ b/application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtPublishEntryHelper extends BaseHubSystemHelper implements HelpableDht { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_DHT); + + // Set package tags + $this->setPackageTags(array('dht_publish_entry')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createDhtPublishEntryHelper () { + // Get new instance + $helperInstance = new DhtPublishEntryHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the announcement descriptor for parsing + * + * @param $dhtInstance An instance of a Distributable class + * @return void + */ + public function loadDescriptorXml (Distributable $dhtInstance) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with publishing an entry ...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_publish_entry_template_class'); + + // Set stacker + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $dhtInstance An instance of a Distributable class + * @return void + */ + public function sendPackage (Distributable $dhtInstance) { + // Compile the template, this inserts the loaded dht data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/messages/.htaccess b/application/hub/classes/helper/messages/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/messages/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/messages/class_ b/application/hub/classes/helper/messages/class_ new file mode 100644 index 000000000..db234f141 --- /dev/null +++ b/application/hub/classes/helper/messages/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???MessageHelper extends BaseMessageHelper implements MessageHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $messageInstance An instance of a UnitHelper class + */ + public final static function create???MessageHelper () { + // Get new instance + $messageInstance = new ???MessageHelper(); + + // Return the prepared instance + return $messageInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/messages/class_BaseMessageHelper.php b/application/hub/classes/helper/messages/class_BaseMessageHelper.php new file mode 100644 index 000000000..0dcbf7251 --- /dev/null +++ b/application/hub/classes/helper/messages/class_BaseMessageHelper.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMessageHelper extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/messages/crypto/.htaccess b/application/hub/classes/helper/messages/crypto/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/messages/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php b/application/hub/classes/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php new file mode 100644 index 000000000..b91e729e0 --- /dev/null +++ b/application/hub/classes/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CryptoRandomUnitMessageHelper extends BaseMessageHelper implements MessageHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $sourceType Type of the source + * @return $messageInstance An instance of a UnitHelper class + */ + public final static function createCryptoRandomUnitMessageHelper ($sourceType) { + // Get new instance + $messageInstance = new CryptoRandomUnitMessageHelper(); + + // Generate a source instance + $sourceInstance = UnitSourceFactory::createUnitSourceInstance($sourceType); + + // Set the source instance + $messageInstance->setSourceInstance($sourceInstance); + + // Return the prepared instance + return $messageInstance; + } + + /** + * Generates an encrypted random message + * + * @return $encryptedMessage The encrypted random message + */ + public function generateRandomMessage () { + // Get the message from our source + $encryptedMessage = $this->getSourceInstance()->generateMessageFromSource(); + + // Return it + return $encryptedMessage; + } + + /** + * "Getter" for an iterator for keys + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getKeyIterator () { + // Create the iterator instance + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('test_unit_producer_key_iterator_class'); + + // And return it + return $iteratorInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/.htaccess b/application/hub/classes/helper/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/announcement/.htaccess b/application/hub/classes/helper/node/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php b/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php new file mode 100644 index 000000000..eb4f6d1e1 --- /dev/null +++ b/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncementHelper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER); + + // Set package tags + $this->setPackageTags(array('announcement')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public static final function createNodeAnnouncementHelper () { + // Get new instance + $helperInstance = new NodeAnnouncementHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the announcement descriptor for parsing + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with announcement to upper hubs...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Publishes the node's descriptor XML to all found upper nodes when the + * node has not yet published it's descriptor to a bootstrap node. This is + * done by getting the raw XML content and inserting all variables into + * the code. After this wents fine, the rendered content got "packaged" + * for network delivery. + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/answer/.htaccess b/application/hub/classes/helper/node/answer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/answer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/answer/announcement/.htaccess b/application/hub/classes/helper/node/answer/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/answer/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php new file mode 100644 index 000000000..1ae11467d --- /dev/null +++ b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init package tags + $this->setPackageTags(array('announcement_answer')); + } + + /** + * Creates the helper class + * + * @param $messageData An array with all message data + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNodeAnnouncementMessageAnswerHelper (array $messageData) { + // Get new instance + $helperInstance = new NodeAnnouncementMessageAnswerHelper(); + + // Set session id of other peer as recipient + $helperInstance->setRecipientType($messageData[XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID]); + + // Set message data + $helperInstance->setMessageData($messageData); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer an announcement...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_answer_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Send out announcement answer package + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active/reachable) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/answer/class_BaseHubAnswerHelper.php b/application/hub/classes/helper/node/answer/class_BaseHubAnswerHelper.php new file mode 100644 index 000000000..2d699f18e --- /dev/null +++ b/application/hub/classes/helper/node/answer/class_BaseHubAnswerHelper.php @@ -0,0 +1,61 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubAnswerHelper extends BaseNodeHelper { + /** + * Message data array + */ + private $messageData = array(); + + /** + * Protected constructor + * + * @param $className Name of the concrete class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for message data + * + * @return $messageData An array with message data + */ + protected final function setMessageData (array $messageData) { + $this->messageData = $messageData; + } + + /** + * Getter for message data + * + * @return $messageData An array with message data + */ + public final function getMessageData () { + return $this->messageData; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/answer/dht/.htaccess b/application/hub/classes/helper/node/answer/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/answer/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php new file mode 100644 index 000000000..07d9e041c --- /dev/null +++ b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtBootstrapMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init package tags + $this->setPackageTags(array('dht_bootstrap_answer')); + } + + /** + * Creates the helper class + * + * @param $messageData An array with all message data + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNodeDhtBootstrapMessageAnswerHelper (array $messageData) { + // Get new instance + $helperInstance = new NodeDhtBootstrapMessageAnswerHelper(); + + // Set session id of other peer as recipient + $helperInstance->setRecipientType($messageData[XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID]); + + // Set message data + $helperInstance->setMessageData($messageData); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer a DHT bootstrap request...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_dht_bootstrap_answer_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Send out announcement answer package + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active/reachable) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/answer/requests/.htaccess b/application/hub/classes/helper/node/answer/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/answer/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php new file mode 100644 index 000000000..5f391a0fc --- /dev/null +++ b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init package tags + $this->setPackageTags(array('request_node_list_answer')); + } + + /** + * Creates the helper class + * + * @param $messageData An array with all message data + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNodeRequestNodeListMessageAnswerHelper (array $messageData) { + // Get new instance + $helperInstance = new NodeRequestNodeListMessageAnswerHelper(); + + // Set session id of other peer as recipient + $helperInstance->setRecipientType($messageData[XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID]); + + // Set message data + $helperInstance->setMessageData($messageData); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer a request: node-list...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_answer_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // "Cache" entries instance for next foreach loop + $entriesInstance = $templateInstance->getTemplateInstance(); + + // Is must not be NULL (then it can only be a template instance) + assert(!is_null($entriesInstance)); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Send out request-node-list answer package + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active/reachable) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/class_ b/application/hub/classes/helper/node/class_ new file mode 100644 index 000000000..21bbb6575 --- /dev/null +++ b/application/hub/classes/helper/node/class_ @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???Helper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_!!!); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNode???Helper () { + // Get new instance + $helperInstance = new Node???Helper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @return void + */ + public function loadDescriptorXml () { + $this->partialStub('Please implement this method.'); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsActive(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/class_BaseNodeHelper.php b/application/hub/classes/helper/node/class_BaseNodeHelper.php new file mode 100644 index 000000000..e2a92b051 --- /dev/null +++ b/application/hub/classes/helper/node/class_BaseNodeHelper.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeHelper extends BaseHubSystemHelper { + /** + * Protected constructor + * + * @param $className Name of the concrete class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/connection/.htaccess b/application/hub/classes/helper/node/connection/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/connection/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php b/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php new file mode 100644 index 000000000..5c57946f0 --- /dev/null +++ b/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeSelfConnectHelper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF); + + // Set package tags + $this->setPackageTags(array('self_connect')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public static final function createNodeSelfConnectHelper () { + // Get new instance + $helperInstance = new NodeSelfConnectHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting self-connect...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_self_connect_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Do the self-connect attempt by delivering a package to ourselfs + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnouncing(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/node/requests/.htaccess b/application/hub/classes/helper/node/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/node/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php b/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php new file mode 100644 index 000000000..e674c326e --- /dev/null +++ b/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeRequestNodeListHelper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER); + + // Set package tags + $this->setPackageTags(array('request_node_list')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNodeRequestNodeListHelper () { + // Get new instance + $helperInstance = new NodeRequestNodeListHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to request: node-list...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsAnnouncementCompleted(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/work_units/.htaccess b/application/hub/classes/helper/work_units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/work_units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/work_units/class_ b/application/hub/classes/helper/work_units/class_ new file mode 100644 index 000000000..400fac1fe --- /dev/null +++ b/application/hub/classes/helper/work_units/class_ @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???WorkUnitHelper extends BaseWorkUnitHelper implements UnitHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $unitInstance An instance of a UnitHelper class + */ + public final static function create???WorkUnitHelper () { + // Get new instance + $unitInstance = new ???WorkUnitHelper(); + + // Return the prepared instance + return $unitInstance; + } + + /** + * Initializes this WU helper + * + * @return void + * @todo 0% done + */ + protected function initializeUnitHelper () { + $this->partialStub('Please implement this method.'); + } + + /** + * Generates a work/test/foo unit instance + * + * @return $unitInstance A work unit instance + * @todo 0% done + */ + public function generateUnit () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/work_units/class_BaseWorkUnitHelper.php b/application/hub/classes/helper/work_units/class_BaseWorkUnitHelper.php new file mode 100644 index 000000000..7dc344ecd --- /dev/null +++ b/application/hub/classes/helper/work_units/class_BaseWorkUnitHelper.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseWorkUnitHelper extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // All WU helpers needs to be initialized + $this->initializeUnitHelper(); + } + + /** + * Initializes this WU helper + * + * @return void + */ + abstract protected function initializeUnitHelper (); +} + +// [EOF] +?> diff --git a/application/hub/classes/helper/work_units/cruncher/.htaccess b/application/hub/classes/helper/work_units/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/helper/work_units/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/helper/work_units/cruncher/class_CruncherTestUnitHelper.php b/application/hub/classes/helper/work_units/cruncher/class_CruncherTestUnitHelper.php new file mode 100644 index 000000000..704a8d9c5 --- /dev/null +++ b/application/hub/classes/helper/work_units/cruncher/class_CruncherTestUnitHelper.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherTestUnitHelper extends BaseWorkUnitHelper implements UnitHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $unitInstance An instance of a UnitHelper class + */ + public final static function createCruncherTestUnitHelper () { + // Get new instance + $unitInstance = new CruncherTestUnitHelper(); + + // Return the prepared instance + return $unitInstance; + } + + /** + * Initializes this WU helper. This method satisfies the abstract + * BaseWorkUnitHelper class. + * + * @return void + * @todo 0% done + */ + protected function initializeUnitHelper () { + $this->partialStub('Please implement this method.'); + } + + /** + * Generates a work/test/foo unit instance. This method satifies the + * UnitHelper interface. + * + * @return $unitInstance A work unit instance + * @todo 0% done + */ + public function generateNextUnitInstance () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/info/.htaccess b/application/hub/classes/info/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/info/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/info/class_ b/application/hub/classes/info/class_ new file mode 100644 index 000000000..58c9aa1b8 --- /dev/null +++ b/application/hub/classes/info/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Info extends BaseInfo implements ShareableInfo { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $infoInstance An instance of a ShareableInfo class + */ + public final static function create???Info () { + // Get new instance + $infoInstance = new ???Info(); + + // Return the prepared instance + return $infoInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/info/class_BaseInfo.php b/application/hub/classes/info/class_BaseInfo.php new file mode 100644 index 000000000..1a24194e9 --- /dev/null +++ b/application/hub/classes/info/class_BaseInfo.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseInfo extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/info/connection/.htaccess b/application/hub/classes/info/connection/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/info/connection/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/info/connection/class_ConnectionInfo.php b/application/hub/classes/info/connection/class_ConnectionInfo.php new file mode 100644 index 000000000..f9751b569 --- /dev/null +++ b/application/hub/classes/info/connection/class_ConnectionInfo.php @@ -0,0 +1,114 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $infoInstance An instance of a ShareableInfo class + */ + public final static function createConnectionInfo () { + // Get new instance + $infoInstance = new ConnectionInfo(); + + // Return the prepared instance + return $infoInstance; + } + + /** + * Fills the information class with data from a Listenable instance + * + * @param $listenerInstance An instance of a Listenable class + * @return void + */ + public function fillWithListenerInformation (Listenable $listenerInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); + + // Fill the generic array with several data from the listener: + $this->setProtocolName($listenerInstance->getProtocolName()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $listenerInstance->getListenAddress()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $listenerInstance->getListenPort()); + + // Set listener here + $this->setListenerInstance($listenerInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Fills the information class with data from a ConnectionHelper instance + * + * @param $helperInstance An instance of a ConnectionHelper class + * @return void + */ + public function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!'); + + // Fill the generic array with several data from the listener: + $this->setProtocolName($helperInstance->getProtocolName()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $helperInstance->getAddress()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $helperInstance->getConnectionPort()); + + // Set helper here + $this->setHelperInstance($helperInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Getter for address + * + * @return $address Address from shared information + */ + public final function getAddress () { + // Return it from generic array + return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS); + } + + /** + * Getter for port + * + * @return $port Port from shared information + */ + public final function getPort () { + // Return it from generic array + return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/.htaccess b/application/hub/classes/iterator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/hub/.htaccess b/application/hub/classes/iterator/hub/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/hub/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/hub/class_HubPingIterator.php b/application/hub/classes/iterator/hub/class_HubPingIterator.php new file mode 100644 index 000000000..8f65db578 --- /dev/null +++ b/application/hub/classes/iterator/hub/class_HubPingIterator.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubPingIterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance of a Iterator class + */ + public static final function createHubPingIterator () { + // Get new instance + $iteratorInstance = new HubPingIterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = NULL; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = NULL; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/network/.htaccess b/application/hub/classes/iterator/network/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/network/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/network/class_NetworkListenIterator.php b/application/hub/classes/iterator/network/class_NetworkListenIterator.php new file mode 100644 index 000000000..18c2e8018 --- /dev/null +++ b/application/hub/classes/iterator/network/class_NetworkListenIterator.php @@ -0,0 +1,124 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This current implementation is not recommended, use a + * @todo latency-based iteration or similar approaches + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkListenIterator extends BaseIterator implements Iterator { + /** + * Key for the global list index + */ + private $indexKey = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A list of a Listable + * @return $iteratorInstance An instance a Iterator class + */ + public static final function createNetworkListenIterator (Listable $listInstance) { + // Get new instance + $iteratorInstance = new NetworkListenIterator(); + + // Set the list + $iteratorInstance->setListInstance($listInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + * @throws IndexOutOfBoundsException If $indexKey is out of bounds + */ + public function current () { + // Default is null + $current = NULL; + + // Is the entry valid? + if (!$this->valid()) { + // Throw an exception here + throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); + } // END - if + + // Now get the entry + $current = $this->getListInstance()->getEntry($this->key()); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $indexKey Current key in iteration + */ + public function key () { + return $this->indexKey; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->indexKey++; + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->indexKey = 0; + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return $isValid Whether the current entry is there + */ + public function valid () { + // Check for total active peers and if we are not at the end + $isValid = ($this->key() < $this->getListInstance()->count()); + + // Return result + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/pool/.htaccess b/application/hub/classes/iterator/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/pool/handler/.htaccess b/application/hub/classes/iterator/pool/handler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/pool/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/pool/handler/class_Handler b/application/hub/classes/iterator/pool/handler/class_Handler new file mode 100644 index 000000000..9ec43c124 --- /dev/null +++ b/application/hub/classes/iterator/pool/handler/class_Handler @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Handler???Iterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance a Iterator class + */ + public final static function createHandler???Iterator () { + // Get new instance + $iteratorInstance = new Handler???Iterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/pool/handler/class_HandlerPoolIterator.php b/application/hub/classes/iterator/pool/handler/class_HandlerPoolIterator.php new file mode 100644 index 000000000..e23c2fde6 --- /dev/null +++ b/application/hub/classes/iterator/pool/handler/class_HandlerPoolIterator.php @@ -0,0 +1,124 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This current implementation is not recommended, use a + * @todo latency-based iteration or similar approaches + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HandlerPoolIterator extends BaseIterator implements Iterator { + /** + * Key for the global list index + */ + private $indexKey = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A list of a Listable + * @return $iteratorInstance An instance a Iterator class + */ + public static final function createHandlerPoolIterator (Listable $listInstance) { + // Get new instance + $iteratorInstance = new HandlerPoolIterator(); + + // Set the list + $iteratorInstance->setListInstance($listInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + * @throws IndexOutOfBoundsException If $indexKey is out of bounds + */ + public function current () { + // Default is null + $current = NULL; + + // Is the entry valid? + if (!$this->valid()) { + // Throw an exception here + throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); + } // END - if + + // Now get the entry + $current = $this->getListInstance()->getEntry($this->key()); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $indexKey Current key in iteration + */ + public function key () { + return $this->indexKey; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->indexKey++; + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->indexKey = 0; + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return $isValid Whether the current entry is there + */ + public function valid () { + // Check for total active peers and if we are not at the end + $isValid = ($this->key() < $this->getListInstance()->count()); + + // Return result + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/pool/monitor/.htaccess b/application/hub/classes/iterator/pool/monitor/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/pool/monitor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/pool/monitor/class_MonitorPoolIterator.php b/application/hub/classes/iterator/pool/monitor/class_MonitorPoolIterator.php new file mode 100644 index 000000000..d94a6f218 --- /dev/null +++ b/application/hub/classes/iterator/pool/monitor/class_MonitorPoolIterator.php @@ -0,0 +1,124 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This current implementation is not recommended, use a + * @todo latency-based iteration or similar approaches + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MonitorPoolIterator extends BaseIterator implements Iterator, Registerable { + /** + * Key for the global list index + */ + private $indexKey = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A list of a Listable + * @return $iteratorInstance An instance a Iterator class + */ + public static final function createMonitorPoolIterator (Listable $listInstance) { + // Get new instance + $iteratorInstance = new MonitorPoolIterator(); + + // Set the list + $iteratorInstance->setListInstance($listInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + * @throws IndexOutOfBoundsException If $indexKey is out of bounds + */ + public function current () { + // Default is null + $current = NULL; + + // Is the entry valid? + if (!$this->valid()) { + // Throw an exception here + throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); + } // END - if + + // Now get the entry + $current = $this->getListInstance()->getEntry($this->key()); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $indexKey Current key in iteration + */ + public function key () { + return $this->indexKey; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->indexKey++; + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->indexKey = 0; + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return $isValid Whether the current entry is there + */ + public function valid () { + // Check for total active peers and if we are not at the end + $isValid = ($this->key() < $this->getListInstance()->count()); + + // Return result + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/pool/shutdown/.htaccess b/application/hub/classes/iterator/pool/shutdown/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/pool/shutdown/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/pool/shutdown/class_Shutdown b/application/hub/classes/iterator/pool/shutdown/class_Shutdown new file mode 100644 index 000000000..5e0aaa843 --- /dev/null +++ b/application/hub/classes/iterator/pool/shutdown/class_Shutdown @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Shutdown???Iterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance a Iterator class + */ + public final static function createShutdown???Iterator () { + // Get new instance + $iteratorInstance = new Shutdown???Iterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/pool/shutdown/class_ShutdownPoolIterator.php b/application/hub/classes/iterator/pool/shutdown/class_ShutdownPoolIterator.php new file mode 100644 index 000000000..9d53a2937 --- /dev/null +++ b/application/hub/classes/iterator/pool/shutdown/class_ShutdownPoolIterator.php @@ -0,0 +1,122 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ShutdownPoolIterator extends BaseIterator implements Iterator { + /** + * Key for the global list index + */ + private $indexKey = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A list of a Listable + * @return $iteratorInstance An instance a Iterator class + */ + public static final function createShutdownPoolIterator (Listable $listInstance) { + // Get new instance + $iteratorInstance = new ShutdownPoolIterator(); + + // Set the list + $iteratorInstance->setListInstance($listInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + * @throws IndexOutOfBoundsException If $indexKey is out of bounds + */ + public function current () { + // Default is null + $current = NULL; + + // Is the entry valid? + if (!$this->valid()) { + // Throw an exception here + throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); + } // END - if + + // Now get the entry + $current = $this->getListInstance()->getEntry($this->key()); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $indexKey Current key in iteration + */ + public function key () { + return $this->indexKey; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->indexKey++; + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->indexKey = 0; + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return $isValid Whether the current entry is there + */ + public function valid () { + // Check for total active peers and if we are not at the end + $isValid = ($this->key() < $this->getListInstance()->count()); + + // Return result + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/pool/tasks/.htaccess b/application/hub/classes/iterator/pool/tasks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/pool/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/pool/tasks/class_TaskPoolIterator.php b/application/hub/classes/iterator/pool/tasks/class_TaskPoolIterator.php new file mode 100644 index 000000000..7611ebc59 --- /dev/null +++ b/application/hub/classes/iterator/pool/tasks/class_TaskPoolIterator.php @@ -0,0 +1,124 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This current implementation is not recommended, use a + * @todo latency-based iteration or similar approaches + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TaskPoolIterator extends BaseIterator implements Iterator, Registerable { + /** + * Key for the global list index + */ + private $indexKey = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A list of a Listable + * @return $iteratorInstance An instance a Iterator class + */ + public static final function createTaskPoolIterator (Listable $listInstance) { + // Get new instance + $iteratorInstance = new TaskPoolIterator(); + + // Set the list + $iteratorInstance->setListInstance($listInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + * @throws IndexOutOfBoundsException If $indexKey is out of bounds + */ + public function current () { + // Default is null + $current = NULL; + + // Is the entry valid? + if (!$this->valid()) { + // Throw an exception here + throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); + } // END - if + + // Now get the entry + $current = $this->getListInstance()->getEntry($this->key()); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $indexKey Current key in iteration + */ + public function key () { + return $this->indexKey; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->indexKey++; + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->indexKey = 0; + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return $isValid Whether the current entry is there + */ + public function valid () { + // Check for total active peers and if we are not at the end + $isValid = ($this->key() < $this->getListInstance()->count()); + + // Return result + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/iterator/producer/.htaccess b/application/hub/classes/iterator/producer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/producer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/producer/keys/.htaccess b/application/hub/classes/iterator/producer/keys/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/iterator/producer/keys/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/iterator/producer/keys/class_TestUnitKeyProducerIterator.php b/application/hub/classes/iterator/producer/keys/class_TestUnitKeyProducerIterator.php new file mode 100644 index 000000000..ce2c1411d --- /dev/null +++ b/application/hub/classes/iterator/producer/keys/class_TestUnitKeyProducerIterator.php @@ -0,0 +1,137 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TestUnitKeyProducerIterator extends BaseIterator implements Iterator { + /** + * Maximum different bit combinations + */ + private $maxBits = 0; + + /** + * Key length + */ + private $keyLength = 0; + + /** + * Current iteration + */ + private $currentIteration = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Get key length + $this->keyLength = $this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length'); + + // Make sure the key length isn't getting to big (32 byte = 256 bit is really, really a lot!) + assert($this->keyLength <= (8 * 32)); + + // Set max bits entry + $this->maxBits = pow(2, $this->keyLength); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('ITERATOR: maxBits=' . $this->maxBits . ',keyLength=' . $this->keyLength . ' bits'); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance of a Iterator class + */ + public final static function createTestUnitKeyProducerIterator () { + // Get new instance + $iteratorInstance = new TestUnitKeyProducerIterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value + * + * @return $current Current value in iteration + */ + public function current () { + // Calculate ASCII string representation of the key number + $current = $this->dec2asc($this->currentIteration); + + // Prepend more zeros + $current = str_pad($current, ($this->keyLength / 8), chr(0), STR_PAD_LEFT); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + * @throws UnsupportedOperationException This method should not be called + */ + public function key () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + /* + * This is of course a very ineffective key generation iterator because + * it will create a lot of keys that will never decode an encrypted + * message. If you know a better algorithm which is freely available and + * can be implemented as an itertator please contact me. + */ + $this->currentIteration++; + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + * @throws UnsupportedOperationException This method should not be called + */ + public function rewind () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + return ($this->currentIteration <= $this->maxBits); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/.htaccess b/application/hub/classes/listener/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/listener/class_BaseListenerDecorator.php b/application/hub/classes/listener/class_BaseListenerDecorator.php new file mode 100644 index 000000000..ab44d2d6f --- /dev/null +++ b/application/hub/classes/listener/class_BaseListenerDecorator.php @@ -0,0 +1,153 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseListenerDecorator extends BaseDecorator implements Visitable { + /** + * Listener type + */ + private $listenerType = 'invalid'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for listen address + * + * @return $listenAddress The address this listener should listen on + */ + public final function getListenAddress () { + return $this->getListenerInstance()->getListenAddress(); + } + + /** + * Getter for listen port + * + * @return $listenPort The port this listener should listen on + */ + public final function getListenPort () { + return $this->getListenerInstance()->getListenPort(); + } + + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + public final function getConnectionType () { + return $this->getListenerInstance()->getConnectionType(); + } + + /** + * Accepts the visitor to process the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this decorator + $visitorInstance->visitDecorator($this); + + // Visit the covered class + $visitorInstance->visitListener($this->getListenerInstance()); + } + + /** + * Getter for listener type. + * + * @return $listenerType The listener's type (hub/peer) + */ + public final function getListenerType () { + return $this->listenerType; + } + + /** + * Setter for listener type. + * + * @param $listenerType The listener's type (hub/peer) + * @return void + */ + protected final function setListenerType ($listenerType) { + $this->listenerType = $listenerType; + } + + /** + * Getter for peer pool instance + * + * @return $poolInstance A peer pool instance + */ + public final function getPoolInstance () { + return $this->getListenerInstance()->getPoolInstance(); + } + + /** + * Monitors incoming raw data from the handler and transfers it to the + * given receiver instance. + * + * @return void + */ + public function monitorIncomingRawData () { + // Get the handler instance + $handlerInstance = $this->getListenerInstance()->getHandlerInstance(); + + /* + * Does our deocorated listener (or even a decorator again) have a + * handler assigned? Remember that a handler will hold all incoming raw + * data and not a listener. + */ + if (!$handlerInstance instanceof Networkable) { + // Skip this silently for now. Later on, this will become mandatory! + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('No handler assigned to this listener decorator. this=' . $this->__toString() . ', listenerInstance=' . $this->getListenerInstance()->__toString()); + return; + } // END - if + + // Does the handler have some decoded data pending? + if (!$handlerInstance->isRawDataPending()) { + // No data is pending so skip further code silently + return; + } // END - if + + // Get receiver (network package) instance + $receiverInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + /* + * We have some pending decoded data. The receiver instance is an + * abstract network package (which can be received and sent out) so + * handle the decoded data over. At this moment we don't need to know + * if the decoded data origins from a TCP or UDP connection so we can + * just pass it over to the network package receiver + */ + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-LISTENER-DECORATOR[' . __METHOD__ . ':' . __LINE__ . '] Going to handle over some raw data to receiver instance (' . $receiverInstance->__toString() . ') ...'); + $receiverInstance->addRawDataToIncomingStack($handlerInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/decorators/.htaccess b/application/hub/classes/listener/decorators/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/listener/decorators/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/listener/tcp/.htaccess b/application/hub/classes/listener/tcp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/listener/tcp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/listener/tcp/class_ b/application/hub/classes/listener/tcp/class_ new file mode 100644 index 000000000..96b146f9f --- /dev/null +++ b/application/hub/classes/listener/tcp/class_ @@ -0,0 +1,208 @@ +while (count($clients) > 0) { + // create a copy, so $clients doesn't get modified by socket_select() + $read = $clients; + + // get a list of all the clients that have data to be read from + // if there are no clients with data, go to next iteration + $left = @socket_select($read, $write = null, $except = null, 0, 150); + if ($left < 1) { + continue; + } + + // check if there is a client trying to connect + if (in_array($mainSocket, $read)) { + // accept the client, and add him to the $clients array + $new_sock = socket_accept($mainSocket); + $clients[] = $new_sock; + + // send the client a welcome message + socket_write($new_sock, "No noobs, but I'll make an exception. :)\n". + "There are ".(count($clients) - 1)." client(s) connected to the server.\n"); + + socket_getpeername($new_sock, $ip); + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}"); + + // Notify all chatter + if (count($clients) > 2) { + foreach ($clients as $send_sock) { + if ($send_sock != $mainSocket && $send_sock != $new_sock) { + socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n"); + } + } + } + + // remove the listening socket from the clients-with-data array + $key = array_search($mainSocket, $read); + unset($read[$key]); + } + + // loop through all the clients that have data to read from + foreach ($read as $read_sock) { + // Get client data + socket_getpeername($read_sock, $ip); + + // read until newline or 1024 bytes + // socket_read while show errors when the client is disconnected, so silence the error messages + $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ); + + // check if the client is disconnected + if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) { + + // remove client for $clients array + $key = array_search($read_sock, $clients); + unset($clients[$key]); + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1).""); + + // Notify all chatter + if (count($clients) > 1) { + foreach ($clients as $send_sock) { + if ($send_sock != $mainSocket) { + socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n"); + } + } + } + + // continue to the next client to read from, if any + socket_write($read_sock, "Server: Good bye.\n"); + socket_shutdown($read_sock, 2); + socket_close($read_sock); + continue; + } elseif (in_array(trim($data), $shutdown)) { + // Is he allowed to shutdown? + if (!in_array($ip, $masters)) { + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!"); + socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n"); + $data = ""; + continue; + } + + // Close all connections a leave here + foreach ($clients as $client) { + // Send message to client + if ($client !== $mainSocket && $client != $read_sock) { + socket_write($client, "Server: Shutting down! Thank you for joining us.\n"); + } + + // Quit him + socket_shutdown($client, 2); + socket_close($client); + } // end foreach + + // Leave the loop + $data = ""; + $clients = array(); + continue; + } + + // trim off the trailing/beginning white spaces + $data = trim($data); + + // Test for HTML codes + $tags = strip_tags($data); + + // check if there is any data after trimming off the spaces + if (!empty($data) && $tags == $data && count($clients) > 2) { + // Send confirmation to "chatter" + socket_write($read_sock, "\nServer: Message accepted.\n"); + + // send this to all the clients in the $clients array (except the first one, which is a listening socket) + foreach ($clients as $send_sock) { + + // if its the listening sock or the client that we got the message from, go to the next one in the list + if ($send_sock == $mainSocket || $send_sock == $read_sock) + continue; + + // write the message to the client -- add a newline character to the end of the message + socket_write($send_sock, "{$ip}:{$data}\n"); + + } // end of broadcast foreach + } elseif ($tags != $data) { + // HTML codes are not allowed + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!"); + socket_write($read_sock, "Server: HTML is forbidden!\n"); + } elseif ((count($clients) == 2) && ($read_sock != $mainSocket)) { + // No one else will hear the "chatter" + out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself."); + socket_write($read_sock, "Server: No one will hear you!\n"); + } + } // end of reading foreach +} + +// close the listening socket +socket_close($mainSocket); + +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Listener extends BaseListener implements Listenable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public final static function create???Listener (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new ???Listener(); + + // Set the application instance + $listenerInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + * @todo 0% done + */ + public function initListener() { + $this->partialStub('Need to implement this method.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + * @todo 0% done + */ + public function doListen() { + $this->partialStub('Need to implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/tcp/class_TcpListener.php b/application/hub/classes/listener/tcp/class_TcpListener.php new file mode 100644 index 000000000..4d01c5a2c --- /dev/null +++ b/application/hub/classes/listener/tcp/class_TcpListener.php @@ -0,0 +1,339 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TcpListener extends BaseListener implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set the protocol to TCP + $this->setProtocolName('tcp'); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public static final function createTcpListener (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new TcpListener(); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + * @throws InvalidSocketException Thrown if the socket could not be initialized + */ + public function initListener () { + // Create a streaming socket, of type TCP/IP + $mainSocket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + + // Is the socket resource valid? + if (!is_resource($mainSocket)) { + // Something bad happened + throw new InvalidSocketException(array($this, $mainSocket), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + // Get socket error code for verification + $socketError = socket_last_error($mainSocket); + + // Check if there was an error else + if ($socketError > 0) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Then throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + // Set the option to reuse the port + if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Get socket error code for verification + $socketError = socket_last_error($mainSocket); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($mainSocket); + + // And throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + /* + * "Bind" the socket to the given address, on given port so this means + * that all connections on this port are now our resposibility to + * send/recv data, disconnect, etc.. + */ + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); + if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Get socket error code for verification + $socketError = socket_last_error($mainSocket); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($mainSocket); + + // And throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + // Start listen for connections + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Listening for connections.'); + if (!socket_listen($mainSocket)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Get socket error code for verification + $socketError = socket_last_error($mainSocket); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($mainSocket); + + // And throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + // Now, we want non-blocking mode + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting non-blocking mode.'); + if (!socket_set_nonblock($mainSocket)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Get socket error code for verification + $socketError = socket_last_error($mainSocket); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($mainSocket); + + // And throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + // Set the main socket + $this->registerServerSocketResource($mainSocket); + + // Initialize the peer pool instance + $poolInstance = ObjectFactory::createObjectByConfiguredName('node_pool_class', array($this)); + + // Add main socket + $poolInstance->addPeer($mainSocket, BaseConnectionHelper::CONNECTION_TYPE_SERVER); + + // And add it to this listener + $this->setPoolInstance($poolInstance); + + // Initialize iterator for listening on packages + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('network_listen_iterator_class', array($poolInstance->getPoolEntriesInstance())); + + // Rewind it and remember it in this class + $iteratorInstance->rewind(); + $this->setIteratorInstance($iteratorInstance); + + // Initialize the network package handler + $handlerInstance = ObjectFactory::createObjectByConfiguredName('tcp_raw_data_handler_class'); + + // Set it in this class + $this->setHandlerInstance($handlerInstance); + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + * @throws InvalidSocketException If an invalid socket resource has been found + */ + public function doListen () { + // Get all readers + $readers = $this->getPoolInstance()->getAllSingleSockets(); + $writers = array(); + $excepts = array(); + + // Check if we have some peers left + $left = socket_select( + $readers, + $writers, + $excepts, + 0, + 150 + ); + + // Some new peers found? + if ($left < 1) { + // Debug message + //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE)); + + // Nothing new found + return; + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE)); + + // Do we have changed peers? + if (in_array($this->getSocketResource(), $readers)) { + /* + * Then accept it, if this socket is set to non-blocking IO and the + * connection is NOT sending any data, socket_read() may throw + * error 11 (Resource temporary unavailable). This really nasty + * because if you have blocking IO socket_read() will wait and wait + * and wait ... + */ + $newSocket = socket_accept($this->getSocketResource()); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',serverSocket=' .$this->getSocketResource()); + + // Array for timeout settings + $options = array( + // Seconds + 'sec' => $this->getConfigInstance()->getConfigEntry('tcp_socket_accept_wait_sec'), + // Milliseconds + 'usec' => $this->getConfigInstance()->getConfigEntry('tcp_socket_accept_wait_usec') + ); + + // Set timeout to configured seconds + // @TODO Does this work on Windozer boxes??? + if (!socket_set_option($newSocket, SOL_SOCKET, SO_RCVTIMEO, $options)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); + } // END - if + + // Output result (only for debugging!) + /* + $option = socket_get_option($newSocket, SOL_SOCKET, SO_RCVTIMEO); + self::createDebugInstance(__CLASS__)->debugOutput('SO_RCVTIMEO[' . gettype($option) . ']=' . print_r($option, TRUE)); + */ + + // Enable SO_OOBINLINE + if (!socket_set_option($newSocket, SOL_SOCKET, SO_OOBINLINE ,1)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); + } // END - if + + // Set non-blocking + if (!socket_set_nonblock($newSocket)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); + } // END - if + + // Add it to the peers + $this->getPoolInstance()->addPeer($newSocket, BaseConnectionHelper::CONNECTION_TYPE_INCOMING); + + // Get peer name + if (!socket_getpeername($newSocket, $peerName)) { + // Handle this socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); + } // END - if + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Create a faked package data array + $packageData = array( + NetworkPackage::PACKAGE_DATA_SENDER => $peerName . ':0', + NetworkPackage::PACKAGE_DATA_RECIPIENT => $nodeInstance->getSessionId(), + NetworkPackage::PACKAGE_DATA_STATUS => NetworkPackage::PACKAGE_STATUS_FAKED + ); + + // Get a connection info instance + $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); + + // Will the info instance with listener data + $infoInstance->fillWithListenerInformation($this); + + // Get a socket registry + $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); + + // Register the socket with the registry and with the faked array + $registryInstance->registerSocket($infoInstance, $newSocket, $packageData); + } // END - if + + // Do we have to rewind? + if (!$this->getIteratorInstance()->valid()) { + // Rewind the list + $this->getIteratorInstance()->rewind(); + } // END - if + + // Get the current value + $currentSocket = $this->getIteratorInstance()->current(); + + // Handle it here, if not main server socket + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource()); + if (($currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] != BaseConnectionHelper::CONNECTION_TYPE_SERVER) && ($currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] != $this->getSocketResource())) { + // ... or else it will raise warnings like 'Transport endpoint is not connected' + $this->getHandlerInstance()->processRawDataFromResource($currentSocket); + } // END - if + + // Advance to next entry. This should be the last line. + $this->getIteratorInstance()->next(); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + * @throws UnsupportedOperationException If this method is called + */ + public function ifListenerAcceptsPackageData (array $packageData) { + // Please don't call this + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/tcp/decorators/.htaccess b/application/hub/classes/listener/tcp/decorators/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/listener/tcp/decorators/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php b/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php new file mode 100644 index 000000000..2df0959a8 --- /dev/null +++ b/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ClientTcpListenerDecorator extends BaseListenerDecorator implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set listener type and protocol name + $this->setListenerType('peer'); + $this->setProtocolName('tcp'); + } + + /** + * Creates an instance of this class + * + * @param $listenerInstance A Listener instance + * @return $decoratorInstance An instance a prepared listener decorator class + */ + public static final function createClientTcpListenerDecorator (Listenable $listenerInstance) { + // Get new instance + $decoratorInstance = new ClientTcpListenerDecorator(); + + // Set the application instance + $decoratorInstance->setListenerInstance($listenerInstance); + + // Return the prepared instance + return $decoratorInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + */ + public function initListener () { + $this->partialStub('WARNING: This method should not be called.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + */ + public function doListen () { + // Handle generic TCP package + $this->getListenerInstance()->doListen(); + + // Handle peer TCP package + $this->partialStub('Need to handle peer TCP package.'); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + public function ifListenerAcceptsPackageData (array $packageData) { + // Get a tags instance + $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); + + // So is the package accepted with this listener? + $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + + // Return the result + return $accepts; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php b/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php new file mode 100644 index 000000000..1f2532cf9 --- /dev/null +++ b/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubTcpListenerDecorator extends BaseListenerDecorator implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set listener type and protocol name + $this->setListenerType('hub'); + $this->setProtocolName('tcp'); + } + + /** + * Creates an instance of this class + * + * @param $listenerInstance A Listener instance + * @return $decoratorInstance An instance a prepared listener decorator class + */ + public static final function createHubTcpListenerDecorator (Listenable $listenerInstance) { + // Get new instance + $decoratorInstance = new HubTcpListenerDecorator(); + + // Set the application instance + $decoratorInstance->setListenerInstance($listenerInstance); + + // Return the prepared instance + return $decoratorInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + */ + public function initListener () { + $this->partialStub('WARNING: This method should not be called.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + */ + public function doListen () { + // Handle generic TCP package + $this->getListenerInstance()->doListen(); + + // Handle hub TCP package + $this->partialStub('Need to handle hub TCP package.'); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + public function ifListenerAcceptsPackageData (array $packageData) { + // Get a tags instance + $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); + + // So is the package accepted with this listener? + $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + + // Return the result + return $accepts; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/udp/.htaccess b/application/hub/classes/listener/udp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/listener/udp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/listener/udp/class_ b/application/hub/classes/listener/udp/class_ new file mode 100644 index 000000000..8be5d3893 --- /dev/null +++ b/application/hub/classes/listener/udp/class_ @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Udp???Listener extends BaseListener implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public final static function createUdp???Listener (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new Udp???Listener(); + + // Set the application instance + $listenerInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + * @todo 0% done + */ + public function initListener() { + $this->partialStub('Need to implement this method.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + * @todo 0% done + */ + public function doListen() { + $this->partialStub('Need to implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/udp/class_UdpListener.php b/application/hub/classes/listener/udp/class_UdpListener.php new file mode 100644 index 000000000..0eed46a90 --- /dev/null +++ b/application/hub/classes/listener/udp/class_UdpListener.php @@ -0,0 +1,198 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UdpListener extends BaseListener implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set the protocol to UDP + $this->setProtocolName('udp'); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public static final function createUdpListener (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new UdpListener(); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + * @throws InvalidSocketException Thrown if the socket is invalid or an + * error was detected. + */ + public function initListener () { + // Try to open a UDP socket + $mainSocket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + + // Is the socket a valid resource or do we have any error? + if (!is_resource($mainSocket)) { + // Then throw an InvalidSocketException + throw new InvalidSocketException(array($this, $mainSocket), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + /* + * "Bind" the socket to the given address, on given port so this means + * that all connections on this port are now our resposibility to + * send/recv data, disconnect, etc.. + */ + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); + if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) { + // Handle the socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Get socket error code for verification + $socketError = socket_last_error($mainSocket); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($mainSocket); + + // And throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + // Now, we want non-blocking mode + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting non-blocking mode.'); + if (!socket_set_nonblock($mainSocket)) { + // Handle the socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Get socket error code for verification + $socketError = socket_last_error($socket); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($mainSocket); + + // And throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + // Set the option to reuse the port + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting re-use address option.'); + if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) { + // Handle the socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); + /* + // Get socket error code for verification + $socketError = socket_last_error($mainSocket); + + // Get error message + $errorMessage = socket_strerror($socketError); + + // Shutdown this socket + $this->shutdownSocket($mainSocket); + + // And throw again + throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + + // Remember the socket in our class + $this->registerServerSocketResource($mainSocket); + + // Initialize the network package handler + $handlerInstance = ObjectFactory::createObjectByConfiguredName('udp_raw_data_handler_class'); + + // Set it in this class + $this->setHandlerInstance($handlerInstance); + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + * @todo ~50% done + */ + public function doListen() { + // Read a package and determine the peer + $amount = @socket_recvfrom($this->getSocketResource(), $rawData, $this->getConfigInstance()->getConfigEntry('udp_buffer_length'), MSG_DONTWAIT, $peer, $port); + + // Get last error + $lastError = socket_last_error($this->getSocketResource()); + + // Do we have an error at the line? + if ($lastError == 11) { + /* + * This (resource temporary unavailable) can be safely ignored on + * "listening" UDP ports. If we don't clear the error here, our UDP + * "listener" won't read any packages except if the UDP sender + * starts the transmission before this "listener" came up... + */ + socket_clear_error($this->getSocketResource()); + + // Skip further processing + return; + } elseif ($lastError > 0) { + // Other error detected + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Error detected: ' . socket_strerror($lastError)); + + // Skip further processing + return; + } elseif ((empty($rawData)) || (trim($peer) == '')) { + // Zero sized packages/peer names are usual in non-blocking mode + return; + } // END - if + + // Debug only + self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + function ifListenerAcceptsPackageData (array $packageData) { + $this->partialStub('This call should not happen. Please report it.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/udp/decorators/.htaccess b/application/hub/classes/listener/udp/decorators/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/listener/udp/decorators/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php b/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php new file mode 100644 index 000000000..7393cbfb8 --- /dev/null +++ b/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ClientUdpListenerDecorator extends BaseListenerDecorator implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set listener type and protocol name + $this->setListenerType('peer'); + $this->setProtocolName('udp'); + } + + /** + * Creates an instance of this class + * + * @param $listenerInstance A Listener instance + * @return $decoratorInstance An instance a prepared listener decorator class + */ + public static final function createClientUdpListenerDecorator (Listenable $listenerInstance) { + // Get new instance + $decoratorInstance = new ClientUdpListenerDecorator(); + + // Set the application instance + $decoratorInstance->setListenerInstance($listenerInstance); + + // Return the prepared instance + return $decoratorInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + */ + public function initListener () { + $this->partialStub('WARNING: This method should not be called.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + */ + public function doListen () { + // Handle generic UDP packages first + $this->getListenerInstance()->doListen(); + + // Handle this peer UDP package + $this->partialStub('Need to handle peer UDP package.'); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + function ifListenerAcceptsPackageData (array $packageData) { + // Get a tags instance + $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); + + // So is the package accepted with this listener? + $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + + // Return the result + return $accepts; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php b/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php new file mode 100644 index 000000000..141e7c880 --- /dev/null +++ b/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubUdpListenerDecorator extends BaseListenerDecorator implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set listener type and protocol name + $this->setListenerType('hub'); + $this->setProtocolName('udp'); + } + + /** + * Creates an instance of this class + * + * @param $listenerInstance A Listener instance + * @return $decoratorInstance An instance a prepared listener decorator class + */ + public static final function createHubUdpListenerDecorator (Listenable $listenerInstance) { + // Get new instance + $decoratorInstance = new HubUdpListenerDecorator(); + + // Set the application instance + $decoratorInstance->setListenerInstance($listenerInstance); + + // Return the prepared instance + return $decoratorInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + */ + public function initListener () { + $this->partialStub('WARNING: This method should not be called.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + */ + public function doListen () { + // Handle generic UDP package first + $this->getListenerInstance()->doListen(); + + // Handle hub UDP package + $this->partialStub('Need to handle hub UDP package.'); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + public function ifListenerAcceptsPackageData (array $packageData) { + // Get a tags instance + $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); + + // So is the package accepted with this listener? + $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + + // Return the result + return $accepts; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/lists/.htaccess b/application/hub/classes/lists/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lists/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/lists/hub/.htaccess b/application/hub/classes/lists/hub/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lists/hub/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/lists/hub/class_HubList.php b/application/hub/classes/lists/hub/class_HubList.php new file mode 100644 index 000000000..efe935f6f --- /dev/null +++ b/application/hub/classes/lists/hub/class_HubList.php @@ -0,0 +1,73 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubList extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public static final function createHubList () { + // Get new instance + $listInstance = new HubList(); + + // Add groups for e.g. connected/disconnected hubs + $listInstance->addGroup('connected'); + $listInstance->addGroup('disconnected'); + + // Return the prepared instance + return $listInstance; + } + + /** + * "Getter" for an iterator instance of this list (not implemented) + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getListIterator () { + $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); + } + + /** + * Clears this list by cleaning up all groups together. + * + * @return void + */ + public function clearList () { + // Clear both groups together + $this->clearGroups(array('connected', 'disconnected')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/lists/pool/.htaccess b/application/hub/classes/lists/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lists/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/lists/pool/class_PoolEntriesList.php b/application/hub/classes/lists/pool/class_PoolEntriesList.php new file mode 100644 index 000000000..41e29f8b6 --- /dev/null +++ b/application/hub/classes/lists/pool/class_PoolEntriesList.php @@ -0,0 +1,79 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PoolEntriesList extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public static final function createPoolEntriesList () { + // Get new instance + $listInstance = new PoolEntriesList(); + + // Add 'pool' group + $listInstance->addGroup('pool'); + + // Return the prepared instance + return $listInstance; + } + + /** + * "Getter" for an iterator instance of this list + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getListIterator () { + // Get the iterator instance from the factory + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('node_ping_iterator_class', array($this)); + + // Rewind it + $iteratorInstance->rewind(); + + // ... and return it + return $iteratorInstance; + } + + /** + * Clears this list by cleaning up all groups together. + * + * @return void + */ + public function clearList () { + // Clear the only one group + $this->clearGroup('pool'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/lists/query/.htaccess b/application/hub/classes/lists/query/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lists/query/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/lists/query/local/.htaccess b/application/hub/classes/lists/query/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lists/query/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/lists/recipient/.htaccess b/application/hub/classes/lists/recipient/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lists/recipient/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/lists/recipient/class_RecipientList.php b/application/hub/classes/lists/recipient/class_RecipientList.php new file mode 100644 index 000000000..a8ac4e916 --- /dev/null +++ b/application/hub/classes/lists/recipient/class_RecipientList.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RecipientList extends BaseList implements Listable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public static final function createRecipientList () { + // Get new instance + $listInstance = new RecipientList(); + + // Add groups: + // 1.) Universal Node Locators + $listInstance->addGroup('unl'); + + // 2.) Session ids + $listInstance->addGroup('session_id'); + + // Return the prepared instance + return $listInstance; + } + + /** + * "Getter" for an iterator instance of this list (not implemented) + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getListIterator () { + $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); + } + + /** + * Clears this list by cleaning up all groups together. + * + * @return void + */ + public function clearList () { + // Clear both groups + $this->clearGroups(array('unl', 'session_id')); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/lookup/.htaccess b/application/hub/classes/lookup/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lookup/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/lookup/class_ b/application/hub/classes/lookup/class_ new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/lookup/class_ @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/lookup/peer/.htaccess b/application/hub/classes/lookup/peer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/lookup/peer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/menu/.htaccess b/application/hub/classes/menu/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/menu/class_Hub b/application/hub/classes/menu/class_Hub new file mode 100644 index 000000000..e518971c6 --- /dev/null +++ b/application/hub/classes/menu/class_Hub @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Hub???Menu extends BaseMenu implements RenderableMenu { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $menuInstance An instance of this class + */ + public final static function createHub???Menu () { + // Get a new instance + $menuInstance = new Hub???Menu(); + + // Return the prepared instance + return $menuInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/menu/class_HubIndexMenu.php b/application/hub/classes/menu/class_HubIndexMenu.php new file mode 100644 index 000000000..2b004eb1b --- /dev/null +++ b/application/hub/classes/menu/class_HubIndexMenu.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 2007 - 2008 Roland Haeder, 2009 - Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubIndexMenu extends BaseMenu implements RenderableMenu { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $menuInstance An instance of this class + */ + public static final function createHubIndexMenu () { + // Get a new instance + $menuInstance = new HubIndexMenu(); + + // Return the prepared instance + return $menuInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/miner/.htaccess b/application/hub/classes/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/miner/chash/.htaccess b/application/hub/classes/miner/chash/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/miner/chash/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/miner/chash/class_HubCoinMiner.php b/application/hub/classes/miner/chash/class_HubCoinMiner.php new file mode 100644 index 000000000..2b9ddb1d7 --- /dev/null +++ b/application/hub/classes/miner/chash/class_HubCoinMiner.php @@ -0,0 +1,147 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubCoinMiner extends BaseHubMiner implements MinerHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set version number + $this->setVersion('0.0.0'); + } + + /** + * Creates an instance of this hub-miner class + * + * @return $minerInstance An instance of this hub-miner class + */ + public final static function createHubCoinMiner () { + // Get a new instance + $minerInstance = new HubCoinMiner(); + + // Return the instance + return $minerInstance; + } + + /** + * This method fills the in-buffer with (a) test unit(s) which are mainly + * used for development of the crunching part. They must be enabled in + * configuration, or else your miner runs out of WUs and waits for more + * to show up. + * + * In this method we already know that the in-buffer is going depleted so + * no need to double-check it here. + * + * @return void + */ + protected function fillInBufferQueueWithTestUnits () { + // Are test units enabled? + if ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'N') { + // They are disabled, so skip any further steps + return; + } elseif ($this->getStateInstance()->isMinerStateVirgin()) { + // No virgin miners please, because they usually have no test units ready for crunching + return; + } + + // Get a test-unit generator instance + $generatorInstance = ObjectFactory::createObjectByConfiguredName('miner_test_unit_generator_class'); + + // We don't need an iterator here because we just need to generate some test units + for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('miner_max_text_unit_amount'); $idx++) { + // Get a test unit from it + $unitInstance = $generatorInstance->generateNextUnitInstance(); + + // ... and finally queue it to the in-buffer queue + $this->queueUnitInstanceToInBuffer($unitInstance); + } // END - for + } + + /** + * This method fills the in-buffer with (real) WUs which will be crunched + * and the result be sent back to the key producer instance. + * + * @return void + */ + protected function fillInBufferQueueWithWorkUnits () { + // This miner's state must not be one of these: 'virgin' + if ($this->getStateInstance()->isMinerStateVirgin()) { + // We can silently skip here, until the generation is finished + return; + } // END - if + + // @TODO Implement this method + $this->partialStub('Please implement this method.'); + } + + /** + * Method to "bootstrap" the miner. This step does also apply provided + * command-line arguments stored in the request instance. No buffer queue + * will be initialized here, we only do "general" things here. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + // Output all lines + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('Hubcoin miner v' . $this->getVersion() . ' is starting ...'); + self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2014 Miner Developer Team'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); + self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); + self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + } + + /** + * Add some miner-specific filters + * + * @param $controllerInstance An object of a Controller instance + * @param $responseInstance An object of a Responseable instance + * @return void + * @todo 0% done + */ + public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { + // Add some filters here + $this->partialStub('Please add some miner-specific filters, if required.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/miner/class_ b/application/hub/classes/miner/class_ new file mode 100644 index 000000000..090621d91 --- /dev/null +++ b/application/hub/classes/miner/class_ @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Hub???Miner extends BaseHubMiner implements MinerHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set version number + $this->setVersion('x.x'); + } + + /** + * Creates an instance of this hub-miner class + * + * @param $requestInstance An instance of a Requestable class + * @return $minerInstance An instance of this hub-miner class + */ + public final static function createHub???Miner (Requestable $requestInstance) { + // Get a new instance + $minerInstance = new Hub???Miner(); + + // Set the request instance + $minerInstance->setRequestInstance($requestInstance); + + // Return the instance + return $minerInstance; + } + + /** + * Method to "bootstrap" the miner. This step does also apply provided + * command-line arguments stored in the request instance. The regular miner + * should communicate with the bootstrap-miners at this point. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + // Call generic (parent) bootstrapping method first + parent::doGenericBootstrapping(); + $this->partialStub('Please implement this method.'); + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + $this->partialStub('Please implement this method.'); + } + + /** + * Add some miner-specific filters + * + * @return void + */ + public function addExtraHubFilters () { + // Add some filters here + } +} + +// [EOF] +?> diff --git a/application/hub/classes/miner/class_BaseHubMiner.php b/application/hub/classes/miner/class_BaseHubMiner.php new file mode 100644 index 000000000..ecdfaa459 --- /dev/null +++ b/application/hub/classes/miner/class_BaseHubMiner.php @@ -0,0 +1,244 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseHubMiner extends BaseHubSystem implements Updateable { + /** + * Version information + */ + private $version = 'x.x'; + + /** + * By default no miner is active + */ + private $isActive = FALSE; + + /** + * All buffer queue instances (a FIFO) + */ + private $bufferInstance = NULL; + + /** + * An array for initialized producers + */ + private $producersInitialized = array(); + + /** + * Stacker name for incoming queue + */ + const STACKER_NAME_IN_QUEUE = 'in_queue'; + + /** + * Stacker name for outcoming queue + */ + const STACKER_NAME_OUT_QUEUE = 'out_queue'; + + /** + * Maximum number of producers (2: test and real) + */ + const MAX_PRODUCERS = 2; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init this miner + $this->initMiner(); + } + + /** + * Initialize the miner generically + * + * @return void + */ + private function initMiner () { + // Add own instance to registry + Registry::getRegistry()->addInstance('miner', $this); + + // Init the state + MinerStateFactory::createMinerStateInstanceByName('init'); + } + + /** + * Getter for version + * + * @return $version Version number of this miner + */ + protected final function getVersion () { + return $this->version; + } + + /** + * Setter for version + * + * @param $version Version number of this miner + * @return void + */ + protected final function setVersion ($version) { + $this->version = (string) $version; + } + + /** + * Checks whether the in-buffer queue is filled by comparing it's current + * amount of entries against a threshold. + * + * @return $isFilled Whether the in-buffer is filled + */ + protected function isInBufferQueueFilled () { + // Determine it + $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > $this->getConfigInstance()->getConfigEntry('miner_in_buffer_min_threshold')); + + // And return the result + return $isFilled; + } + + /** + * This method fills the in-buffer with (a) test unit(s) which are mainly + * used for development of the crunching part. They must be enabled in + * configuration, or else your miner runs out of WUs and waits for more + * to show up. + * + * In this method we already know that the in-buffer is going depleted so + * no need to double-check it here. + * + * @return void + */ + abstract protected function fillInBufferQueueWithTestUnits (); + + /** + * This method fills the in-buffer with (real) WUs which will be crunched + * and the result be sent back to the key producer instance. + * + * @return void + */ + abstract protected function fillInBufferQueueWithWorkUnits (); + + /** + * Enables/disables the miner (just sets a flag) + * + * @param $version Version number of this miner + * @return void + */ + public final function enableIsActive ($isActive = TRUE) { + $this->isActive = (bool) $isActive; + } + + /** + * Determines whether the miner is active + * + * @return $isActive Whether the miner is active + */ + public final function isActive () { + return $this->isActive; + } + + /** + * Initializes all buffer queues (mostly in/out). This method is demanded + * by the MinerHelper interface. + * + * @return void + */ + public function initBufferQueues () { + /* + * Initialize both buffer queues, we can use the FIFO class here + * directly and encapsulate its method calls with protected methods. + */ + $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('miner_buffer_stacker_class'); + + // Initialize common stackers, like in/out + $this->bufferInstance->initStacks(array( + self::STACKER_NAME_IN_QUEUE, + self::STACKER_NAME_OUT_QUEUE + )); + + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('MINER: All buffers are now initialized.'); + } + + /** + * This method determines if the in-buffer is going to depleted and if so, + * it fetches more WUs from the network. If no WU can be fetched from the + * network and if enabled, a random test WU is being generated. + * + * This method is demanded from the MinerHelper interface. + * + * @return void + */ + public function doFetchWorkUnits () { + // Simply check if we have enough WUs left in the in-buffer queue (a FIFO) + if (!$this->isInBufferQueueFilled()) { + // The in-buffer queue needs filling, so head out and get some work + $this->fillInBufferQueueWithWorkUnits(); + + // Is the buffer still not filled and are test-packages allowed? + if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'Y')) { + // Then fill the in-buffer with (one) test-unit(s) + $this->fillInBufferQueueWithTestUnits(); + } // END - if + } // END - if + } + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + * @throws DatabaseUpdateSupportException If this class does not support database updates + * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem + */ + public function updateDatabaseField ($fieldName, $fieldValue) { + // Unfinished + $this->partialStub('Unfinished!'); + return; + } + + /** + * Changes the state to 'booting' and shall be called after the block + * producer has been initialized. + * + * @param $producerInstance An instance of a BlockProducer class + * @return void + */ + public function blockProducerHasInitialized (BlockProducer $producerInstance) { + // Make sure the state is correct ('init') + $this->getStateInstance()->validateMinerStateIsInit(); + + // Mark given producer as initialized + $this->producersInitialized[$producerInstance->__toString()] = TRUE; + + // Has all producers been initialized? + if (count($this->producersInitialized) == self::MAX_PRODUCERS) { + // Change it to 'booting' + MinerStateFactory::createMinerStateInstanceByName('booting'); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/nodes/.htaccess b/application/hub/classes/nodes/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/nodes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/nodes/boot/.htaccess b/application/hub/classes/nodes/boot/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/nodes/boot/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/nodes/boot/class_HubBootNode.php b/application/hub/classes/nodes/boot/class_HubBootNode.php new file mode 100644 index 000000000..62342384d --- /dev/null +++ b/application/hub/classes/nodes/boot/class_HubBootNode.php @@ -0,0 +1,136 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubBootNode extends BaseHubNode implements NodeHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this hub-node class + * + * @param $requestInstance An instance of a Requestable class + * @return $nodeInstance An instance of this hub-node class + */ + public static final function createHubBootNode (Requestable $requestInstance) { + // Get a new instance + $nodeInstance = new HubBootNode(); + + // Set the request instance + $nodeInstance->setRequestInstance($requestInstance); + + // Return the instance + return $nodeInstance; + } + + /** + * Method to "bootstrap" the node. This step does also apply provided + * command-line arguments stored in the request instance. The regular node + * should communicate with the bootstrap-nodes at this point. + * + * @return void + * @todo add some more special bootstrap things for this boot node + */ + public function doBootstrapping () { + // Get UNL + $unl = $this->detectOwnUniversalNodeLocator(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl); + + // Now check if the IP address matches one of the bootstrap nodes + if ($this->ifAddressMatchesBootstrapNodes($unl)) { + // Get our port from configuration + $ourPort = $this->getConfigInstance()->getConfigEntry('node_listen_port'); + + // Extract port + $bootPort = substr($this->getBootUniversalNodeLocator(), -strlen($ourPort), strlen($ourPort)); + + // Is the port the same? + if ($bootPort == $ourPort) { + // It is the same! + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: UNL matches bootstrap node ' . $this->getBootUniversalNodeLocator() . '.'); + + // Now, does the mode match + if ($this->getRequestInstance()->getRequestElement('mode') == self::NODE_TYPE_BOOT) { + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Our node is a valid bootstrap node.'); + } else { + // Output warning + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Mismatching mode ' . $this->getRequestInstance()->getRequestElement('mode') . '!=' . BaseHubNode::NODE_TYPE_BOOT . ' detected.'); + } + } else { + // IP does match, but no port + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our UNL ' . $unl . ' does match a known bootstrap-node but not the port ' . $ourPort . '/' . $bootPort . '.'); + } + } else { + // Node does not match any know bootstrap-node + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our UNL ' . $unl . ' does not match any known bootstrap-nodes.'); + } + + // Enable acceptance of announcements + $this->enableAcceptingAnnouncements(); + + // This might not be all... + $this->partialStub('Please implement more bootsrapping steps.'); + } + + /** + * Add some node-specific filters + * + * @return void + */ + public function addExtraNodeFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); + } + + /** + * Adds extra tasks to the given handler for this node + * + * @param $handlerInstance An instance of a HandleableTask class + * @return void + */ + public function addExtraTasks (HandleableTask $handlerInstance) { + // Prepare a task for booting the DHT + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_bootstrap_task_class'); + + // Register it + $handlerInstance->registerTask('dht_bootstrap', $taskInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/nodes/class b/application/hub/classes/nodes/class new file mode 100644 index 000000000..24dbb9808 --- /dev/null +++ b/application/hub/classes/nodes/class @@ -0,0 +1,11 @@ + + /** + * Adds extra tasks to the given handler for this node + * + * @param $handlerInstance An instance of a HandleableTask class + * @return void + * @todo 0% done + */ + public function addExtraTasks (HandleableTask $handlerInstance) { + $this->partialStub('Please add some tasks or empty this method.'); + } diff --git a/application/hub/classes/nodes/class_ b/application/hub/classes/nodes/class_ new file mode 100644 index 000000000..9514e1fff --- /dev/null +++ b/application/hub/classes/nodes/class_ @@ -0,0 +1,98 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Hub???Node extends BaseHubNode implements NodeHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this hub-node class + * + * @param $requestInstance An instance of a Requestable class + * @return $nodeInstance An instance of this hub-node class + */ + public final static function createHub???Node (Requestable $requestInstance) { + // Get a new instance + $nodeInstance = new Hub???Node(); + + // Set the request instance + $nodeInstance->setRequestInstance($requestInstance); + + // Return the instance + return $nodeInstance; + } + + /** + * Method to "bootstrap" the node. This step does also apply provided + * command-line arguments stored in the request instance. The regular node + * should communicate with the bootstrap-nodes at this point. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + // Call generic (parent) bootstrapping method first + parent::doGenericBootstrapping(); + $this->partialStub('Please implement this method.'); + } + + /** + * Initializes hub-specific queues + * + * @return void + * @todo Implement this method + */ + public function initQueues () { + $this->partialStub('Please implement this method.'); + } + + /** + * Add some node-specific filters + * + * @return void + */ + public function addExtraHubFilters () { + // Add some filters here + } + + /** + * Adds extra tasks to the given handler for this node + * + * @param $handlerInstance An instance of a HandleableTask class + * @return void + * @todo 0% done + */ + public function addExtraTasks (HandleableTask $handlerInstance) { + $this->partialStub('Please add some tasks or empty this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php new file mode 100644 index 000000000..1dff70eea --- /dev/null +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -0,0 +1,834 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { + /** + * Node types + */ + const NODE_TYPE_BOOT = 'boot'; + const NODE_TYPE_MASTER = 'master'; + const NODE_TYPE_LIST = 'list'; + const NODE_TYPE_REGULAR = 'regular'; + + // Exception constants + const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00; + + // Other constants + const OBJECT_LIST_SEPARATOR = ','; + + /** + * Universal node locator of bootstrap node + */ + private $bootUnl = ''; + + /** + * Whether this node is anncounced (keep on FALSE!) + * @deprecated + */ + private $hubIsAnnounced = FALSE; + + /** + * Whether this hub is active (default: FALSE) + */ + private $isActive = FALSE; + + /** + * Whether this node accepts announcements (default: FALSE) + */ + private $acceptAnnouncements = FALSE; + + /** + * Whether this node accepts DHT bootstrap requests (default: FALSE) + */ + private $acceptDhtBootstrap = FALSE; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Get a wrapper instance + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_info_db_wrapper_class'); + + // Set it here + $this->setWrapperInstance($wrapperInstance); + + // Get a crypto instance + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // Set it here + $this->setCryptoInstance($cryptoInstance); + + // Set the node instance in registry + Registry::getRegistry()->addInstance('node', $this); + + // Init state which sets the state to 'init' + $this->initState(); + } + + /** + * Initializes the node's state which sets it to 'init' + * + * @return void + */ + private function initState() { + // Get the state factory and create the initial state. + NodeStateFactory::createNodeStateInstanceByName('init'); + } + + /** + * Generates a private key and hashes it (for speeding up things) + * + * @param $searchInstance An instance of a LocalSearchCriteria class + * @return void + */ + private function generatePrivateKeyAndHash (LocalSearchCriteria $searchInstance) { + // Get an RNG instance + $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); + + // Generate a pseudo-random string + $randomString = $rngInstance->randomString(255); + + // Hash and encrypt the string so we become a node id (also documented as "hub id") + $this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString)); + $this->setPrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey())); + + // Register the node id with our wrapper + $this->getWrapperInstance()->registerPrivateKey($this, $this->getRequestInstance(), $searchInstance); + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . ''); + } + + /** + * Generates a random string from various data inluding UUID if PECL + * extension uuid is installed. + * + * @param $length Length of the random part + * @return $randomString Random string + * @todo Make this code more generic and move it to CryptoHelper or + */ + protected function generateRamdomString ($length) { + // Get an RNG instance + $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); + + // Generate a pseudo-random string + $randomString = $rngInstance->randomString($length) . ':' . $this->getBootUniversalNodeLocator() . ':' . $this->getRequestInstance()->getRequestElement('mode'); + + // Add UUID for even more entropy for the hasher + $randomString .= $this->getCryptoInstance()->createUuid(); + + // Return it + return $randomString; + } + + /** + * Getter for boot UNL (Universal Node Locator) + * + * @return $bootUnl The UNL (Universal Node Locator) of the boot node + */ + protected final function getBootUniversalNodeLocator () { + return $this->bootUnl; + } + + /** + * Checks whether the given IP address matches one of the bootstrap nodes + * + * @param $remoteAddr IP address to checkout against our bootstrapping list + * @return $isFound Whether the IP is found + */ + protected function ifAddressMatchesBootstrapNodes ($remoteAddr) { + // By default nothing is found + $isFound = FALSE; + + // Run through all configured IPs + foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) { + // Does it match? + if ($unl == $remoteAddr) { + // Found it! + $isFound = TRUE; + + // Remember the UNL + $this->bootUnl = $unl; + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: UNL matches remote address ' . $unl . '.'); + + // Stop further searching + break; + } elseif ($unl == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) { + /* + * IP matches listen address. At this point we really don't care + * if we can really listen on that address + */ + $isFound = TRUE; + + // Remember the port number + $this->bootUnl = $unl; + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: UNL matches listen address ' . $unl . '.'); + + // Stop further searching + break; + } + } // END - foreach + + // Return the result + return $isFound; + } + + /** + * Tries to detect own UNL (Universal Node Locator) + * + * @return $unl Node's own universal node locator + */ + public function detectOwnUniversalNodeLocator () { + // Is "cache" set? + if (!isset($GLOBALS[__METHOD__])) { + // Get the UNL array back + $unlData = $this->getUniversalNodeLocatorArray(); + + // There are 2 UNLs, internal and external. + if ($this->getConfigInstance()->getConfigEntry('allow_publish_internal_address') == 'N') { + // Public "external" UNL address + $GLOBALS[__METHOD__] = $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]; + } else { + // Non-public "internal" UNL address + $GLOBALS[__METHOD__] = $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL]; + } + } // END - if + + // Return it + return $GLOBALS[__METHOD__]; + } + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + public function outputConsoleTeaser () { + // Get the app instance (for shortening our code) + $app = $this->getApplicationInstance(); + + // Output all lines + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' mode active'); + self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); + self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); + self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); + self::createDebugInstance(__CLASS__)->debugOutput(' '); + } + + /** + * Generic method to acquire a hub-id. On first run this generates a new one + * based on many pseudo-random data. On any later run, unless the id + * got not removed from database, it will be restored from the database. + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance) { + // Is there a node id? + if ($this->getWrapperInstance()->ifNodeDataIsFound($this)) { + // Get the node id from result and set it + $this->setNodeId($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID)); + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . ''); + } else { + // Get an RNG instance + $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); + + // Generate a pseudo-random string + $randomString = $rngInstance->randomString(255); + + // Hash and encrypt the string so we become a node id (also documented as "hub id") + $this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString))); + + // Register the node id with our wrapper + $this->getWrapperInstance()->registerNodeId($this, $this->getRequestInstance()); + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . ''); + } + } + + /** + * Generates a session id which will be sent to the other hubs and peers + * + * @return void + */ + public function bootstrapGenerateSessionId () { + // Now get a search criteria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Search for the node number one which is hard-coded the default + $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1); + $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $this->getRequestInstance()->getRequestElement('mode')); + $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID , $this->getNodeId()); + $searchInstance->setLimit(1); + + // Remember it for later usage + $this->setSearchInstance($searchInstance); + + // Get a random string + $randomString = $this->generateRamdomString(255); + + // Hash and encrypt the string so we become a "node id" aka Hub-Id + $this->setSessionId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString))); + + // Register the node id with our wrapper + $this->getWrapperInstance()->registerSessionId($this, $this->getRequestInstance(), $searchInstance); + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . ''); + + // Change the state because the node has aquired a session id + $this->getStateInstance()->nodeGeneratedSessionId(); + } + + /** + * Generate a private key for en-/decryption + * + * @return void + */ + public function bootstrapGeneratePrivateKey () { + // Is it valid? + if ($this->getWrapperInstance()->ifNodeDataIsFound($this)) { + // Is the element set? + if (is_null($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY))) { + /* + * Auto-generate the private key for e.g. out-dated database + * "tables". This allows a smooth update for the underlaying + * database table. + */ + $this->generatePrivateKeyAndHash($this->getSearchInstance()); + } else { + // Get the node id from result and set it + $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY))); + $this->setPrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH)); + + // Output message + self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found private key hash: ' . $this->getPrivateKeyHash() . ''); + } + } else { + /* + * Generate it in a private method (no confusion with 'private + * method access' and 'private key' here! ;-)). + */ + $this->generatePrivateKeyAndHash($this->getSearchInstance()); + } + } + + /** + * Adds hub data elements to a given dataset instance + * + * @param $criteriaInstance An instance of a storeable criteria + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { + // Make sure the request instance is set as it is not optional. + assert($requestInstance instanceof Requestable); + + // Add node number and type + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1); + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $requestInstance->getRequestElement('mode')); + + // Add the node id + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId()); + + // Add the session id if acquired + if ($this->getSessionId() != '') { + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId()); + } // END - if + + // Add the private key if acquired + if ($this->getPrivateKey() != '') { + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey())); + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash()); + } // END - if + + // Add own external and internal addresses as UNLs + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, HubTools::determineOwnInternalAddress()); + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, HubTools::determineOwnExternalAddress()); + } + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + * @throws DatabaseUpdateSupportException If this class does not support database updates + * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem + */ + public function updateDatabaseField ($fieldName, $fieldValue) { + // Unfinished + $this->partialStub('Unfinished!'); + return; + + // Get a critieria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add search criteria + $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $searchInstance->setLimit(1); + + // Now get another criteria + $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); + + // Add criteria entry which we shall update + $updateInstance->addCriteria($fieldName, $fieldValue); + + // Add the search criteria for searching for the right entry + $updateInstance->setSearchInstance($searchInstance); + + // Set wrapper class name + $updateInstance->setWrapperConfigEntry('user_db_wrapper_class'); + + // Remember the update in database result + $this->getResultInstance()->add2UpdateQueue($updateInstance); + } + + /** + * Announces this hub to the upper (bootstrap or list) hubs. After this is + * successfully done the given task is unregistered from the handler. This + * might look a bit overloaded here but the announcement phase isn't a + * simple "Hello there" message, it may later on also contain more + * informations like the object list. + * + * @param $taskInstance The task instance running this announcement + * @return void + * @throws NodeAlreadyAnnouncedException If this hub is already announced + * @todo Change the first if() block to check for a specific state + */ + public function announceToUpperNodes (Taskable $taskInstance) { + // Is this hub node announced? + if ($this->hubIsAnnounced === TRUE) { + // Already announced! + throw new NodeAlreadyAnnouncedException($this, self::EXCEPTION_HUB_ALREADY_ANNOUNCED); + } // END - if + + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('HUB-Announcement: START (taskInstance=' . $taskInstance->__toString(). ')'); + + // Get a helper instance + $helperInstance = ObjectFactory::createObjectByConfiguredName('node_announcement_helper_class'); + + // Load the announcement descriptor + $helperInstance->loadDescriptorXml($this); + + // Compile all variables + $helperInstance->getTemplateInstance()->compileConfigInVariables(); + + // "Publish" the descriptor by sending it to the bootstrap/list nodes + $helperInstance->sendPackage($this); + + // Change the state, this should be the last line except debug output + $this->getStateInstance()->nodeAnnouncingToUpperHubs(); + + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('HUB-Announcement: FINISHED'); + } + + /** + * Does a self-connect attempt on the public IP address. This should make + * it sure, we are reachable from outside world. For this kind of package we + * don't need that overload we have in the announcement phase. + * + * @param $taskInstance The task instance running this announcement + * @return void + */ + public function doSelfConnection (Taskable $taskInstance) { + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Self Connection: START (taskInstance=' . $taskInstance->__toString(). ')'); + + // Get a helper instance + $helperInstance = ObjectFactory::createObjectByConfiguredName('node_self_connect_helper_class', array($this)); + + // Load the descriptor (XML) file + $helperInstance->loadDescriptorXml($this); + + // Compile all variables + $helperInstance->getTemplateInstance()->compileConfigInVariables(); + + // And send the package away + $helperInstance->sendPackage($this); + + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Self Connection: FINISHED'); + } + + /** + * Activates the hub by doing some final preparation and setting + * $hubIsActive to TRUE. + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function activateNode (Requestable $requestInstance, Responseable $responseInstance) { + // Checks whether a listener is still active and shuts it down if one + // is still listening. + if (($this->determineIfListenerIsActive()) && ($this->isNodeActive())) { + // Shutdown them down before they can hurt anything + $this->shutdownListenerPool(); + } // END - if + + // Get the controller here + $controllerInstance = Registry::getRegistry()->getInstance('controller'); + + // Run all filters for the hub activation + $controllerInstance->executeActivationFilters($requestInstance, $responseInstance); + + // ----------------------- Last step from here ------------------------ + // Activate the hub. This is ALWAYS the last step in this method + $this->getStateInstance()->nodeIsActivated(); + // ---------------------- Last step until here ------------------------ + } + + /** + * Initializes the listener pool (class) + * + * @return void + */ + public function initializeListenerPool () { + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Initialize listener: START'); + + // Get a new pool instance + $this->setListenerPoolInstance(ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this))); + + // Get an instance of the low-level listener + $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this)); + + // Setup address and port + $listenerInstance->setListenAddressByConfiguration('node_listen_addr'); + + /* + * All nodes can now use the same configuration entry because it can be + * customized in config-local.php. + */ + $listenerInstance->setListenPortByConfiguration('node_listen_port'); + + // Initialize the listener + $listenerInstance->initListener(); + + // Get a decorator class + $decoratorInstance = ObjectFactory::createObjectByConfiguredName('node_tcp_listener_class', array($listenerInstance)); + + // Add this listener to the pool + $this->getListenerPoolInstance()->addListener($decoratorInstance); + + // Get a decorator class + $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance)); + + // Add this listener to the pool + $this->getListenerPoolInstance()->addListener($decoratorInstance); + + // Get an instance of the low-level listener + $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this)); + + // Setup address and port + $listenerInstance->setListenAddressByConfiguration('node_listen_addr'); + + /* + * All nodes can now use the same configuration entry because it can be + * customized in config-local.php. + */ + $listenerInstance->setListenPortByConfiguration('node_listen_port'); + + // Initialize the listener + $listenerInstance->initListener(); + + // Get a decorator class + $decoratorInstance = ObjectFactory::createObjectByConfiguredName('node_udp_listener_class', array($listenerInstance)); + + // Add this listener to the pool + $this->getListenerPoolInstance()->addListener($decoratorInstance); + + // Get a decorator class + $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance)); + + // Add this listener to the pool + $this->getListenerPoolInstance()->addListener($decoratorInstance); + + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Initialize listener: FINISHED.'); + } + + /** + * Getter for isActive attribute + * + * @return $isActive Whether the hub is active + */ + public final function isNodeActive () { + return $this->isActive; + } + + /** + * Enables (default) or disables isActive flag + * + * @param $isActive Whether the hub is active + * @return void + */ + public final function enableIsActive ($isActive = TRUE) { + $this->isActive = (bool) $isActive; + } + + /** + * Checks whether this node accepts announcements + * + * @return $acceptAnnouncements Whether this node accepts announcements + */ + public final function isAcceptingAnnouncements () { + // Check it (this node must be active and not shutdown!) + $acceptAnnouncements = (($this->acceptAnnouncements === TRUE) && ($this->isNodeActive())); + + // Return it + return $acceptAnnouncements; + } + + /** + * Checks whether this node accepts DHT bootstrap requests + * + * @return $acceptDhtBootstrap Whether this node accepts DHT bootstrap requests + */ + public final function isAcceptingDhtBootstrap () { + // Check it (this node must be active and not shutdown!) + $acceptDhtBootstrap = (($this->acceptDhtBootstrap === TRUE) && ($this->isNodeActive())); + + // Return it + return $acceptDhtBootstrap; + } + + /** + * Checks whether this node has attempted to announce itself + * + * @return $hasAnnounced Whether this node has attempted to announce itself + * @todo Add checking if this node has been announced to the sender node + */ + public function ifNodeIsAnnouncing () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeIsAnnouncing(): state=' . $this->getStateInstance()->getStateName()); + + // Simply check the state of this node + $hasAnnounced = ($this->getStateInstance() instanceof NodeAnnouncingState); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeIsAnnouncing(): hasAnnounced=' . intval($hasAnnounced)); + + // Return it + return $hasAnnounced; + } + + /** + * Checks whether this node has attempted to announce itself and completed it + * + * @return $hasAnnouncementCompleted Whether this node has attempted to announce itself and completed it + * @todo Add checking if this node has been announced to the sender node + */ + public function ifNodeHasAnnouncementCompleted () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName()); + + // Simply check the state of this node + $hasAnnouncementCompleted = ($this->getStateInstance() instanceof NodeAnnouncementCompletedState); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted)); + + // Return it + return $hasAnnouncementCompleted; + } + + /** + * Enables whether this node accepts announcements + * + * @param $acceptAnnouncements Whether this node accepts announcements (default: TRUE) + * @return void + */ + protected final function enableAcceptingAnnouncements ($acceptAnnouncements = TRUE) { + $this->acceptAnnouncements = $acceptAnnouncements; + } + + /** + * Enables whether this node accepts DHT bootstrap requests + * + * @param $acceptDhtBootstrap Whether this node accepts DHT bootstrap requests (default: TRUE) + * @return void + */ + public final function enableAcceptDhtBootstrap ($acceptDhtBootstrap = TRUE) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Enabling DHT bootstrap requests ...'); + $this->acceptDhtBootstrap = $acceptDhtBootstrap; + } + + /** + * Checks wether this node is accepting node-list requests + * + * @return $acceptsRequest Wether this node accepts node-list requests + */ + public function isAcceptingNodeListRequests () { + /* + * Only 'regular' nodes does not accept such requests, checking + * HubRegularNode is faster, but if e.g. HubRegularI2PNode will be + * added then the next check will be TRUE. + */ + $acceptsRequest = ((!$this instanceof HubRegularNode) && ($this->getRequestInstance()->getRequestElement('mode') != self::NODE_TYPE_REGULAR)); + + // Return it + return $acceptsRequest; + } + + /** + * Determines an instance of a LocateableNode class + * + * @return $unlInstance An instance of a LocateableNode class for this node + */ + public function determineUniversalNodeLocator () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Determine UNL based on this node: + // 1) Get discovery class + $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class'); + + // 2) "Determine" it + $unlInstance = $discoveryInstance->discoverUniversalNodeLocatorByNode($this); + + // 3) Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unlInstance= ' . $unlInstance->__toString() . ' - EXIT!'); + return $unlInstance; + } + + /** + * "Getter" for an array of an instance of a LocateableNode class + * + * @return $unlData An array from an instance of a LocateableNode class for this node + */ + public final function getUniversalNodeLocatorArray () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Get the Universal Node Locator (UNL) instance + $unlInstance = $this->determineUniversalNodeLocator(); + + // Make sure the instance is valid + if (!$unlInstance instanceof LocateableNode) { + // No valid instance, so better debug this + $this->debugBackTrace('unlInstance[' . gettype($unlInstance) . ']=' . $unlInstance); + } // END - if + + // ... and the array from it + $unlData = $unlInstance->getUnlData(); + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + return $unlData; + } + + /** + * Updates/refreshes node data (e.g. status). + * + * @return void + * @todo Find more to do here + */ + public function updateNodeData () { + // Set some dummy configuration entries, e.g. node_status + $this->getConfigInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName()); + } + + /** + * Handles message answer by given data array + * + * @param $messageData A valid answer message data array + * @param $packageInstance An instance of a Receivable class + * @return void + * @todo Handle thrown exception + */ + public function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance) { + // Is it not empty? + assert(!empty($messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS])); + + // Construct configuration entry for handling class' name + $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]) . '_handler_class'; + + // Try to get a class + $handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry); + + // Handle it there + $handlerInstance->handleAnswerMessageData($messageData, $packageInstance); + } + + /** + * "Getter" for an array of all accepted object types + * + * @return $objectList Array of all accepted object types + */ + public function getListFromAcceptedObjectTypes () { + // Get registry instance + $objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); + + // Get all entries + $objectList = $objectRegistryInstance->getEntries(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME); + + // ... and return it + return $objectList; + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $nodeData An array with valid node data + * @return void + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $nodeData) { + // Add all data the array provides + foreach (NodeDistributedHashTableDatabaseWrapper::getAllElements() as $element) { + // Is the element there? + if (isset($nodeData[$element])) { + // Add it + $dataSetInstance->addCriteria($element, $nodeData[$element]); + } else { + // Output warning message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in nodeData array.'); + } + } // END - foreac + } +} + +// [EOF] +?> diff --git a/application/hub/classes/nodes/list/.htaccess b/application/hub/classes/nodes/list/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/nodes/list/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/nodes/list/class_HubListNode.php b/application/hub/classes/nodes/list/class_HubListNode.php new file mode 100644 index 000000000..ac7c92fd5 --- /dev/null +++ b/application/hub/classes/nodes/list/class_HubListNode.php @@ -0,0 +1,96 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubListNode extends BaseHubNode implements NodeHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this hub-node class + * + * @param $requestInstance An instance of a Requestable class + * @return $nodeInstance An instance of this hub-node class + */ + public static final function createHubListNode (Requestable $requestInstance) { + // Get a new instance + $nodeInstance = new HubListNode(); + + // Set the request instance + $nodeInstance->setRequestInstance($requestInstance); + + // Return the instance + return $nodeInstance; + } + + /** + * Method to "bootstrap" the node. This step does also apply provided + * command-line arguments stored in the request instance. The regular node + * should communicate with the bootstrap-nodes at this point. + * + * @return void + * @todo Implement more bootstrap steps + */ + public function doBootstrapping () { + $this->partialStub(); + } + + /** + * Add some node-specific filters + * + * @return void + */ + public function addExtraNodeFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // Self-announcement task + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_announcement_task_filter')); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); + } + + /** + * Adds extra tasks to the given handler for this node + * + * @param $handlerInstance An instance of a HandleableTask class + * @return void + * @todo 0% done + */ + public function addExtraTasks (HandleableTask $handlerInstance) { + $this->partialStub('Please add some tasks or empty this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/nodes/master/.htaccess b/application/hub/classes/nodes/master/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/nodes/master/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/nodes/master/class_HubMasterNode.php b/application/hub/classes/nodes/master/class_HubMasterNode.php new file mode 100644 index 000000000..2893a05d4 --- /dev/null +++ b/application/hub/classes/nodes/master/class_HubMasterNode.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubMasterNode extends BaseHubNode implements NodeHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this hub-node class + * + * @param $requestInstance An instance of a Requestable class + * @return $nodeInstance An instance of this hub-node class + */ + public static final function createHubMasterNode (Requestable $requestInstance) { + // Get a new instance + $nodeInstance = new HubMasterNode(); + + // Set the request instance + $nodeInstance->setRequestInstance($requestInstance); + + // Return the instance + return $nodeInstance; + } + + /** + * Method to "bootstrap" the node. This step does also apply provided + * command-line arguments stored in the request instance. The regular node + * should communicate with the bootstrap-nodes at this point. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + // Enable acceptance of announcements + $this->enableAcceptingAnnouncements(); + + // Do more steps + $this->partialStub('Please implement more boot-strapping steps!'); + } + + /** + * Add some node-specific filters + * + * @return void + */ + public function addExtraNodeFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // Self-announcement task + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_announcement_task_filter')); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); + } + + /** + * Adds extra tasks to the given handler for this node + * + * @param $handlerInstance An instance of a HandleableTask class + * @return void + * @todo 0% done + */ + public function addExtraTasks (HandleableTask $handlerInstance) { + $this->partialStub('Please add some tasks or empty this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/nodes/regular/.htaccess b/application/hub/classes/nodes/regular/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/nodes/regular/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/nodes/regular/class_HubRegularNode.php b/application/hub/classes/nodes/regular/class_HubRegularNode.php new file mode 100644 index 000000000..7bfdaf899 --- /dev/null +++ b/application/hub/classes/nodes/regular/class_HubRegularNode.php @@ -0,0 +1,96 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubRegularNode extends BaseHubNode implements NodeHelper, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this hub-node class + * + * @param $requestInstance An instance of a Requestable class + * @return $nodeInstance An instance of this hub-node class + */ + public static final function createHubRegularNode (Requestable $requestInstance) { + // Get a new instance + $nodeInstance = new HubRegularNode(); + + // Set the request instance + $nodeInstance->setRequestInstance($requestInstance); + + // Return the instance + return $nodeInstance; + } + + /** + * Method to "bootstrap" the node. This step does also apply provided + * command-line arguments stored in the request instance. The regular node + * should communicate with the bootstrap-nodes at this point. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + $this->partialStub(); + } + + /** + * Add some node-specific filters + * + * @return void + */ + public function addExtraNodeFilters () { + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get the controller from the application + $controllerInstance = $applicationInstance->getControllerInstance(); + + // Self-announcement task + $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_announcement_task_filter')); + + // @TODO Add some filters here + $this->partialStub('Add some filters here.'); + } + + /** + * Adds extra tasks to the given handler for this node + * + * @param $handlerInstance An instance of a HandleableTask class + * @return void + * @todo 0% done + */ + public function addExtraTasks (HandleableTask $handlerInstance) { + $this->partialStub('Please add some tasks or empty this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/package/.htaccess b/application/hub/classes/package/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/package/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/package/assembler/.htaccess b/application/hub/classes/package/assembler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/package/assembler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php new file mode 100644 index 000000000..192c54fb1 --- /dev/null +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -0,0 +1,322 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, Visitable { + /** + * Name for stacker holding raw data of multiple messages + */ + const STACKER_NAME_MULTIPLE_MESSAGE = 'multiple_message'; + + /** + * Pending data + */ + private $pendingData = ''; + + /** + * Private call-back methods + */ + private $callbacks = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $packageInstance An instance of a Receivable class + * @return $assemblerInstance An instance of an Assembler class + */ + public static final function createPackageAssembler (Receivable $packageInstance) { + // Get new instance + $assemblerInstance = new PackageAssembler(); + + // Set package instance here + $assemblerInstance->setPackageInstance($packageInstance); + + // Create an instance of a raw data input stream + $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_input_stream_class'); + + // And set it + $assemblerInstance->setInputStreamInstance($streamInstance); + + // Now get a chunk handler instance + $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); + + // Set handler instance + $assemblerInstance->setHandlerInstance($handlerInstance); + + // Get stacker instance + $stackInstance = ObjectFactory::createObjectByConfiguredName('multiple_message_stacker_class'); + + // Initialize the only one stack + $stackInstance->initStack(self::STACKER_NAME_MULTIPLE_MESSAGE); + + // And add it + $assemblerInstance->setStackInstance($stackInstance); + + // Return the prepared instance + return $assemblerInstance; + } + + /** + * Checks whether the input buffer (stacker to be more preceise) is empty. + * + * @return $isInputBufferEmpty Whether the input buffer is empty + */ + private function ifInputBufferIsEmpty () { + // Check it + $isInputBufferEmpty = $this->getPackageInstance()->getStackInstance()->isStackEmpty(NetworkPackage::STACKER_NAME_DECODED_HANDLED); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: isInputBufferEmpty=' . intval($isInputBufferEmpty)); + + // Return it + return $isInputBufferEmpty; + } + + /** + * Checks whether given package content is completed (start/end markers are found) + * + * @param $packageContent An array with two elements: 'raw_data' and 'error_code' + * @return $isCompleted Whether the given package content is completed + */ + private function isPackageContentCompleted (array $packageContent) { + // Check both + $isCompleted = $this->ifStartEndMarkersSet($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); + + // Return status + return $isCompleted; + } + + /** + * Assembles the content from $packageContent. This method does only + * initialize the whole process by creating a call-back which will then + * itself (99.9% of all cases) "explode" the decoded data stream and add + * it to a chunk assembler queue. + * + * If the call-back method or this would attempt to assemble the package + * chunks and (maybe) re-request some chunks from the sender, this would + * take to much time and therefore slow down this node again. + * + * @param $packageContent An array with two elements: 'raw_data' and 'error_code' + * @return void + * @throws UnsupportedPackageCodeHandlerException If the package code handler is not implemented + */ + public function chunkPackageContent (array $packageContent) { + // Validate the package content array again + assert( + (isset($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA])) && + (isset($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE])) + ); + + // Construct call-back name from package error code + $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]] = 'handlePackageBy' . self::convertToClassName($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]); + + // Abort if the call-back method is not there + if (!method_exists($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]])) { + // Throw an exception + throw new UnsupportedPackageCodeHandlerException(array($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]], $packageContent), BaseListener::EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER); + } // END - if + + // Call it back + call_user_func(array($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]]), $packageContent); + } + + /************************************************************************** + * Call-back methods for above method * + **************************************************************************/ + + /** + * Call-back handler to handle unhandled package data. This method + * "explodes" the string with the chunk separator from PackageFragmenter + * class, does some low checks on it and feeds it into another queue for + * verification and re-request for bad chunks. + * + * @param $packageContent An array with two elements: 'raw_data' and 'error_code' + * @return void + */ + private function handlePackageByUnhandledPackage (array $packageContent) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); + + // Check for some conditions + if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) { + // Last chunk is not valid, so wait for more + $this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]; + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)'); + } else { + // Debug message + //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': packageContent=' . print_r($packageContent, TRUE) . ',chunks='.print_r($chunks, TRUE)); + } + } + + /** + * Checks whether the assembler's pending data is empty which means it has + * no pending data left for handling ... ;-) + * + * @return $ifPendingDataIsEmpty Whether pending data is empty + */ + public function isPendingDataEmpty () { + // A simbple check + $ifPendingDataIsEmpty = empty($this->pendingData); + + // Return it + return $ifPendingDataIsEmpty; + } + + /** + * Checks whether the assembler has multiple messages pending + * + * @return $isPending Whether the assembler has multiple messages pending + */ + public function ifMultipleMessagesPending () { + // Determine it + $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_MULTIPLE_MESSAGE)); + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': isPending=' . intval($isPending)); + return $isPending; + } + + /** + * Handles the assembler's pending data + * + * @return void + */ + public function handlePendingData () { + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData); + + // Assert on condition + assert(!$this->isPendingDataEmpty()); + + // No markers set? + if (!$this->ifStartEndMarkersSet($this->pendingData)) { + // This will cause an assertition in next call, so simply wait for more data + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: this->pendingData=' . $this->pendingData); + return; + } elseif (substr_count($this->pendingData, BaseRawDataHandler::STREAM_START_MARKER) > 1) { + /* + * Multiple messages found, so split off first message as the input + * stream can only handle one message per time. + */ + foreach (explode(BaseRawDataHandler::STREAM_START_MARKER, $this->pendingData) as $message) { + // Prepend start marker again as it is needed to decode the message. + $message = BaseRawDataHandler::STREAM_START_MARKER . $message; + + // Push it on stack + $this->getStackInstance()->pushNamed(self::STACKER_NAME_MULTIPLE_MESSAGE, $message); + } // END - foreach + + // Clear pending data + $this->clearPendingData(); + + // ... and exit here + return; + } + + // Init fake array + $packageContent = array( + BaseRawDataHandler::PACKAGE_RAW_DATA => $this->getInputStreamInstance()->streamData($this->pendingData), + BaseRawDataHandler::PACKAGE_ERROR_CODE => BaseRawDataHandler::SOCKET_ERROR_UNHANDLED + ); + + /* + * Clear pending data as it has been processed and will be handled some + * lines below. + */ + $this->clearPendingData(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.'); + + // Make sure last CHUNK_SEPARATOR is not there + if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) { + // Remove it + $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1); + } // END - if + + /* + * "explode" the string from 'raw_data' with chunk separator to get an + * array of chunks. These chunks must then be verified by their + * checksums. Also the final chunk must be handled. + */ + $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); + + // Add all chunks because the last final chunk is found + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to add ' . count($chunks) . ' to chunk handler ...'); + $this->getHandlerInstance()->addAllChunksWithFinal($chunks); + } + + /** + * Handles multiple messages. + * + * @return void + */ + public function handleMultipleMessages () { + // Assert on condition + assert($this->ifMultipleMessagesPending()); + assert($this->isPendingDataEmpty()); + + // "Pop" next entry from stack and set it as new pending data + $this->pendingData = $this->getStackInstance()->popNamed(self::STACKER_NAME_MULTIPLE_MESSAGE); + + // And handle it + $this->handlePendingData(); + } + + /** + * Accepts the visitor to process the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit the assembler + $visitorInstance->visitAssembler($this); + } + + /** + * Clears pending data + * + * @return void + */ + public function clearPendingData () { + // Clear it + $this->pendingData = ''; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/package/class_NetworkPackage.php b/application/hub/classes/package/class_NetworkPackage.php new file mode 100644 index 000000000..3fdc59eed --- /dev/null +++ b/application/hub/classes/package/class_NetworkPackage.php @@ -0,0 +1,1486 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Needs to add functionality for handling the object's type + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, Registerable, Visitable { + /** + * Package mask for compressing package data: + * 0: Compressor extension + * 1: Raw package data + * 2: Tags, seperated by semicolons, no semicolon is required if only one tag is needed + * 3: Checksum + * 0 1 2 3 + */ + const PACKAGE_MASK = '%s%s%s%s%s%s%s'; + + /** + * Separator for the above mask + */ + const PACKAGE_MASK_SEPARATOR = '^'; + + /** + * Size of an array created by invoking + * explode(NetworkPackage::PACKAGE_MASK_SEPARATOR, $content). + */ + const PACKAGE_CONTENT_ARRAY_SIZE = 4; + + /** + * Separator for checksum + */ + const PACKAGE_CHECKSUM_SEPARATOR = '_'; + + /** + * Array indexes for above mask, start with zero + */ + const INDEX_COMPRESSOR_EXTENSION = 0; + const INDEX_PACKAGE_DATA = 1; + const INDEX_TAGS = 2; + const INDEX_CHECKSUM = 3; + + /** + * Array indexes for raw package array + */ + const INDEX_PACKAGE_SENDER = 0; + const INDEX_PACKAGE_RECIPIENT = 1; + const INDEX_PACKAGE_CONTENT = 2; + const INDEX_PACKAGE_STATUS = 3; + const INDEX_PACKAGE_HASH = 4; + const INDEX_PACKAGE_PRIVATE_KEY_HASH = 5; + + /** + * Size of the decoded data array + */ + const DECODED_DATA_ARRAY_SIZE = 6; + + /** + * Named array elements for decoded package content + */ + const PACKAGE_CONTENT_EXTENSION = 'compressor'; + const PACKAGE_CONTENT_MESSAGE = 'message'; + const PACKAGE_CONTENT_TAGS = 'tags'; + const PACKAGE_CONTENT_CHECKSUM = 'checksum'; + const PACKAGE_CONTENT_SENDER = 'sender'; + const PACKAGE_CONTENT_HASH = 'hash'; + const PACKAGE_CONTENT_PRIVATE_KEY_HASH = 'pkhash'; + + /** + * Named array elements for package data + */ + const PACKAGE_DATA_SENDER = 'sender'; + const PACKAGE_DATA_RECIPIENT = 'recipient'; + const PACKAGE_DATA_CONTENT = 'content'; + const PACKAGE_DATA_STATUS = 'status'; + const PACKAGE_DATA_HASH = 'hash'; + const PACKAGE_DATA_PRIVATE_KEY_HASH = 'pkhash'; + + /** + * All package status + */ + const PACKAGE_STATUS_NEW = 'new'; + const PACKAGE_STATUS_FAILED = 'failed'; + const PACKAGE_STATUS_DECODED = 'decoded'; + const PACKAGE_STATUS_FAKED = 'faked'; + + /** + * Constants for message data array + */ + const MESSAGE_ARRAY_DATA = 'message_data'; + const MESSAGE_ARRAY_TYPE = 'message_type'; + const MESSAGE_ARRAY_SENDER = 'message_sender'; + const MESSAGE_ARRAY_HASH = 'message_hash'; + const MESSAGE_ARRAY_TAGS = 'message_tags'; + + /** + * Generic answer status field + */ + + /** + * Tags separator + */ + const PACKAGE_TAGS_SEPARATOR = ';'; + + /** + * Raw package data separator + */ + const PACKAGE_DATA_SEPARATOR = '#'; + + /** + * Separator for more than one recipient + */ + const PACKAGE_RECIPIENT_SEPARATOR = ':'; + + /** + * Network target (alias): 'upper nodes' + */ + const NETWORK_TARGET_UPPER = 'upper'; + + /** + * Network target (alias): 'self' + */ + const NETWORK_TARGET_SELF = 'self'; + + /** + * Network target (alias): 'dht' + */ + const NETWORK_TARGET_DHT = 'dht'; + + /** + * TCP package size in bytes + */ + const TCP_PACKAGE_SIZE = 512; + + /************************************************************************** + * Stacker for out-going packages * + **************************************************************************/ + + /** + * Stacker name for "undeclared" packages + */ + const STACKER_NAME_UNDECLARED = 'package_undeclared'; + + /** + * Stacker name for "declared" packages (which are ready to send out) + */ + const STACKER_NAME_DECLARED = 'package_declared'; + + /** + * Stacker name for "out-going" packages + */ + const STACKER_NAME_OUTGOING = 'package_outgoing'; + + /************************************************************************** + * Stacker for incoming packages * + **************************************************************************/ + + /** + * Stacker name for "incoming" decoded raw data + */ + const STACKER_NAME_DECODED_INCOMING = 'package_decoded_data'; + + /** + * Stacker name for handled decoded raw data + */ + const STACKER_NAME_DECODED_HANDLED = 'package_handled_decoded'; + + /** + * Stacker name for "chunked" decoded raw data + */ + const STACKER_NAME_DECODED_CHUNKED = 'package_chunked_decoded'; + + /************************************************************************** + * Stacker for incoming messages * + **************************************************************************/ + + /** + * Stacker name for new messages + */ + const STACKER_NAME_NEW_MESSAGE = 'package_new_message'; + + /** + * Stacker name for processed messages + */ + const STACKER_NAME_PROCESSED_MESSAGE = 'package_processed_message'; + + /************************************************************************** + * Stacker for raw data handling * + **************************************************************************/ + + /** + * Stacker for outgoing data stream + */ + const STACKER_NAME_OUTGOING_STREAM = 'outgoing_stream'; + + /** + * Array index for final hash + */ + const RAW_FINAL_HASH_INDEX = 'hash'; + + /** + * Array index for encoded data + */ + const RAW_ENCODED_DATA_INDEX = 'data'; + + /** + * Array index for sent bytes + */ + const RAW_SENT_BYTES_INDEX = 'sent'; + + /** + * Array index for socket resource + */ + const RAW_SOCKET_INDEX = 'socket'; + + /** + * Array index for buffer size + */ + const RAW_BUFFER_SIZE_INDEX = 'buffer'; + + /** + * Array index for diff between buffer and sent bytes + */ + const RAW_DIFF_INDEX = 'diff'; + + /************************************************************************** + * Protocol names * + **************************************************************************/ + const PROTOCOL_TCP = 'TCP'; + const PROTOCOL_UDP = 'UDP'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $compressorInstance A Compressor instance for compressing the content + * @return $packageInstance An instance of a Deliverable class + */ + public static final function createNetworkPackage (Compressor $compressorInstance) { + // Get new instance + $packageInstance = new NetworkPackage(); + + // Now set the compressor instance + $packageInstance->setCompressorInstance($compressorInstance); + + /* + * We need to initialize a stack here for our packages even for those + * which have no recipient address and stamp... ;-) This stacker will + * also be used for incoming raw data to handle it. + */ + $stackInstance = ObjectFactory::createObjectByConfiguredName('network_package_stacker_class'); + + // At last, set it in this class + $packageInstance->setStackInstance($stackInstance); + + // Init all stacker + $packageInstance->initStacks(); + + // Get a visitor instance for speeding up things and set it + $visitorInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_monitor_visitor_class'); + $packageInstance->setVisitorInstance($visitorInstance); + + // Get crypto instance and set it, too + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + $packageInstance->setCryptoInstance($cryptoInstance); + + // Get a singleton package assembler instance from factory and set it here, too + $assemblerInstance = PackageAssemblerFactory::createAssemblerInstance($packageInstance); + $packageInstance->setAssemblerInstance($assemblerInstance); + + // Get node instance + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Get pool instance from node + $poolInstance = $nodeInstance->getListenerPoolInstance(); + + // And set it here + $packageInstance->setListenerPoolInstance($poolInstance); + + // Return the prepared instance + return $packageInstance; + } + + /** + * Initialize all stackers + * + * @param $forceReInit Whether to force reinitialization of all stacks + * @return void + */ + protected function initStacks ($forceReInit = FALSE) { + // Initialize all + $this->getStackInstance()->initStacks(array( + self::STACKER_NAME_UNDECLARED, + self::STACKER_NAME_DECLARED, + self::STACKER_NAME_OUTGOING, + self::STACKER_NAME_DECODED_INCOMING, + self::STACKER_NAME_DECODED_HANDLED, + self::STACKER_NAME_DECODED_CHUNKED, + self::STACKER_NAME_NEW_MESSAGE, + self::STACKER_NAME_PROCESSED_MESSAGE, + self::STACKER_NAME_OUTGOING_STREAM + ), $forceReInit); + } + + /** + * Determines private key hash from given session id + * + * @param $decodedData Array with decoded data + * @return $hash Private key's hash + */ + private function determineSenderPrivateKeyHash (array $decodedData) { + // Get DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Ask DHT for session id + $senderData = $dhtInstance->findNodeLocalBySessionId($decodedData[self::PACKAGE_CONTENT_SENDER]); + + // Is an entry found? + if (count($senderData) > 0) { + // Make sure the element 'private_key_hash' is there + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderData=' . print_r($senderData, TRUE)); + assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])); + + // Return it + return $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]; + } // END - if + + // Make sure the requested element is there + //* DEBUG-DIE */ die('decodedData=' . print_r($decodedData, TRUE)); + assert(isset($decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])); + + // Don't accept empty keys + if (empty($decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])) { + // This needs fixing + die('[' . __METHOD__ . ':' . __LINE__ . ':] Empty private key hash: decodedData=' . print_r($decodedData, TRUE)); + } // END - if + + // There is no DHT entry so, accept the hash from decoded data + return $decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH]; + } + + /** + * "Getter" for hash from given content + * + * @param $content Raw package content + * @return $hash Hash for given package content + */ + private function getHashFromContent ($content) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); + + // Create the hash + // @TODO md5() is very weak, but it needs to be fast + $hash = md5( + $content . + self::PACKAGE_CHECKSUM_SEPARATOR . + $this->getSessionId() . + self::PACKAGE_CHECKSUM_SEPARATOR . + $this->getCompressorInstance()->getCompressorExtension() + ); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); + + // And return it + return $hash; + } + + /** + * Checks whether the checksum (sometimes called "hash") is the same + * + * @param $decodedContent Package raw content + * @param $decodedData Whole raw package data array + * @return $isChecksumValid Whether the checksum is the same + */ + private function isChecksumValid (array $decodedContent, array $decodedData) { + // Get checksum + $checksum = $this->getHashFromContentSessionId($decodedContent, $decodedData[self::PACKAGE_DATA_SENDER]); + + // Is it the same? + $isChecksumValid = ($checksum == $decodedContent[self::PACKAGE_CONTENT_CHECKSUM]); + + // Return it + return $isChecksumValid; + } + + /** + * Change the package with given status in given stack + * + * @param $packageData Raw package data in an array + * @param $stackerName Name of the stacker + * @param $newStatus New status to set + * @return void + */ + private function changePackageStatus (array $packageData, $stackerName, $newStatus) { + // Skip this for empty stacks + if ($this->getStackInstance()->isStackEmpty($stackerName)) { + // This avoids an exception after all packages has failed + return; + } // END - if + + // Pop the entry (it should be it) + $nextData = $this->getStackInstance()->popNamed($stackerName); + + // Compare both hashes + assert($nextData[self::PACKAGE_DATA_HASH] == $packageData[self::PACKAGE_DATA_HASH]); + + // Temporary set the new status + $packageData[self::PACKAGE_DATA_STATUS] = $newStatus; + + // And push it again + $this->getStackInstance()->pushNamed($stackerName, $packageData); + } + + /** + * "Getter" for hash from given content and sender's session id + * + * @param $decodedContent Raw package content + * @param $sessionId Session id of the sender + * @return $hash Hash for given package content + */ + public function getHashFromContentSessionId (array $decodedContent, $sessionId) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]); + + // Create the hash + // @TODO md5() is very weak, but it needs to be fast + $hash = md5( + $decodedContent[self::PACKAGE_CONTENT_MESSAGE] . + self::PACKAGE_CHECKSUM_SEPARATOR . + $sessionId . + self::PACKAGE_CHECKSUM_SEPARATOR . + $decodedContent[self::PACKAGE_CONTENT_EXTENSION] + ); + + // And return it + return $hash; + } + + /////////////////////////////////////////////////////////////////////////// + // Delivering packages / raw data + /////////////////////////////////////////////////////////////////////////// + + /** + * Declares the given raw package data by discovering recipients + * + * @param $packageData Raw package data in an array + * @return void + */ + private function declareRawPackageData (array $packageData) { + // Make sure the required field is there + assert(isset($packageData[self::PACKAGE_DATA_RECIPIENT])); + + /* + * We need to disover every recipient, just in case we have a + * multi-recipient entry like 'upper' is. 'all' may be a not so good + * target because it causes an overload on the network and may be + * abused for attacking the network with large packages. + */ + $discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance(); + + // Discover all recipients, this may throw an exception + $discoveryInstance->discoverRecipients($packageData); + + // Now get an iterator + $iteratorInstance = $discoveryInstance->getIterator(); + + // Make sure the iterator instance is valid + assert($iteratorInstance instanceof Iterator); + + // Rewind back to the beginning + $iteratorInstance->rewind(); + + // ... and begin iteration + while ($iteratorInstance->valid()) { + // Get current entry + $currentRecipient = $iteratorInstance->current(); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]); + + // Set the recipient + $packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient; + + // Push the declared package to the next stack. + $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package declared for recipient ' . $currentRecipient); + + // Skip to next entry + $iteratorInstance->next(); + } // END - while + + /* + * The recipient list can be cleaned up here because the package which + * shall be delivered has already been added for all entries from the + * list. + */ + $discoveryInstance->clearRecipients(); + } + + /** + * Delivers raw package data. In short, this will discover the raw socket + * resource through a discovery class (which will analyse the receipient of + * the package), register the socket with the connection (handler/helper?) + * instance and finally push the raw data on our outgoing queue. + * + * @param $packageData Raw package data in an array + * @return void + */ + private function deliverRawPackageData (array $packageData) { + /* + * This package may become big, depending on the shared object size or + * delivered message size which shouldn't be so long (to save + * bandwidth). Because of the nature of the used protocol (TCP) we need + * to split it up into smaller pieces to fit it into a TCP frame. + * + * So first we need (again) a discovery class but now a protocol + * discovery to choose the right socket resource. The discovery class + * should take a look at the raw package data itself and then decide + * which (configurable!) protocol should be used for that type of + * package. + */ + $discoveryInstance = SocketDiscoveryFactory::createSocketDiscoveryInstance(); + + // Now discover the right protocol + $socketResource = $discoveryInstance->discoverSocket($packageData, BaseConnectionHelper::CONNECTION_TYPE_OUTGOING); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after discoverSocket() has been called.'); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: stateInstance=' . $helperInstance->getStateInstance()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.'); + + // The socket needs to be put in a special registry that can handle such data + $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); + + // Get the connection helper from registry + $helperInstance = Registry::getRegistry()->getInstance('connection'); + + // And make sure it is valid + assert($helperInstance instanceof ConnectionHelper); + + // Get connection info class + $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($helperInstance->getProtocolName(), 'helper'); + + // Will the info instance with connection helper data + $infoInstance->fillWithConnectionHelperInformation($helperInstance); + + // Is it not there? + if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($infoInstance, $socketResource))) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Registering socket ' . $socketResource . ' ...'); + + // Then register it + $registryInstance->registerSocket($infoInstance, $socketResource, $packageData); + } elseif (!$helperInstance->getStateInstance()->isPeerStateConnected()) { + // Is not connected, then we cannot send + self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.'); + + // Shutdown the socket + $this->shutdownSocket($socketResource); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.'); + + // Make sure the connection is up + $helperInstance->getStateInstance()->validatePeerStateConnected(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.'); + + // Enqueue it again on the out-going queue, the connection is up and working at this point + $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after pushNamed() has been called.'); + } + + /** + * Sends waiting packages + * + * @param $packageData Raw package data + * @return void + */ + private function sendOutgoingRawPackageData (array $packageData) { + // Init sent bytes + $sentBytes = 0; + + // Get the right connection instance + $infoInstance = SocketRegistryFactory::createSocketRegistryInstance()->getInfoInstanceFromPackageData($packageData); + + // Test helper instance + assert($infoInstance instanceof ShareableInfo); + + // Get helper instance + $helperInstance = $infoInstance->getHelperInstance(); + + // Some sanity-checks on the object + //* DEBUG-DIE: */ die('[' . __METHOD__ . ':' . __LINE__ . ']: p1=' . $infoInstance->getProtocolName() . ',p2=' . $helperInstance->getProtocolName() . ',infoInstance=' . print_r($infoInstance, TRUE)); + assert($helperInstance instanceof ConnectionHelper); + assert($infoInstance->getProtocolName() == $helperInstance->getProtocolName()); + + // Is this connection still alive? + if ($helperInstance->isShuttedDown()) { + // This connection is shutting down + // @TODO We may want to do somthing more here? + return; + } // END - if + + // Sent out package data + $helperInstance->sendRawPackageData($packageData); + } + + /** + * Generates a secure hash for given raw package content and sender id + * + * @param $content Raw package data + * @param $senderId Sender id to generate a hash for + * @return $hash Hash as hex-encoded string + */ + private function generatePackageHash ($content, $senderId) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!'); + + // Is the feature enabled? + if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { + // Feature is not enabled + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...'); + return NULL; + } // END - if + + // Fake array + $data = array( + self::PACKAGE_CONTENT_SENDER => $senderId, + self::PACKAGE_CONTENT_MESSAGE => $content, + self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => '' + ); + + // Hash content and sender id together, use scrypt + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $senderId . ',content()=' . strlen($content)); + $hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array($senderId . ':' . $content . ':' . $this->determineSenderPrivateKeyHash($data))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash . ' - EXIT!'); + + // Return it + return $hash; + } + + /** + * Checks whether the hash of given package data is 'valid', here that + * means it is the same or not. + * + * @param $decodedArray An array with 'decoded' (explode() was mostly called) data + * @return $isHashValid Whether the hash is valid + * @todo Unfinished area, hashes are currently NOT fully supported + */ + private function isPackageHashValid (array $decodedArray) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!'); + + // Make sure the required array elements are there + assert(isset($decodedArray[self::PACKAGE_CONTENT_SENDER])); + assert(isset($decodedArray[self::PACKAGE_CONTENT_MESSAGE])); + assert(isset($decodedArray[self::PACKAGE_CONTENT_HASH])); + assert(isset($decodedArray[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])); + + // Is the feature enabled? + if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { + // Feature is not enabled, so hashes are always valid + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...'); + return TRUE; + } // END - if + + // Check validity + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]); + //* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE)); + $isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH])); + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: isHashValid=' . intval($isHashValid) . ' - EXIT!'); + return $isHashValid; + } + + /** + * "Enqueues" raw content into this delivery class by reading the raw content + * from given helper's template instance and pushing it on the 'undeclared' + * stack. + * + * @param $helperInstance An instance of a HubHelper class + * @return void + */ + public function enqueueRawDataFromTemplate (HubHelper $helperInstance) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); + + // Get the raw content ... + $content = $helperInstance->getTemplateInstance()->getRawTemplateData(); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('content(' . strlen($content) . ')=' . $content); + + // ... and compress it + $compressed = $this->getCompressorInstance()->compressStream($content); + + // Add magic in front of it and hash behind it, including BASE64 encoding + $packageContent = sprintf(self::PACKAGE_MASK, + // 1.) Compressor's extension + $this->getCompressorInstance()->getCompressorExtension(), + // - separator + self::PACKAGE_MASK_SEPARATOR, + // 2.) Compressed raw package content, encoded with BASE64 + base64_encode($compressed), + // - separator + self::PACKAGE_MASK_SEPARATOR, + // 3.) Tags + implode(self::PACKAGE_TAGS_SEPARATOR, $helperInstance->getPackageTags()), + // - separator + self::PACKAGE_MASK_SEPARATOR, + // 4.) Checksum + $this->getHashFromContent($compressed) + ); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...'); + + // Now prepare the temporary array and push it on the 'undeclared' stack + $this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array( + self::PACKAGE_DATA_SENDER => $this->getSessionId(), + self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(), + self::PACKAGE_DATA_CONTENT => $packageContent, + self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_NEW, + self::PACKAGE_DATA_HASH => $this->generatePackageHash($content, $this->getSessionId()), + self::PACKAGE_DATA_PRIVATE_KEY_HASH => $this->getPrivateKeyHash(), + )); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); + } + + /** + * Checks whether a package has been enqueued for delivery. + * + * @return $isEnqueued Whether a package is enqueued + */ + public function isPackageEnqueued () { + // Check whether the stacker is not empty + $isEnqueued = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED))); + + // Return the result + return $isEnqueued; + } + + /** + * Checks whether a package has been declared + * + * @return $isDeclared Whether a package is declared + */ + public function isPackageDeclared () { + // Check whether the stacker is not empty + $isDeclared = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED))); + + // Return the result + return $isDeclared; + } + + /** + * Checks whether a package should be sent out + * + * @return $isWaitingDelivery Whether a package is waiting for delivery + */ + public function isPackageWaitingForDelivery () { + // Check whether the stacker is not empty + $isWaitingDelivery = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING))); + + // Return the result + return $isWaitingDelivery; + } + + /** + * Checks whether encoded (raw) data is pending + * + * @return $isPending Whether encoded data is pending + */ + public function isEncodedDataPending () { + // Check whether the stacker is not empty + $isPending = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING_STREAM))); + + // Return the result + return $isPending; + } + + /** + * Delivers an enqueued package to the stated destination. If a non-session + * id is provided, recipient resolver is being asked (and instanced once). + * This allows that a single package is being delivered to multiple targets + * without enqueueing it for every target. If no target is provided or it + * can't be determined a NoTargetException is being thrown. + * + * @return void + * @throws NoTargetException If no target can't be determined + */ + public function declareEnqueuedPackage () { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); + + // Make sure this method isn't working if there is no package enqueued + if (!$this->isPackageEnqueued()) { + // This is not fatal but should be avoided + self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!'); + return; + } // END - if + + /* + * Now there are for sure packages to deliver, so start with the first + * one. + */ + $packageData = $this->getStackInstance()->popNamed(self::STACKER_NAME_UNDECLARED); + + // Declare the raw package data for delivery + $this->declareRawPackageData($packageData); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); + } + + /** + * Delivers the next declared package. Only one package per time will be sent + * because this may take time and slows down the whole delivery + * infrastructure. + * + * @return void + */ + public function processDeclaredPackage () { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); + + // Sanity check if we have packages declared + if (!$this->isPackageDeclared()) { + // This is not fatal but should be avoided + self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No package has been declared, but ' . __METHOD__ . ' has been called!'); + return; + } // END - if + + // Get the package + $packageData = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED); + + // Assert on it + assert(isset($packageData[self::PACKAGE_DATA_RECIPIENT])); + + // Try to deliver the package + try { + // And try to send it + $this->deliverRawPackageData($packageData); + + // And remove it finally + $this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED); + } catch (UnexpectedStateException $e) { + // The state is not excepected (shall be 'connected') + self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage()); + + // Mark the package with status failed + $this->changePackageStatus($packageData, self::STACKER_NAME_DECLARED, self::PACKAGE_STATUS_FAILED); + } + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); + } + + /** + * Sends waiting packages out for delivery + * + * @return void + */ + public function sendWaitingPackage () { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); + + // Sanity check if we have packages waiting for delivery + if (!$this->isPackageWaitingForDelivery()) { + // This is not fatal but should be avoided + self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No package is waiting for delivery, but ' . __METHOD__ . ' was called.'); + return; + } // END - if + + // Get the package + $packageData = $this->getStackInstance()->getNamed(self::STACKER_NAME_OUTGOING); + + try { + // Now try to send it + $this->sendOutgoingRawPackageData($packageData); + + // And remove it finally + $this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING); + } catch (InvalidSocketException $e) { + // Output exception message + self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package was not delivered: ' . $e->getMessage()); + + // Mark package as failed + $this->changePackageStatus($packageData, self::STACKER_NAME_OUTGOING, self::PACKAGE_STATUS_FAILED); + } + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); + } + + /** + * Sends out encoded data to a socket + * + * @return void + */ + public function sendEncodedData () { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); + + // Make sure there is pending encoded data + assert($this->isEncodedDataPending()); + + // Pop current data from stack + $encodedDataArray = $this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING_STREAM); + + // Init in this round sent bytes + $sentBytes = 0; + + // Assert on socket + assert(is_resource($encodedDataArray[self::RAW_SOCKET_INDEX])); + + // And deliver it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Sending out ' . strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) . ' bytes,rawBufferSize=' . $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] . ',diff=' . $encodedDataArray[self::RAW_DIFF_INDEX]); + if ($encodedDataArray[self::RAW_DIFF_INDEX] >= 0) { + // Send all out (encodedData is smaller than or equal buffer size) + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], 0, ($encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - $encodedDataArray[self::RAW_DIFF_INDEX])))); + $sentBytes = @socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], ($encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - $encodedDataArray[self::RAW_DIFF_INDEX])); + } else { + // Send buffer size out + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], 0, $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX]))); + $sentBytes = @socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX]); + } + + // If there was an error, we don't continue here + if ($sentBytes === FALSE) { + // Handle the error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $encodedDataArray[self::RAW_SOCKET_INDEX], array('0.0.0.0', '0')); + + // And throw it + throw new InvalidSocketException(array($this, $encodedDataArray[self::RAW_SOCKET_INDEX], $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + } elseif (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) > 0)) { + // Nothing sent means we are done + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')'); + return; + } else { + // The difference between sent bytes and length of raw data should not go below zero + assert((strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) - $sentBytes) >= 0); + + // Add total sent bytes + $encodedDataArray[self::RAW_SENT_BYTES_INDEX] += $sentBytes; + + // Cut out the last unsent bytes + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Sent out ' . $sentBytes . ' of ' . strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) . ' bytes ...'); + $encodedDataArray[self::RAW_ENCODED_DATA_INDEX] = substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], $sentBytes); + + // Calculate difference again + $encodedDataArray[self::RAW_DIFF_INDEX] = $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]); + + // Can we abort? + if (strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) <= 0) { + // Abort here, all sent! + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')'); + return; + } // END - if + } + + // Push array back in stack + $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); + } + + /////////////////////////////////////////////////////////////////////////// + // Receiving packages / raw data + /////////////////////////////////////////////////////////////////////////// + + /** + * Checks whether decoded raw data is pending + * + * @return $isPending Whether decoded raw data is pending + */ + private function isRawDataPending () { + // Just return whether the stack is not empty + $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING)); + + // Return the status + return $isPending; + } + + /** + * Checks whether new raw package data has arrived at a socket + * + * @return $hasArrived Whether new raw package data has arrived for processing + */ + public function isNewRawDataPending () { + // Visit the pool. This monitors the pool for incoming raw data. + $this->getListenerPoolInstance()->accept($this->getVisitorInstance()); + + // Check for new data arrival + $hasArrived = $this->isRawDataPending(); + + // Return the status + return $hasArrived; + } + + /** + * Handles the incoming decoded raw data. This method does not "convert" the + * decoded data back into a package array, it just "handles" it and pushs it + * on the next stack. + * + * @return void + */ + public function handleIncomingDecodedData () { + /* + * This method should only be called if decoded raw data is pending, + * so check it again. + */ + if (!$this->isRawDataPending()) { + // This is not fatal but should be avoided + self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!'); + return; + } // END - if + + // Very noisy debug message: + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.'); + + // "Pop" the next entry (the same array again) from the stack + $decodedData = $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING); + + // Make sure both array elements are there + assert( + (is_array($decodedData)) && + (isset($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA])) && + (isset($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE])) + ); + + /* + * Also make sure the error code is SOCKET_ERROR_UNHANDLED because we + * only want to handle unhandled packages here. + */ + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . BaseRawDataHandler::SOCKET_ERROR_UNHANDLED . ')'); + assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED); + + // Remove the last chunk SEPARATOR (because there is no need for it) + if (substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) { + // It is there and should be removed + $decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1); + } // END - if + + // This package is "handled" and can be pushed on the next stack + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...'); + $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $decodedData); + } + + /** + * Adds raw decoded data from the given handler instance to this receiver + * + * @param $handlerInstance An instance of a Networkable class + * @return void + */ + public function addRawDataToIncomingStack (Networkable $handlerInstance) { + /* + * Get the decoded data from the handler, this is an array with + * 'raw_data' and 'error_code' as elements. + */ + $decodedData = $handlerInstance->getNextRawData(); + + // Very noisy debug message: + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE)); + + // And push it on our stack + $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $decodedData); + } + + /** + * Checks whether incoming decoded data is handled. + * + * @return $isHandled Whether incoming decoded data is handled + */ + public function isIncomingRawDataHandled () { + // Determine if the stack is not empty + $isHandled = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_HANDLED)); + + // Return it + return $isHandled; + } + + /** + * Checks whether the assembler has pending data left + * + * @return $isHandled Whether the assembler has pending data left + */ + public function ifAssemblerHasPendingDataLeft () { + // Determine if the stack is not empty + $isHandled = (!$this->getAssemblerInstance()->isPendingDataEmpty()); + + // Return it + return $isHandled; + } + + /** + * Checks whether the assembler has multiple packages pending + * + * @return $isPending Whether the assembler has multiple packages pending + */ + public function ifMultipleMessagesPending () { + // Determine if the stack is not empty + $isPending = ($this->getAssemblerInstance()->ifMultipleMessagesPending()); + + // Return it + return $isPending; + } + + /** + * Handles the attached assemler's pending data queue to be finally + * assembled to the raw package data back. + * + * @return void + */ + public function handleAssemblerPendingData () { + // Handle it + $this->getAssemblerInstance()->handlePendingData(); + } + + /** + * Handles multiple messages. + * + * @return void + */ + public function handleMultipleMessages () { + // Handle it + $this->getAssemblerInstance()->handleMultipleMessages(); + } + + /** + * Assembles incoming decoded data so it will become an abstract network + * package again. The assembler does later do it's job by an other task, + * not this one to keep best speed possible. + * + * @return void + */ + public function assembleDecodedDataToPackage () { + // Make sure the raw decoded package data is handled + assert($this->isIncomingRawDataHandled()); + + // Get current package content (an array with two elements; see handleIncomingDecodedData() for details) + $packageContent = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECODED_HANDLED); + + // Assert on some elements + assert( + (is_array($packageContent)) && + (isset($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA])) && + (isset($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE])) + ); + + // Start assembling the raw package data array by chunking it + $this->getAssemblerInstance()->chunkPackageContent($packageContent); + + // Remove the package from 'handled_decoded' stack ... + $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED); + + // ... and push it on the 'chunked' stacker + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE)); + $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent); + } + + /** + * Accepts the visitor to process the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); + + // Visit the package + $visitorInstance->visitNetworkPackage($this); + + // Then visit the assembler to handle multiple packages + $this->getAssemblerInstance()->accept($visitorInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); + } + + /** + * Clears all stacks + * + * @return void + */ + public function clearAllStacks () { + // Call the init method to force re-initialization + $this->initStacks(TRUE); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: All stacker have been re-initialized.'); + } + + /** + * Removes the first failed outoging package from the stack to continue + * with next one (it will never work until the issue is fixed by you). + * + * @return void + * @throws UnexpectedPackageStatusException If the package status is not 'failed' + * @todo This may be enchanced for outgoing packages? + */ + public function removeFirstFailedPackage () { + // Get the package again + $packageData = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED); + + // Is the package status 'failed'? + if ($packageData[self::PACKAGE_DATA_STATUS] != self::PACKAGE_STATUS_FAILED) { + // Not failed! + throw new UnexpectedPackageStatusException(array($this, $packageData, self::PACKAGE_STATUS_FAILED), BaseListener::EXCEPTION_UNEXPECTED_PACKAGE_STATUS); + } // END - if + + // Remove this entry + $this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED); + } + + /** + * "Decode" the package content into the same array when it was sent. + * + * @param $rawPackageContent The raw package content to be "decoded" + * @return $decodedData An array with 'sender', 'recipient', 'content' and 'status' elements + */ + public function decodeRawContent ($rawPackageContent) { + // Use the separator '#' to "decode" it + $decodedArray = explode(self::PACKAGE_DATA_SEPARATOR, $rawPackageContent); + + // Assert on count (should be always 3) + assert(count($decodedArray) == self::DECODED_DATA_ARRAY_SIZE); + + /* + * Create 'decodedData' array with all assoziative array elements. + */ + $decodedData = array( + self::PACKAGE_DATA_SENDER => $decodedArray[self::INDEX_PACKAGE_SENDER], + self::PACKAGE_DATA_RECIPIENT => $decodedArray[self::INDEX_PACKAGE_RECIPIENT], + self::PACKAGE_DATA_CONTENT => $decodedArray[self::INDEX_PACKAGE_CONTENT], + self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_DECODED, + self::PACKAGE_DATA_HASH => $decodedArray[self::INDEX_PACKAGE_HASH], + self::PACKAGE_DATA_PRIVATE_KEY_HASH => $decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH] + ); + + // And return it + return $decodedData; + } + + /** + * Handles decoded data for this node by "decoding" the 'content' part of + * it. Again this method uses explode() for the "decoding" process. + * + * @param $decodedData An array with decoded raw package data + * @return void + * @throws InvalidDataChecksumException If the checksum doesn't match + */ + public function handleRawData (array $decodedData) { + /* + * "Decode" the package's content by a simple explode() call, for + * details of the array elements, see comments for constant + * PACKAGE_MASK. + */ + $decodedContent = explode(self::PACKAGE_MASK_SEPARATOR, $decodedData[self::PACKAGE_DATA_CONTENT]); + + // Assert on array count for a very basic validation + assert(count($decodedContent) == self::PACKAGE_CONTENT_ARRAY_SIZE); + + /* + * Convert the indexed array into an associative array. This is much + * better to remember than plain numbers, isn't it? + */ + $decodedContent = array( + // Compressor's extension used to compress the data + self::PACKAGE_CONTENT_EXTENSION => $decodedContent[self::INDEX_COMPRESSOR_EXTENSION], + // Package data (aka "message") in BASE64-decoded form but still compressed + self::PACKAGE_CONTENT_MESSAGE => base64_decode($decodedContent[self::INDEX_PACKAGE_DATA]), + // Tags as an indexed array for "tagging" the message + self::PACKAGE_CONTENT_TAGS => explode(self::PACKAGE_TAGS_SEPARATOR, $decodedContent[self::INDEX_TAGS]), + // Checksum of the _decoded_ data + self::PACKAGE_CONTENT_CHECKSUM => $decodedContent[self::INDEX_CHECKSUM], + // Sender's id + self::PACKAGE_CONTENT_SENDER => $decodedData[self::PACKAGE_DATA_SENDER], + // Hash from decoded raw data + self::PACKAGE_CONTENT_HASH => $decodedData[self::PACKAGE_DATA_HASH], + // Hash of private key + self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $decodedData[self::PACKAGE_DATA_PRIVATE_KEY_HASH] + ); + + // Is the checksum valid? + if (!$this->isChecksumValid($decodedContent, $decodedData)) { + // Is not the same, so throw an exception here + throw new InvalidDataChecksumException(array($this, $decodedContent, $decodedData), BaseListener::EXCEPTION_INVALID_DATA_CHECKSUM); + } // END - if + + /* + * The checksum is the same, then it can be decompressed safely. The + * original message is at this point fully decoded. + */ + $decodedContent[self::PACKAGE_CONTENT_MESSAGE] = $this->getCompressorInstance()->decompressStream($decodedContent[self::PACKAGE_CONTENT_MESSAGE]); + + // And push it on the next stack + $this->getStackInstance()->pushNamed(self::STACKER_NAME_NEW_MESSAGE, $decodedContent); + } + + /** + * Checks whether a new message has arrived + * + * @return $hasArrived Whether a new message has arrived for processing + */ + public function isNewMessageArrived () { + // Determine if the stack is not empty + $hasArrived = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_NEW_MESSAGE)); + + // Return it + return $hasArrived; + } + + /** + * Handles newly arrived messages + * + * @return void + * @todo Implement verification of all sent tags here? + */ + public function handleNewlyArrivedMessage () { + // Make sure there is at least one message + assert($this->isNewMessageArrived()); + + // Get it from the stacker, it is the full array with the decoded message + $decodedContent = $this->getStackInstance()->popNamed(self::STACKER_NAME_NEW_MESSAGE); + + // Generate the hash of comparing it + if (!$this->isPackageHashValid($decodedContent)) { + // Is not valid, so throw an exception here + exit(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . chr(10)); + } // END - if + + // Now get a filter chain back from factory with given tags array + $chainInstance = PackageFilterChainFactory::createChainByTagsArray($decodedContent[self::PACKAGE_CONTENT_TAGS]); + + /* + * Process the message through all filters, note that all other + * elements from $decodedContent are no longer needed. + */ + $chainInstance->processMessage($decodedContent, $this); + + /* + * Post-processing of message data (this won't remove the message from + * the stack). + */ + $chainInstance->postProcessMessage($this); + } + + /** + * Checks whether a processed message is pending for "interpretation" + * + * @return $isPending Whether a processed message is pending + */ + public function isProcessedMessagePending () { + // Check it + $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PROCESSED_MESSAGE)); + + // Return it + return $isPending; + } + + /** + * Handle processed messages by "interpreting" the 'message_type' element + * + * @return void + */ + public function handleProcessedMessage () { + // Get it from the stacker, it is the full array with the processed message + $messageArray = $this->getStackInstance()->popNamed(self::STACKER_NAME_PROCESSED_MESSAGE); + + // Add type for later easier handling + $messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE]; + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: messageArray=' . print_r($messageArray, TRUE)); + + // Create a handler instance from given message type + $handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]); + + // Handle message data + $handlerInstance->handleMessageData($messageArray[self::MESSAGE_ARRAY_DATA], $this); + + // Post-handling of message data + $handlerInstance->postHandleMessageData($messageArray, $this); + } + + /** + * Feeds the hash and sender (as recipient for the 'sender' reward) to the + * miner's queue, unless the message is not a "reward claim" message as this + * leads to an endless loop. You may wish to run the miner to get some + * reward ("Hubcoins") for "mining" this hash. + * + * @param $messageData Array with message data + * @return void + * @todo ~10% done? + */ + public function feedHashToMiner (array $messageData) { + // Is the feature enabled? + if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { + /* + * Feature is not enabled, don't feed the hash to the miner as it + *may be invalid. + */ + return; + } // END - if + + // Make sure the required elements are there + assert(isset($messageData[self::MESSAGE_ARRAY_SENDER])); + assert(isset($messageData[self::MESSAGE_ARRAY_HASH])); + assert(isset($messageData[self::MESSAGE_ARRAY_TAGS])); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); + + // Resolve session id ('sender' is a session id) into node id + $nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]); + + // Is 'claim_reward' the message type? + if (in_array('claim_reward', $messageData[self::MESSAGE_ARRAY_TAGS])) { + /* + * Then don't feed this message to the miner as this causes an + * endless loop of mining. + */ + return; + } // END - if + + $this->partialStub('@TODO nodeId=' . $nodeId . ',messageData=' . print_r($messageData, TRUE)); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/package/fragmenter/.htaccess b/application/hub/classes/package/fragmenter/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/package/fragmenter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php new file mode 100644 index 000000000..a816686c8 --- /dev/null +++ b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php @@ -0,0 +1,542 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registerable { + /** + * Cached chunk size in bits + */ + private $chunkSize = 0; + + /** + * Array for chunks + */ + private $chunks = array(); + + /** + * Array for chunk hashes + */ + private $chunkHashes = array(); + + /** + * Array for chunk pointers + */ + private $chunkPointers = array(); + + /** + * Array for processed packages + */ + private $processedPackages = array(); + + /** + * Serial numbers (array key is final hash) + */ + private $serialNumber = array(); + + /** + * Maximum possible serial number, "cache" for speeding up things + */ + private $maxSerialNumber = 0; + + /** + * Length of largest possible serial number + */ + const MAX_SERIAL_LENGTH = 8; + + /** + * Separator between chunk data, serial number and chunk hash + */ + const CHUNK_DATA_HASH_SEPARATOR = '@'; + + /** + * SEPARATOR for all chunk hashes + */ + const CHUNK_HASH_SEPARATOR = ';'; + + /** + * SEPARATOR between two chunks + */ + const CHUNK_SEPARATOR = '|'; + + /** + * Identifier for hash chunk + */ + const HASH_CHUNK_IDENTIFIER = 'HASH-CHUNK:'; + + /** + * Identifier for end-of-package marker + */ + const END_OF_PACKAGE_IDENTIFIER = 'EOP:'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init this fragmenter + $this->initFragmenter(); + } + + /** + * Creates an instance of this class + * + * @return $fragmenterInstance An instance of a Fragmentable class + */ + public static final function createPackageFragmenter () { + // Get new instance + $fragmenterInstance = new PackageFragmenter(); + + // Get a crypto instance and set it here + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + $fragmenterInstance->setCryptoInstance($cryptoInstance); + + // Return the prepared instance + return $fragmenterInstance; + } + + /** + * Initializes this fragmenter + * + * @return void + */ + private function initFragmenter () { + // Load some configuration entries and "cache" them: + // - Chunk size in bits + $this->chunkSize = $this->getConfigInstance()->getConfigEntry('package_chunk_size'); + + // - Maximum serial number + $this->maxSerialNumber = $this->hex2dec(str_repeat('f', self::MAX_SERIAL_LENGTH)); + } + + /** + * Initializes the pointer for given final hash + * + * @param $finalHash Final hash to initialize pointer for + * @return void + */ + private function initPointer ($finalHash) { + $this->chunkPointers[$finalHash] = 0; + } + + /** + * "Getter" for processedPackages array index + * + * @param $packageData Raw package data array + * @return $index Array index for processedPackages + */ + private function getProcessedPackagesIndex (array $packageData) { + return ( + $packageData[NetworkPackage::PACKAGE_DATA_SENDER] . NetworkPackage::PACKAGE_DATA_SEPARATOR . + $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . NetworkPackage::PACKAGE_DATA_SEPARATOR . + $packageData[NetworkPackage::PACKAGE_DATA_CONTENT] . NetworkPackage::PACKAGE_DATA_SEPARATOR + ); + } + + /** + * Checks whether the given package data is already processed by this fragmenter + * + * @param $packageData Raw package data array + * @return $isProcessed Whether the package has been fragmented + */ + private function isPackageProcessed (array $packageData) { + // Get array index + $index = $this->getProcessedPackagesIndex($packageData); + + // Is the array index there? + $isProcessed = ( + (isset($this->processedPackages[$index])) + && + ($this->processedPackages[$index] === TRUE) + ); + + // Return it + return $isProcessed; + } + + /** + * Marks the given package data as processed by this fragmenter + * + * @param $packageData Raw package data array + * @return void + */ + private function markPackageDataProcessed (array $packageData) { + // Remember it (until we may remove it) + $this->processedPackages[$this->getProcessedPackagesIndex($packageData)] = TRUE; + } + + /** + * Getter for final hash from given package data + * + * @param $packageData Raw package data array + * @return $finalHash Final hash for package data + */ + private function getFinalHashFromPackageData (array $packageData) { + // Make sure it is there + assert(isset($this->processedPackages[$this->getProcessedPackagesIndex($packageData)])); + + // Return it + return $this->processedPackages[$this->getProcessedPackagesIndex($packageData)]; + } + + /** + * Get next chunk pointer for given final hash + * + * @param $finalHash Final hash to get current pointer for + */ + private function getCurrentChunkPointer ($finalHash) { + // Is the final hash valid? + assert(strlen($finalHash) > 0); + + // Is the pointer already initialized? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + assert(isset($this->chunkPointers[$finalHash])); + + // Return it + return $this->chunkPointers[$finalHash]; + } + + /** + * Advance the chunk pointer for given final hash + * + * @param $finalHash Final hash to advance the pointer for + */ + private function nextChunkPointer ($finalHash) { + // Is the pointer already initialized? + assert(isset($this->chunkPointers[$finalHash])); + + // Count one up + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + $this->chunkPointers[$finalHash]++; + } + + /** + * "Getter" for data chunk size of given hash. + * + * @param $hash Hash to substract it's length + * @return $dataChunkSize The chunk size + */ + private function getDataChunkSizeFromHash ($hash) { + // Calculate real (data) chunk size + $dataChunkSize = ( + // Real chunk size + ($this->chunkSize / 8) - + // Hash size + strlen($hash) - + // Length of sperators + (strlen(self::CHUNK_DATA_HASH_SEPARATOR) * 2) - + // Length of max serial number + self::MAX_SERIAL_LENGTH + ); + + // This should be larger than zero bytes + assert($dataChunkSize > 0); + + // Return it + return $dataChunkSize; + } + + /** + * Generates a hash from raw data + * + * @param $rawData Raw data bytes to hash + * @return $hash Hash from the raw data + * @todo Implement a way to send non-announcement packages with extra-salt + */ + private function generateHashFromRawData ($rawData) { + /* + * Get the crypto instance and hash the data with no extra salt because + * the other peer doesn't have *this* peer's salt. + */ + $hash = $this->getCryptoInstance()->hashString($rawData, '', FALSE); + + // Return it + return $hash; + } + + /** + * Appends an end-of-package chunk to the chunk list for given chunk and + * final hash. As of 23-March-2012 the format of this chunk will be as any + * regular one to keep things easy (KISS) in ChunkHandler class. + * + * @param $lastChunk Last chunk raw data + * @param $finalHash Final hash for raw (unencoded) data + * @return void + */ + private function appendEndOfPackageChunk ($lastChunk, $finalHash) { + // Generate end-of-package marker + $chunkData = + self::END_OF_PACKAGE_IDENTIFIER . + $finalHash . self::CHUNK_HASH_SEPARATOR . + $this->generateHashFromRawData($lastChunk); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...'); + + // Add it as regular chunk + $this->addChunkData($finalHash, $chunkData); + } + + /** + * Splits the given encoded data into smaller chunks, the size of the final + * and the SEPARATOR is being subtracted from chunk size to fit it into a + * TCP package (512 bytes). + * + * @param $rawData Raw data string + * @param $finalHash Final hash from the raw data + * @return void + */ + private function splitEncodedDataIntoChunks ($rawData, $finalHash) { + // Make sure final hashes with at least 32 bytes can pass + assert(strlen($finalHash) >= 32); + + // Calculate real (data) chunk size + $dataChunkSize = $this->getDataChunkSizeFromHash($finalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: dataChunkSize=' . $dataChunkSize); + + // Init variables + $chunkHash = ''; + $chunkData = ''; + + // Now split it up + for ($idx = 0; $idx < strlen($rawData); $idx += $dataChunkSize) { + // Get the next chunk + $chunkData = substr($rawData, $idx, $dataChunkSize); + + // Add the chunk to the propper array and do all the stuff there + $this->addChunkData($finalHash, $chunkData); + } // END - for + + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).'); + + // Add end-of-package chunk + $this->appendEndOfPackageChunk($chunkData, $finalHash); + } + + /** + * Adds the given chunk (raw data) to the proper array and hashes it for + * later verfication. + * + * @param $finalHash Final hash for faster processing + * @param $chunkData Raw chunk data + * @param $prepend Whether append (default) or prepend the chunk + * @return void + */ + private function addChunkData ($finalHash, $chunkData, $prepend = FALSE) { + // Hash it + $rawDataHash = $this->getCryptoInstance()->hashString($chunkData, '', FALSE); + + // Prepend the hash to the chunk + $rawData = ( + $rawDataHash . self::CHUNK_DATA_HASH_SEPARATOR . + $this->getNextHexSerialNumber($finalHash) . self::CHUNK_DATA_HASH_SEPARATOR . + $chunkData . self::CHUNK_SEPARATOR + ); + + // Make sure the chunk is not larger than a TCP package can hold + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...'); + // @TODO This assert broke packages where the hash chunk was very large: assert(strlen($rawData) <= NetworkPackage::TCP_PACKAGE_SIZE); + + // Add it to the array + if ($prepend === TRUE) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); + array_unshift($this->chunkHashes[$finalHash], $rawDataHash); + array_unshift($this->chunks[$finalHash] , $rawData); + } else { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); + + // Is the array there? + if (!isset($this->chunks[$finalHash])) { + // Then initialize it + $this->chunks[$finalHash] = array(); + $this->chunkHashes[$finalHash] = array(); + } // END - if + + // Add both + array_push($this->chunks[$finalHash] , $rawData); + array_push($this->chunkHashes[$finalHash], $rawDataHash); + } + } + + /** + * Prepends a chunk (or more) with all hashes from all chunks + final chunk. + * + * @param $finalHash Final hash from the raw data + * @return void + */ + private function prependHashChunk ($finalHash) { + // "Implode" the whole array of hashes into one string + $rawData = self::HASH_CHUNK_IDENTIFIER . implode(self::CHUNK_HASH_SEPARATOR, $this->chunkHashes[$finalHash]); + + // Prepend chunk + $this->addChunkData($finalHash, $rawData, TRUE); + } + + /** + * "Getter" for the next hexadecimal-encoded serial number + * + * @param $finalHash Final hash + * @return $encodedSerialNumber The next hexadecimal-encoded serial number + */ + public function getNextHexSerialNumber ($finalHash) { + // Assert on maximum serial number length + assert(isset($this->serialNumber[$finalHash])); + assert($this->serialNumber[$finalHash] <= $this->maxSerialNumber); + + // Encode the current serial number + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]); + $encodedSerialNumber = $this->dec2Hex($this->serialNumber[$finalHash], self::MAX_SERIAL_LENGTH); + + // Count one up + $this->serialNumber[$finalHash]++; + + // Return the encoded serial number + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: encodedSerialNumber=' . $encodedSerialNumber); + return $encodedSerialNumber; + } + + /** + * This method does "implode" the given package data array into one long + * string, splits it into small chunks, adds a serial number and checksum + * to all chunks and prepends a chunk with all hashes only in it. It will + * return the final hash for faster processing of packages. + * + * @param $packageData Raw package data array + * @param $helperInstance An instance of a ConnectionHelper class + * @return $finalHash Final hash for faster processing + * @todo $helperInstance is unused + */ + public function fragmentPackageArray (array $packageData, ConnectionHelper $helperInstance) { + // Is this package already fragmented? + if (!$this->isPackageProcessed($packageData)) { + // First we need to "implode" the array + $rawData = implode(NetworkPackage::PACKAGE_DATA_SEPARATOR, $packageData); + + // Generate the final hash from the raw data (not encoded!) + $finalHash = $this->generateHashFromRawData($rawData); + + // Remember it + $this->processedPackages[$this->getProcessedPackagesIndex($packageData)] = $finalHash; + + // Init pointer and reset serial number + $this->initPointer($finalHash); + $this->resetSerialNumber($finalHash); + + // Split the encoded data into smaller chunks + $this->splitEncodedDataIntoChunks($rawData, $finalHash); + + // Prepend a chunk with all hashes together + $this->prependHashChunk($finalHash); + + // Mark the package as fragmented + $this->markPackageDataProcessed($packageData); + } else { + // Get the final hash from the package data + $finalHash = $this->getFinalHashFromPackageData($packageData); + } + + // Return final hash + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + return $finalHash; + } + + /** + * This method gets the next chunk from the internal FIFO which should be + * sent to the given recipient. It will return an associative array where + * the key is the chunk hash and value the raw chunk data. + * + * @param $finalHash Final hash for faster lookup + * @return $rawDataChunk Raw package data chunk + * @throws AssertionException If $finalHash was not 'TRUE' + */ + public function getNextRawDataChunk ($finalHash) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + + try { + // Get current chunk index + $current = $this->getCurrentChunkPointer($finalHash); + } catch (AssertionException $e) { + // This may happen when the final hash is TRUE + if ($finalHash === TRUE) { + // Set current to null + $current = NULL; + } else { + // Throw the exception + throw $e; + } + } + + // If there is no entry left, return an empty array + if ((!isset($this->chunkHashes[$finalHash][$current])) || (!isset($this->chunks[$finalHash][$current]))) { + // No more entries found + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ' - No more entries found!'); + return array(); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ',chunkHashes()=' . count($this->chunkHashes[$finalHash]) .' - Entry choosen ...'); + + // Generate the array + $rawDataChunk = array( + $this->chunkHashes[$finalHash][$current] => $this->chunks[$finalHash][$current] + ); + + // Count one index up + $this->nextChunkPointer($finalHash); + + // Return the chunk array + return $rawDataChunk; + } + + /** + * Resets the serial number to zero for given final hash + * + * @param $finalHash Final hash to reset counter for + * @return void + */ + public function resetSerialNumber ($finalHash) { + // Final hash must be set + assert((is_string($finalHash)) && (!empty($finalHash))); + + // Reset/set serial number + $this->serialNumber[$finalHash] = 0; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/pools/.htaccess b/application/hub/classes/pools/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/pools/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/pools/class_ b/application/hub/classes/pools/class_ new file mode 100644 index 000000000..3a37f6987 --- /dev/null +++ b/application/hub/classes/pools/class_ @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Pool extends BasePool implements Poolable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listenerInstance A Listenable instance + * @return $poolInstance An instance a Poolable class + */ + public final static function create???Pool (Listenable $listenerInstance) { + // Get new instance + $poolInstance = new ???Pool(); + + // Set the application instance + $poolInstance->setListenerInstance($listenerInstance); + + // Return the prepared instance + return $poolInstance; + } + + /** + * Adds a listener instance to this pool + * + * @param $poolInstance An instance of a Listenable class + * @return void + * @todo 0% done + */ + public function addListener (Listenable $poolInstance) { + $this->partialStub('Need to implement this method. listenerInstance=' . $poolInstance->__toString()); + } +} + +// +?> diff --git a/application/hub/classes/pools/class_BasePool.php b/application/hub/classes/pools/class_BasePool.php new file mode 100644 index 000000000..b03caebb8 --- /dev/null +++ b/application/hub/classes/pools/class_BasePool.php @@ -0,0 +1,190 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePool extends BaseHubSystem implements Visitable { + /** + * Socket array elements + */ + const SOCKET_ARRAY_RESOURCE = 'resource'; + const SOCKET_ARRAY_CONN_TYPE = 'connection_type'; + + /** + * A list of pool entries + */ + private $poolEntriesInstance = NULL; + + /** + * An array with all valid connection types + */ + private $connectionTypes = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init the pool entries + $this->poolEntriesInstance = ObjectFactory::createObjectByConfiguredName('pool_entries_list_class'); + + // Init array of connection types + $this->connectionTypes = array( + BaseConnectionHelper::CONNECTION_TYPE_INCOMING, + BaseConnectionHelper::CONNECTION_TYPE_OUTGOING, + BaseConnectionHelper::CONNECTION_TYPE_SERVER + ); + } + + /** + * Getter for pool entries instance + * + * @return $poolEntriesInstance An instance for pool entries (list) + */ + public final function getPoolEntriesInstance () { + return $this->poolEntriesInstance; + } + + /** + * Adds an instance to a pool segment + * + * @param $group Name of the pool group + * @param $poolSegment Name of the pool segment + * @param $visitableInstance An instance of a class that should bed added to the pool + * @return void + */ + protected final function addInstance ($group, $poolName, Visitable $visitableInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); + + // Make sure the group is not 'invalid' + assert($group != 'invalid'); + + // Is the pool group there? + if (!$this->getPoolEntriesInstance()->isGroupSet($group)) { + // Create the missing pool group + $this->getPoolEntriesInstance()->addGroup($group); + } // END - if + + // Add it to given pool group + $this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Adds an entry to the pool + * + * @param $poolEntry The new pool entry that should be added + * @return void + */ + protected final function addPoolEntry ($poolEntry) { + $this->getPoolEntriesInstance()->addEntry('pool', $poolEntry); + } + + /** + * Accepts the visitor to process the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); + + // Visit this pool + $visitorInstance->visitPool($this); + + // Do we have a registry instance for this visitor's iterator? + if (Registry::getRegistry()->instanceExists($visitorInstance->getVisitorMode() . '_pool_iterator')) { + // Get the instance from registry + $iteratorInstance = Registry::getRegistry()->getInstance($visitorInstance->getVisitorMode() . '_pool_iterator'); + } else { + // Get a new iterator instance + $iteratorInstance = ObjectFactory::createObjectByConfiguredName($visitorInstance->getVisitorMode() . '_pool_iterator_class', array($this->getPoolEntriesInstance())); + + // Add it to the registry + Registry::getRegistry()->addInstance($visitorInstance->getVisitorMode() . '_pool_iterator', $iteratorInstance); + } + + // Reset the counter + $iteratorInstance->rewind(); + + // Visit all registered entries + while ($iteratorInstance->valid()) { + // Get current entry + $poolEntry = $iteratorInstance->current(); + + // Is this entry visitable? + if ($poolEntry instanceof Visitable) { + // Visit this entry as well + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...'); + $poolEntry->accept($visitorInstance); + } else { + // Cannot visit this entry + $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . ', reason: not implementing Visitable.'); + } + + // Advance to next entry + $iteratorInstance->next(); + } // END - while + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); + } + + /** + * Gets the array from specified list + * + * @param $list The list identifier we should return + * @return $array The requested array + */ + protected final function getArrayFromList ($list) { + // Get the array + $array = $this->getPoolEntriesInstance()->getArrayFromList($list); + + // Return it + return $array; + } + + /** + * Checks whether the given connection type is valid + * + * @param $connectionType Type of connection, can be 'incoming', 'outgoing' or 'server' + * @return $isValid Whether the provided connection type is valid + */ + protected function isValidConnectionType ($connectionType) { + // Is it valid? + $isValid = in_array($connectionType, $this->connectionTypes, TRUE); + + // Return result + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/pools/listener/.htaccess b/application/hub/classes/pools/listener/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/pools/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/pools/listener/class_DefaultListenerPool.php b/application/hub/classes/pools/listener/class_DefaultListenerPool.php new file mode 100644 index 000000000..5f9cf6e4c --- /dev/null +++ b/application/hub/classes/pools/listener/class_DefaultListenerPool.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DefaultListenerPool extends BasePool implements PoolableListener { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public static final function createDefaultListenerPool (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new DefaultListenerPool(); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * Adds a listener instance to this pool + * + * @param $listenerInstance An instance of a Listenable class + * @return void + */ + public function addListener (Listenable $listenerInstance) { + // Add this listener instance to the instance list + parent::addInstance($listenerInstance->getProtocolName(), 'listener', $listenerInstance); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput( + 'POOL[' . __METHOD__ . ':' . __LINE__ . ']: Listener ' . $listenerInstance->__toString() . + ' listening to ' . $listenerInstance->getListenAddress() . ':' . + $listenerInstance->getListenPort() . ' added to listener pool.' + ); + } + + /** + * Run the shutdown seqeuence by a Visitor Pattern + * + * @return void + */ + public function doShutdown () { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down listener pool - CALLED!'); + + // Get a new visitor + $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_listener_pool_visitor_class'); + + // Start visiting + $this->accept($visitorInstance); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down listener pool - EXIT!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/pools/peer/.htaccess b/application/hub/classes/pools/peer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/pools/peer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/pools/peer/class_DefaultPeerPool.php b/application/hub/classes/pools/peer/class_DefaultPeerPool.php new file mode 100644 index 000000000..90e76fde8 --- /dev/null +++ b/application/hub/classes/pools/peer/class_DefaultPeerPool.php @@ -0,0 +1,283 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DefaultPeerPool extends BasePool implements PoolablePeer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listenerInstance A Listenable instance + * @return $poolInstance An instance a Poolable class + */ + public static final function createDefaultPeerPool (Listenable $listenerInstance) { + // Get new instance + $poolInstance = new DefaultPeerPool(); + + // Set the application instance + $poolInstance->setListenerInstance($listenerInstance); + + // Return the prepared instance + return $poolInstance; + } + + /** + * Validates given socket + * + * @param $socketResource A valid socket resource + * @return void + * @throws InvalidSocketException If the given socket has an error + */ + private function validateSocket ($socketResource) { + // Is it a valid resource? + if (!is_resource($socketResource)) { + // Throw an exception + throw new InvalidSocketException(array($this, $socketResource), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + // Get error code + $errorCode = socket_last_error($socketResource); + + // Is it without any errors? + if ($errorCode > 0) { + // Handle the socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); + /* + // Get error message + $errorMessage = socket_strerror($errorCode); + + // Shutdown this socket + $this->getListenerInstance()->shutdownSocket($socketResource); + + // And throw again + throw new InvalidSocketException(array($this, $socketResource, $errorCode, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + } + + /** + * Adds a socket resource to the peer pool + * + * @param $socketResource A valid (must be!) socket resource + * @param $connectionType Type of connection, can only be 'incoming', 'outgoing' or 'server' + * @return void + * @throws InvalidSocketException If the given resource is invalid or errorous + * @throws InvalidConnectionTypeException If the provided connection type is not valid + */ + public function addPeer ($socketResource, $connectionType) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DEFAULT-PEER-POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',connectionType=' . $connectionType . ' - CALLED!'); + + // Validate the socket + $this->validateSocket($socketResource); + + // Is the connection type valid? + if (!$this->isValidConnectionType($connectionType)) { + // Is not a valid connection type! + throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); + } // END - if + + // Default is this peer's IP + $peerName = '0.0.0.0'; + + // The socket resource should not match server socket + if ($socketResource != $this->getListenerInstance()->getSocketResource()) { + // Try to determine the peer's IP number + if (!socket_getpeername($socketResource, $peerName)) { + // Handle the socket error with a faked recipientData array + $this->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); + /* + // Get last error + $lastError = socket_last_error($socketResource); + + // Doesn't work! + throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET); + */ + } // END - if + } else { + // Server sockets won't work with socket_getpeername() + self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Socket resource is server socket (' . $socketResource . '). This is not a bug.'); + } + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Adding peer ' . $peerName . ',socketResource=' . $socketResource . ',type=' . $connectionType); + + // Construct the array + $socketArray = array( + self::SOCKET_ARRAY_RESOURCE => $socketResource, + self::SOCKET_ARRAY_CONN_TYPE => $connectionType + ); + + // Add it finally to the pool + $this->addPoolEntry($socketArray); + } + + /** + * Getter for array of all socket resources + * + * @return $sockets An array with all sockets + */ + public final function getAllSockets () { + // Get the list + $sockets = $this->getArrayFromList('pool'); + + // Return it + return $sockets; + } + + /** + * Getter for array of all socket arrays + * + * @return $sockets An array with all socket arrays + */ + public final function getAllSingleSockets () { + // Get the array list + $socketArrays = $this->getArrayFromList('pool'); + + // Init socket array + $sockets = array(); + + // "Walk" through all socket arrays + foreach ($socketArrays as $socketArray) { + // Add the socket + array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]); + } // END - foreach + + // Return it + return $sockets; + } + + /** + * "Getter" for all sockets of specified type + * + * @param $connectionType Type of connection, can only be 'incoming', 'outgoing' or 'server' + * @return $sockets An array with sockets of given type + * @throws InvalidConnectionTypeException If the provided connection type is not valid + */ + public function getSocketsByConnectionType ($connectionType) { + // Is the connection type valid? + if (!$this->isValidConnectionType($connectionType)) { + // Is not a valid connection type! + throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); + } // END - if + + // Get the array list + $socketArrays = $this->getArrayFromList('pool'); + + // Init socket array + $sockets = array(); + + // "Walk" through all socket arrays + foreach ($socketArrays as $socketArray) { + // Does it match? + if ($socketArray[self::SOCKET_ARRAY_CONN_TYPE] === $connectionType) { + // Add the socket + array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]); + } // END - if + } // END - foreach + + // Return it + return $sockets; + } + + /** + * "Getter" for a valid socket resource from given packae data. + * + * @param $packageData Raw package data + * @param $connectionType Type of connection, can be 'incoming', 'outgoing', 'server' or default + * @return $socketResource Socket resource + * @throws InvalidConnectionTypeException If the provided connection type is not valid + */ + public function getSocketFromPackageData (array $packageData, $connectionType = NULL) { + // Default is no socket + $socketResource = FALSE; + + // Resolve recipient (UNL) into a handler instance + $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData); + + // Get UNL data + $unlData = $handlerInstance->getUniversalNodeLocatorDataArray(); + + // Make sure it is a valid Universal Node Locator array (3 elements) + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); + assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),unlData[' . UniversalNodeLocator::UNL_PART_ADDRESS . ']=' . $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] . ',unlData[' . UniversalNodeLocator::UNL_PART_PORT . ']=' . $unlData[UniversalNodeLocator::UNL_PART_PORT] . ' ...'); + + // Default is all sockets + $sockets = $this->getAllSockets(); + + // Is connection type set? + if ((is_string($connectionType)) && ($this->isValidConnectionType($connectionType))) { + // Then get a list of this type + $sockets = $this->getSocketsByConnectionType($connectionType); + } elseif (is_string($connectionType)) { + // Is not a valid connection type! + throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); + } + + // Get all sockets and check them, skip the server socket + foreach ($sockets as $socketArray) { + // Is this a server socket? + if ($socketArray[self::SOCKET_ARRAY_RESOURCE] === $this->getListenerInstance()->getSocketResource()) { + // Skip 'server' sockets (local socket) + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Skipping server socket ' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ' ...'); + continue; + } // END - if + + // Try to get the "peer"'s name + if (!socket_getpeername($socketArray[self::SOCKET_ARRAY_RESOURCE], $peerIp)) { + // Handle the socket error with given package data + $this->handleSocketError(__METHOD__, __LINE__, $socketArray[self::SOCKET_ARRAY_RESOURCE], explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); + } // END - if + + // Get + // If the "peer" IP and recipient is same, use it + if ($peerIp == $unlData[UniversalNodeLocator::UNL_PART_ADDRESS]) { + // IPs match, so take the socket and quit this loop + $socketResource = $socketArray[self::SOCKET_ARRAY_RESOURCE]; + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: peerIp=' . $peerIp . ' matches with recipient IP address. Taking socket=' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[self::SOCKET_ARRAY_CONN_TYPE]); + break; + } // END - if + } // END - foreach + + // Return the determined socket resource + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource); + return $socketResource; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/.htaccess b/application/hub/classes/producer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/producer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/producer/class_ b/application/hub/classes/producer/class_ new file mode 100644 index 000000000..52778e9e5 --- /dev/null +++ b/application/hub/classes/producer/class_ @@ -0,0 +1,59 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Producer extends BaseProducer implements Producer, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $producerInstance An instance of a Producer class + */ + public final static function create???Producer () { + // Get new instance + $producerInstance = new ???Producer(); + + // Return the prepared instance + return $producerInstance; + } + + /** + * Initializes the producer + * + * @return void + */ + protected function initProducer () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/class_BaseProducer.php b/application/hub/classes/producer/class_BaseProducer.php new file mode 100644 index 000000000..8ac4cdfa1 --- /dev/null +++ b/application/hub/classes/producer/class_BaseProducer.php @@ -0,0 +1,196 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseProducer extends BaseFrameworkSystem { + /** + * Outgoing work-queue + */ + private $outgoingQueueInstance = NULL; + + /** + * Incoming raw data/items queue + */ + private $incomingQueueInstance = NULL; + + /** + * Stacker name for incoming work + */ + const STACKER_NAME_IN_QUEUE = 'incoming_queue'; + + /** + * Stacker name for outgoing work + */ + const STACKER_NAME_OUT_QUEUE = 'outgoing_queue'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Initialize all producers + $this->initProducer(); + + // Get miner instance + $minerInstance = Registry::getRegistry()->getInstance('miner'); + + // Change state to next state + $minerInstance->blockProducerHasInitialized($this); + + // Initialize work queue (out-going, produced items) + $this->initWorkQueue(); + } + + /** + * Getter for outgoing work queue + * + * @param $outgoingQueueInstance The outgoing work queue instance + */ + protected final function getOutgoingQueueInstance () { + return $this->outgoingQueueInstance; + } + + /** + * Setter for outgoing work queue + * + * @param $outgoingQueueInstance The outgoing work queue instance + * @return void + */ + private final function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) { + $this->outgoingQueueInstance = $outgoingQueueInstance; + } + + /** + * Getter for incoming raw data/items queue + * + * @param $incomingQueueInstance The incoming raw data/items queue instance + */ + protected final function getIncomingQueueInstance () { + return $this->incomingQueueInstance; + } + + /** + * Setter for incoming raw data/items queue + * + * @param $incomingQueueInstance The incoming raw data/items queue instance + * @return void + */ + private final function setIncomingQueueInstance (Stackable $incomingQueueInstance) { + $this->incomingQueueInstance = $incomingQueueInstance; + } + + /** + * Initializes this producer, this method must be overwritten. + * + * @return void + */ + abstract protected function initProducer(); + + /** + * Initializes the work queue which is being used for outgoing, produced + * items. + * + * @return void + */ + protected function initWorkQueue () { + // Get an instance and set it in this producer + $this->setOutgoingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_outgoing_queue')); + + // Init the queue + $this->initOutgoingQueue(); + + // Get an instance and set it in this producer + $this->setIncomingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_incoming_queue')); + + // Init the queue + $this->initIncomingQueue(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: All queues have been initialized.'); + } + + /** + * Inits the out-going queue stack + * + * @return void + */ + protected function initOutgoingQueue () { + $this->getOutgoingQueueInstance()->initStack(self::STACKER_NAME_OUT_QUEUE, TRUE); + } + + /** + * Adds an entry to the out-going work queue + * + * @param $value The value to be added to the out-going work queue + * @return void + */ + protected function addValueToOutgoingQueue ($value) { + $this->getOutgoingQueueInstance()->pushNamed(self::STACKER_NAME_OUT_QUEUE, $value); + } + + /** + * Checks whether a configurable out-going queue limit has been reached + * + * @param $configEntry Configuration entry where the limit is stored + * @return $isReached Whether the limit is reached + */ + protected function isOutgoingQueueLimitReached ($configEntry) { + return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getOutgoingQueueInstance()->getStackCount(self::STACKER_NAME_OUT_QUEUE)); + } + + /** + * Inits the incoming queue stack + * + * @return void + */ + protected function initIncomingQueue () { + $this->getIncomingQueueInstance()->initStack(self::STACKER_NAME_IN_QUEUE, TRUE); + } + + /** + * Adds an entry to the incoming work queue + * + * @param $value The value to be added to the incoming work queue + * @return void + */ + protected function addValueToIncomingQueue ($value) { + $this->getIncomingQueueInstance()->pushNamed(self::STACKER_NAME_IN_QUEUE, $value); + } + + /** + * Checks whether a configurable incoming queue limit has been reached + * + * @param $configEntry Configuration entry where the limit is stored + * @return $isReached Whether the limit is reached + */ + protected function isIncomingQueueLimitReached($configEntry) { + return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getIncomingQueueInstance()->getStackCount(self::STACKER_NAME_IN_QUEUE)); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/cruncher/.htaccess b/application/hub/classes/producer/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/producer/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/producer/cruncher/class_BaseKeyProducer.php b/application/hub/classes/producer/cruncher/class_BaseKeyProducer.php new file mode 100644 index 000000000..857193062 --- /dev/null +++ b/application/hub/classes/producer/cruncher/class_BaseKeyProducer.php @@ -0,0 +1,40 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseKeyProducer extends BaseProducer { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init key producer + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/cruncher/class_BaseUnitProducer.php b/application/hub/classes/producer/cruncher/class_BaseUnitProducer.php new file mode 100644 index 000000000..c8fac2e5a --- /dev/null +++ b/application/hub/classes/producer/cruncher/class_BaseUnitProducer.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseUnitProducer extends BaseProducer { + /** + * Work/test unit status + */ + const UNIT_STATUS_AVAILABLE = 'available'; // Available for crunching + const UNIT_STATUS_PENDING = 'pending'; // Is being crunched at the moment + const UNIT_STATUS_DONE = 'done'; // Is already crunched/finished + + /** + * Work or test unit? + */ + const UNIT_TYPE_TEST_UNIT = 'test_unit'; + const UNIT_TYPE_TEST_WORK = 'work_unit'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/cruncher/keys/.htaccess b/application/hub/classes/producer/cruncher/keys/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/producer/cruncher/keys/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/producer/cruncher/keys/class_CruncherKeyProducer.php b/application/hub/classes/producer/cruncher/keys/class_CruncherKeyProducer.php new file mode 100644 index 000000000..4850d5e5d --- /dev/null +++ b/application/hub/classes/producer/cruncher/keys/class_CruncherKeyProducer.php @@ -0,0 +1,129 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $producerInstance An instance of a Producer class + */ + public final static function createCruncherKeyProducer () { + // Get new instance + $producerInstance = new CruncherKeyProducer(); + + // Get a helper instance, we now only need this for the key iterator + $helperInstance = ObjectFactory::createObjectByConfiguredName('crypto_random_message_helper_class', array('test')); + + // Next get an iterator, again the helper will do that for us + $iteratorInstance = $helperInstance->getKeyIterator(); + + // Set it in the producer + $producerInstance->setIteratorInstance($iteratorInstance); + + // Return the prepared instance + return $producerInstance; + } + + /** + * Initializes the producer. This method satisfies the abstract BaseProducer + * class. + * + * @return void + * @todo Find something for init phase of this key producer + */ + protected function initProducer () { + } + + /** + * Initializes the executor, whatever it does. + * + * @return void + * @todo 0% done + */ + public function initExecutor (Stateable $stateInstance) { + $this->partialStub('Maybe implement this method?'); + } + + /** + * Produces some keys and pushes them onto the queue + * + * @param $stateInstance An instance of a Stateable instance + * @return void + * @todo ~30% done + */ + public function produceKeys (Stateable $stateInstance) { + // Is this cruncher virgin? + if (!$stateInstance->isCruncherStateVirgin()) { + // This cruncher is not virgin, so skip it + self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: The cruncher is not virgin. stateInstance=' . $stateInstance->__toString() . ''); + return; + } elseif (!$this->getIteratorInstance()->valid()) { + // This producer's iterator has finished its assignment + self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: Finished creating keys. iteratorInstance=' . $this->getIteratorInstance()->__toString() . ''); + return; + } + + /* + * Now we need to create an iterator, just as for the work units, + * to create new keys from the encrypted message. The iterator will + * not iterate over an object nor a collection. It will instead + * encapsulate the "key production" into a class and not in a simple + * for() loop. These keys then needs to be bundled into test units + * and stored to database for later re-usage. + */ + + /* + * Get current key (which is not the key of the iterator) This is always + * an ASCII string. + */ + $currentKey = $this->getIteratorInstance()->current(); + + // Add it to the out-going work queue + $this->addValueToOutgoingQueue($currentKey); + + // Is the per-work unit limit reached? + if ($this->isOutgoingQueueLimitReached('cruncher_per_unit_key_limit')) { + // @TODO Send the produced key bundle to the unit producer's input queue + self::createDebugInstance(__CLASS__)->debugOutput('currentKey(b64)="' . base64_encode($currentKey) . '" needs to be processed.'); + + // At last re-init the stack + $this->initOutgoingQueue(); + } // END - if + + // Continue with next one + $this->getIteratorInstance()->next(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/cruncher/work_units/.htaccess b/application/hub/classes/producer/cruncher/work_units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/producer/cruncher/work_units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/classes/producer/cruncher/work_units/class_CruncherTestUnitProducer.php new file mode 100644 index 000000000..4014b5f79 --- /dev/null +++ b/application/hub/classes/producer/cruncher/work_units/class_CruncherTestUnitProducer.php @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $producerInstance An instance of a Producer class + */ + public final static function createCruncherTestUnitProducer () { + // Get new instance + $producerInstance = new CruncherTestUnitProducer(); + + // Test units have a helper class that wraps the source + $helperInstance = ObjectFactory::createObjectByConfiguredName('crypto_random_message_helper_class', array('test')); + + // So set it in the producer + $producerInstance->setHelperInstance($helperInstance); + + // Return the prepared instance + return $producerInstance; + } + + /** + * Initializes the producer. This method satisfies the abstract BaseProducer + * class. + * + * @return void + */ + protected function initProducer () { + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('cruncher_test_unit_producer_template_class'); + + // Load the template + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + + // And set it in this cruncher + $this->setTemplateInstance($templateInstance); + } + + /** + * Prepares the produces of some test units and pushes them onto the queue + * + * @param $stateInstance An instance of a Stateable instance + * @return void + * @todo ~60% done + */ + public function initUnitProduction (Stateable $stateInstance) { + // First get a database wrapper because we want to permanently store test units + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('cruncher_unit_db_wrapper_class'); + + // Do we have some entries? + if ($wrapperInstance->isTestUnitProduced()) { + // Entries found + // @TODO Unfinished work here + $this->debugInstance(); + + // The state must be changed because ... + $stateInstance->someFooStateChange(); + } else { + // Get an encrypted, random message from our source + $encryptedMessage = $this->getHelperInstance()->generateRandomMessage(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: An encrypted, random message has been generated. Generating keys ...'); + + // Set the encrypted message in the template instance + $this->getTemplateInstance()->assignVariable('encrypted_message', $encryptedMessage); + + // The state must be changed because we have a new message + $stateInstance->encryptedMessageGenerated(); + } + } + + /** + * Initializes the executor, whatever it does. + * + * @return void + * @todo Maybe unfinished + */ + public function initExecutor (Stateable $stateInstance) { + $this->partialStub('Maybe implement this method?'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/miner/.htaccess b/application/hub/classes/producer/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/producer/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/producer/miner/blocks/.htaccess b/application/hub/classes/producer/miner/blocks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/producer/miner/blocks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/producer/miner/blocks/class_MinerRealGenesisBlockProducer.php b/application/hub/classes/producer/miner/blocks/class_MinerRealGenesisBlockProducer.php new file mode 100644 index 000000000..0abd16c37 --- /dev/null +++ b/application/hub/classes/producer/miner/blocks/class_MinerRealGenesisBlockProducer.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerRealGenesisBlockProducer extends BaseBlockProducer implements BlockProducer, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $producerInstance An instance of a Producer class + */ + public final static function createMinerRealGenesisBlockProducer () { + // Get new instance + $producerInstance = new MinerRealGenesisBlockProducer(); + + // Get a (minable) hash block instance + $minableInstance = ObjectFactory::createObjectByConfiguredName('miner_real_hash_block_class'); + + // Set it here + $producerInstance->setMinableInstance($minableInstance); + + // Return the prepared instance + return $producerInstance; + } + + /** + * Initializes the producer. This method satisfies the abstract BaseProducer + * class. + * + * @return void + * @todo 0% done + */ + protected function initProducer () { + $this->partialStub('Please implement this method.'); + } + + /** + * Initializes the executor, whatever it does. + * + * @return void + * @todo 0% done + */ + public function initExecutor (Stateable $stateInstance) { + $this->partialStub('Please implement this method.'); + } + + /** + * Prepares the produces of some test units and pushes them onto the queue + * + * @param $stateInstance An instance of a Stateable instance + * @return void + * @todo ~5% done + */ + public function prepareBlockProduction (Stateable $stateInstance) { + // The state must be 'booting' + $stateInstance->validateMinerStateIsBooting(); + + /* + * Now that the miner is booting a genesis block for real mining can be + * created. + */ + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/miner/blocks/class_MinerTestGenesisBlockProducer.php b/application/hub/classes/producer/miner/blocks/class_MinerTestGenesisBlockProducer.php new file mode 100644 index 000000000..fbf80a39f --- /dev/null +++ b/application/hub/classes/producer/miner/blocks/class_MinerTestGenesisBlockProducer.php @@ -0,0 +1,95 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerTestGenesisBlockProducer extends BaseBlockProducer implements BlockProducer, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $producerInstance An instance of a Producer class + */ + public final static function createMinerTestGenesisBlockProducer () { + // Get new instance + $producerInstance = new MinerTestGenesisBlockProducer(); + + // Get a (minable) hash block instance + $minableInstance = ObjectFactory::createObjectByConfiguredName('miner_test_hash_block_class'); + + // Set it here + $producerInstance->setMinableInstance($minableInstance); + + // Return the prepared instance + return $producerInstance; + } + + /** + * Initializes the producer. This method satisfies the abstract BaseProducer + * class. + * + * @return void + * @todo 0% done + */ + protected function initProducer () { + $this->partialStub('Please implement this method.'); + } + + /** + * Initializes the executor, whatever it does. + * + * @return void + * @todo 0% done + */ + public function initExecutor (Stateable $stateInstance) { + $this->partialStub('Please implement this method.'); + } + + /** + * Prepares the produces of some test units and pushes them onto the queue + * + * @param $stateInstance An instance of a Stateable instance + * @return void + * @todo ~5% done + */ + public function prepareBlockProduction (Stateable $stateInstance) { + // The state must be 'booting' + $stateInstance->validateMinerStateIsBooting(); + + /* + * Now that the miner is booting a "genesis" block for testing purposes + * can be created. The real "genesis" block will be created differently + * to this. + */ + } +} + +// [EOF] +?> diff --git a/application/hub/classes/producer/miner/class_BaseBlockProducer.php b/application/hub/classes/producer/miner/class_BaseBlockProducer.php new file mode 100644 index 000000000..4ed231824 --- /dev/null +++ b/application/hub/classes/producer/miner/class_BaseBlockProducer.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseBlockProducer extends BaseProducer { + /** + * Block status + */ + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/queries/.htaccess b/application/hub/classes/queries/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/queries/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/queries/class_ b/application/hub/classes/queries/class_ new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/queries/class_ @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/queries/local/.htaccess b/application/hub/classes/queries/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/queries/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/queues/.htaccess b/application/hub/classes/queues/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/queues/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/queues/class_ b/application/hub/classes/queues/class_ new file mode 100644 index 000000000..f551ef47b --- /dev/null +++ b/application/hub/classes/queues/class_ @@ -0,0 +1,3 @@ + diff --git a/application/hub/classes/queues/peer/.htaccess b/application/hub/classes/queues/peer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/queues/peer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/recipient/.htaccess b/application/hub/classes/recipient/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/recipient/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/recipient/class_ b/application/hub/classes/recipient/class_ new file mode 100644 index 000000000..d85e73e9c --- /dev/null +++ b/application/hub/classes/recipient/class_ @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Recipient extends BaseRecipient implements Recipient { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $recipientInstance An instance of a Recipient class + */ + public final static function create???Recipient () { + // Get new instance + $recipientInstance = new ???Recipient(); + + // Return the prepared instance + return $recipientInstance; + } + + /** + * Tries to resolve given recipient into session ids or Universal Node Locator + * depending on implementation (hint: Template Method Pattern) + * + * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) + * @param $listInstance An instance of a Listable class + * @return $resolved Resolved recipient or VOID if only the set list has been filled + * @throws FrameworkException Could throw different exceptions back depending on implementation + * @todo 0% done + */ + public function resolveRecipient ($recipient, Listable $listInstance) { + // Make sure the recipient is valid + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('!!!-RECIPIENT: recipient=' . $recipient); + assert($recipient == '|||'); + $this->partialStub('Please implement this method. recipient=' . $recipient); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/recipient/class_BaseRecipient.php b/application/hub/classes/recipient/class_BaseRecipient.php new file mode 100644 index 000000000..bdcf99319 --- /dev/null +++ b/application/hub/classes/recipient/class_BaseRecipient.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseRecipient extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/recipient/dht/.htaccess b/application/hub/classes/recipient/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/recipient/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/recipient/dht/class_DhtRecipient.php b/application/hub/classes/recipient/dht/class_DhtRecipient.php new file mode 100644 index 000000000..e8f213966 --- /dev/null +++ b/application/hub/classes/recipient/dht/class_DhtRecipient.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtRecipient extends BaseRecipient implements Recipient { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $recipientInstance An instance of a Recipient class + */ + public final static function createDhtRecipient () { + // Get new instance + $recipientInstance = new DhtRecipient(); + + // Return the prepared instance + return $recipientInstance; + } + + /** + * Tries to resolve given recipient into session ids or Universal Node Locator + * depending on implementation (hint: Template Method Pattern). This + * implementation will add more than one recipient to the list as a DHT is + * distributed and the package might go to more than one recipient. + * + * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) + * @param $listInstance An instance of a Listable class + * @param $packageData Valid package data array + * @return void + * @throws FrameworkException Could throw different exceptions depending on implementation + */ + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient . ' - CALLED!'); + + // Make sure the recipient is valid + assert($recipient == NetworkPackage::NETWORK_TARGET_DHT); + + // Get recipient discovery instance + $discoverInstance = ObjectFactory::createObjectByConfiguredName('dht_recipient_discovery_class'); + + // "Discover" recipients by given package data + $recipients = $discoverInstance->resolveRecipientsByPackageData($packageData); + + // Now "walk" through all elements and add them to the list + foreach ($recipients as $recipient) { + // These array elements must exist for this loop: + // @TODO Unfinished + die(__METHOD__ . ':recipient=' . print_r($recipient, TRUE)); + assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])); + + // Put ip and port both together + $unl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]; + + // Add it to the list + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: Calling listInstance->addEntry(' . $unl . ') ...'); + $listInstance->addEntry('unl', $unl); + } // END - foreach + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient . ' - EXIT!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/recipient/direct/.htaccess b/application/hub/classes/recipient/direct/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/recipient/direct/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/recipient/direct/class_DirectRecipient.php b/application/hub/classes/recipient/direct/class_DirectRecipient.php new file mode 100644 index 000000000..2c26a97c1 --- /dev/null +++ b/application/hub/classes/recipient/direct/class_DirectRecipient.php @@ -0,0 +1,80 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DirectRecipient extends BaseRecipient implements Recipient { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $recipientInstance An instance of a Recipient class + */ + public final static function createDirectRecipient () { + // Get new instance + $recipientInstance = new DirectRecipient(); + + // Return the prepared instance + return $recipientInstance; + } + + /** + * Tries to resolve given recipient into session ids or Universal Node Locator + * depending on implementation (hint: Template Method Pattern) + * + * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) + * @param $listInstance An instance of a Listable class + * @param $packageData Valid package data array + * @return $resolved Resolved recipient or VOID if only the set list has been filled + * @throws FrameworkException Could throw different exceptions depending on implementation + */ + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient); + + // "Explode" all recipients + $recipients = explode(NetworkPackage::PACKAGE_RECIPIENT_SEPARATOR, $recipient); + + // Is maximum reached? + assert(count($recipients) <= $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')); + + // Try it on all + foreach ($recipients as $recipient) { + // Try to sole a single recipient + $unlData = HubTools::resolveSessionId($recipient); + + // Add it as recipient + $listInstance->addEntry('unl', $unlData); + } // END - foreach + } +} + +// [EOF] +?> diff --git a/application/hub/classes/recipient/self/.htaccess b/application/hub/classes/recipient/self/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/recipient/self/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/recipient/self/class_SelfRecipient.php b/application/hub/classes/recipient/self/class_SelfRecipient.php new file mode 100644 index 000000000..2f83c757b --- /dev/null +++ b/application/hub/classes/recipient/self/class_SelfRecipient.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SelfRecipient extends BaseRecipient implements Recipient { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $recipientInstance An instance of a Recipient class + */ + public final static function createSelfRecipient () { + // Get new instance + $recipientInstance = new SelfRecipient(); + + // Return the prepared instance + return $recipientInstance; + } + + /** + * Tries to resolve given recipient into session ids or Universal Node Locator + * depending on implementation (hint: Template Method Pattern) + * + * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) + * @param $listInstance An instance of a Listable class + * @param $packageData Valid package data array + * @return $resolved Resolved recipient or VOID if only the set list has been filled + * @throws FrameworkException Could throw different exceptions depending on implementation + */ + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { + // Make sure the recipient is valid + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SELF-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient); + // @TODO Add more checks on data + assert($recipient == NetworkPackage::NETWORK_TARGET_SELF); + + // Determine IP or 'external_address' if set + $unl = HubTools::determineOwnExternalAddress(); + + // Is it not empty? + if (!empty($unl)) { + // Add it to the list + $listInstance->addEntry('unl', $unl); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/recipient/upper/.htaccess b/application/hub/classes/recipient/upper/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/recipient/upper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/recipient/upper/class_UpperRecipient.php b/application/hub/classes/recipient/upper/class_UpperRecipient.php new file mode 100644 index 000000000..026c6eeae --- /dev/null +++ b/application/hub/classes/recipient/upper/class_UpperRecipient.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UpperRecipient extends BaseRecipient implements Recipient { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $recipientInstance An instance of a Recipient class + */ + public final static function createUpperRecipient () { + // Get new instance + $recipientInstance = new UpperRecipient(); + + // Return the prepared instance + return $recipientInstance; + } + + /** + * Tries to resolve given recipient into session ids or Universal Node Locator + * depending on implementation (hint: Template Method Pattern) + * + * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) + * @param $listInstance An instance of a Listable class + * @param $packageData Valid package data array + * @return $resolved Resolved recipient or VOID if only the set list has been filled + * @throws FrameworkException Could throw different exceptions depending on implementation + */ + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { + // Make sure the recipient is valid + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UPPER-RECIPIENT: recipient=' . $recipient); + assert($recipient == NetworkPackage::NETWORK_TARGET_UPPER); + + // Get all bootstrap nodes + foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlData) { + // Is maximum reached? + if ($listInstance->count() == $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')) { + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER[' . __METHOD__ . ':' . __LINE__ . ']: Going to abort at maximum of ' . $this->getConfigInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!'); + + // Then stop adding more + break; + } // END - if + + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER[' . __METHOD__ . ':' . __LINE__ . ']: Adding node ' . print_r($unlData, TRUE) . ' as recipient.'); + + // Add the entry + $listInstance->addEntry('unl', $unlData); + } // END - foreach + } +} + +// [EOF] +?> diff --git a/application/hub/classes/registry/.htaccess b/application/hub/classes/registry/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/registry/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/registry/objects/.htaccess b/application/hub/classes/registry/objects/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/registry/objects/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/registry/objects/class_ObjectTypeRegistry.php b/application/hub/classes/registry/objects/class_ObjectTypeRegistry.php new file mode 100644 index 000000000..8df6eb9dc --- /dev/null +++ b/application/hub/classes/registry/objects/class_ObjectTypeRegistry.php @@ -0,0 +1,58 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ObjectTypeRegistry extends BaseRegistry implements Register { + /** + * Instance of this class + */ + private static $registryInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton method, we really only need one instance of this class. + * + * @return $registryInstance Instance of this class + */ + public static final function createObjectTypeRegistry () { + // Is an instance there? + if (is_null(self::$registryInstance)) { + // Not yet, so create one + self::$registryInstance = new ObjectTypeRegistry(); + } // END - if + + // Return the instance + return self::$registryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/registry/socket/.htaccess b/application/hub/classes/registry/socket/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/registry/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/registry/socket/class_SocketRegistry.php b/application/hub/classes/registry/socket/class_SocketRegistry.php new file mode 100644 index 000000000..a420ecaa5 --- /dev/null +++ b/application/hub/classes/registry/socket/class_SocketRegistry.php @@ -0,0 +1,338 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketRegistry extends BaseRegistry implements Register, RegisterableSocket { + // Exception constants + const SOCKET_NOT_REGISTERED = 0xd200; + + /** + * Instance of this class + */ + private static $registryInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates a singleton instance of this registry class + * + * @return $registryInstance An instance of this class + */ + public static final function createSocketRegistry () { + // Is an instance there? + if (is_null(self::$registryInstance)) { + // Not yet, so create one + self::$registryInstance = new SocketRegistry(); + } // END - if + + // Return the instance + return self::$registryInstance; + } + + /** + * "Getter" to get a string respresentation for a key for the sub-registry + * in this format: class:type:port + * + * @param $infoInstance An instance of a ShareableInfo class + * @return $key A string representation of the socket for the registry + */ + private function getSubRegistryKey (ShareableInfo $infoInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); + + // Get address and port + $address = $infoInstance->getAddress(); + $port = $infoInstance->getPort(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: address=' . $address . ',port=' . $port); + + // Get connection type and port number and add both together + $key = sprintf('%s:%s:%s:%s', + $infoInstance->__toString(), + $infoInstance->getProtocolName(), + $address, + $port + ); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!'); + + // Return resulting key + return $key; + } + + /** + * "Getter" to get a string respresentation of the listener + * + * @param $infoInstance An instance of a ShareableInfo class + * @return $key A string representation of the listener for the registry + */ + private function getRegistryKeyFromInfo (ShareableInfo $infoInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); + + // Get the key + $key = $infoInstance->getProtocolName(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!'); + + // Return resulting key + return $key; + } + + /** + * Checks whether the shared connection info is registered + * + * @param $infoInstance An instance of a ShareableInfo class + * @return $isRegistered Whether the listener is registered + */ + private function isInfoRegistered (ShareableInfo $infoInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ' - CALLED!'); + + // Get the key + $key = $this->getRegistryKeyFromInfo($infoInstance); + + // Determine it + $isRegistered = $this->instanceExists($key); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); + + // Return result + return $isRegistered; + } + + /** + * Checks whether given socket resource is registered. If $socketResource is + * FALSE only the instance will be checked. + * + * @param $infoInstance An instance of a ShareableInfo class + * @param $socketResource A valid socket resource + * @return $isRegistered Whether the given socket resource is registered + */ + public function isSocketRegistered (ShareableInfo $infoInstance, $socketResource) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - CALLED!'); + + // Default is not registered + $isRegistered = FALSE; + + // First, check for the instance, there can be only once + if ($this->isInfoRegistered($infoInstance)) { + // That one is found so "get" a registry key from it + $key = $this->getRegistryKeyFromInfo($infoInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...'); + + // Get the registry + $registryInstance = $this->getInstance($key); + + // "Get" a key for the socket + $socketKey = $this->getSubRegistryKey($infoInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...'); + + // Is it there? + if ($registryInstance->instanceExists($socketKey)) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey)); + + // Get the instance + $registeredInstance = $registryInstance->getInstance($socketKey); + + // Is it SocketContainer and same socket? + $isRegistered = (($registeredInstance instanceof SocketContainer) && ($registeredInstance->ifSocketResourceMatches($socketResource))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Final result: isRegistered(' . $socketResource . ')=' . intval($isRegistered)); + } // END - if + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); + + // Return the result + return $isRegistered; + } + + /** + * Registeres given socket for listener or throws an exception if it is already registered + * + * @param $infoInstance An instance of a ShareableInfo class + * @param $socketResource A valid socket resource + * @param $packageData Optional raw package data + * @throws SocketAlreadyRegisteredException If the given socket is already registered + * @return void + */ + public function registerSocket (ShareableInfo $infoInstance, $socketResource, array $packageData = array()) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - CALLED!'); + + // Is the socket already registered? + if ($this->isSocketRegistered($infoInstance, $socketResource)) { + // Throw the exception + throw new SocketAlreadyRegisteredException(array($infoInstance, $socketResource), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED); + } // END - if + + // Does the instance exist? + if (!$this->isInfoRegistered($infoInstance)) { + // No, not found so we create a sub registry (not needed to configure!) + $registryInstance = SubRegistry::createSubRegistry(); + + // Now we can create the sub-registry for this info + $this->addInstance($this->getRegistryKeyFromInfo($infoInstance), $registryInstance); + } else { + // Get the sub-registry back + $registryInstance = $this->getInstance($this->getRegistryKeyFromInfo($infoInstance)); + } + + // Get a key for sub-registries + $socketKey = $this->getSubRegistryKey($infoInstance); + + // Get a socket container + $socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $infoInstance, $packageData)); + + // We have a sub-registry, the socket key and the socket, now we need to put all together + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...'); + $registryInstance->addInstance($socketKey, $socketInstance); + } + + /** + * Getter for given listener's socket resource + * + * @param $listenerInstance An instance of a Listenable class + * @return $socketResource A valid socket resource + * @throws NoSocketRegisteredException If the requested socket is not registered + */ + public function getRegisteredSocketResource (Listenable $listenerInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ' - CALLED!'); + + // The socket must be registered before we can return it + if (!$this->isInfoRegistered($listenerInstance)) { + // Throw the exception + throw new NoSocketRegisteredException ($listenerInstance, self::SOCKET_NOT_REGISTERED); + } // END - if + + // Now get the key from the listener + $key = $this->getRegistryKeyFromInfo($listenerInstance); + + // And get the registry + $registryInstance = $this->getInstance($key); + + // Get a socket key + $socketKey = $this->getSubRegistryKey($listenerInstance); + + // And the final socket resource + $socketResource = $registryInstance->getInstance($socketKey)->getSocketResource(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!'); + + // Return the resource + return $socketResource; + } + + /** + * "Getter" for info instance from given package data + * + * @param $packageData Raw package data + * @return $infoInstance An instance of a ShareableInfo class + */ + public function getInfoInstanceFromPackageData (array $packageData) { + // Init info instance + $infoInstance = NULL; + //* DEBUG-DIE: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE)); + + // Get all keys and check them + foreach ($this->getInstanceRegistry() as $key => $registryInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString()); + + // This is always a SubRegistry instance + foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString()); + + // Is this a SocketContainer instance and is the address the same? + if (($containerInstance instanceof SocketContainer) && ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]))) { + // Debug die + //* DEBUG-DIE: */ die(__METHOD__ . ': containerInstance=' . print_r($containerInstance, TRUE)); + + // Get listener and helper instances + $listenerInstance = $containerInstance->getListenerInstance(); + $helperInstance = $containerInstance->getHelperInstance(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance)); + + // Is a listener or helper set? + if ($listenerInstance instanceof Listenable) { + // Found a listener, so get the info instance first + $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($listenerInstance->getProtocolName(), 'helper'); + + // Fill info instance with listener data + $infoInstance->fillWithListenerInformation($listenerInstance); + } elseif ($helperInstance instanceof ConnectionHelper) { + // Found a helper, so get the info instance first + $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($helperInstance->getProtocolName(), 'helper'); + + // Helper is found + $infoInstance->fillWithConnectionHelperInformation($helperInstance); + } else { + // Not supported state! + $this->debugInstance('[' . __METHOD__ . ':' . __LINE__ . ']: Invalid state found, please report this to the developers with full debug infos.' . PHP_EOL); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',infoInstance[' . gettype($infoInstance) . ']=' . $infoInstance->__toString() . ' with protocol ' . $infoInstance->getProtocolName() . ' - FOUND!'); + break; + } // END - if + } // END - foreach + + // Is no longer NULL set? + if (!is_null($infoInstance)) { + // Then skip here, too + break; + } // END - if + } // END - foreach + + // Return the info instance + return $infoInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/.htaccess b/application/hub/classes/resolver/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/command/.htaccess b/application/hub/classes/resolver/command/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/command/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/command/console/.htaccess b/application/hub/classes/resolver/command/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/command/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/command/console/class_HubConsoleCommandResolver.php b/application/hub/classes/resolver/command/console/class_HubConsoleCommandResolver.php new file mode 100644 index 000000000..2343d40c4 --- /dev/null +++ b/application/hub/classes/resolver/command/console/class_HubConsoleCommandResolver.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "HubConsole" + $this->setClassPrefix('hub_console'); + } + + /** + * Creates an instance of a HubConsole command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public static final function createHubConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HubConsoleCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/command/html/.htaccess b/application/hub/classes/resolver/command/html/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/command/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/command/html/class_HubHtmlCommandResolver.php b/application/hub/classes/resolver/command/html/class_HubHtmlCommandResolver.php new file mode 100644 index 000000000..95841f395 --- /dev/null +++ b/application/hub/classes/resolver/command/html/class_HubHtmlCommandResolver.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubHtmlCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "HubHtml" + $this->setClassPrefix('hub_html'); + } + + /** + * Creates an instance of a HubHtml command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public static final function createHubHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HubHtmlCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/controller/.htaccess b/application/hub/classes/resolver/controller/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/controller/console/.htaccess b/application/hub/classes/resolver/controller/console/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php b/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php new file mode 100644 index 000000000..2a73ee255 --- /dev/null +++ b/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "HubConsole" + $this->setClassPrefix('hub_console'); + } + + /** + * Creates an instance of a resolver class with a given command + * + * @param $controllerName The controller we shall resolve + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public static final function createHubConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HubConsoleControllerResolver(); + + // Is the variable $controllerName set and the command is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { + // Invalid command found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Set command name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default + * command + * @throws InvalidControllerInstanceException Thrown if $controllerInstance + * is invalid + */ + public function resolveController () { + // Init variables + $controllerName = ''; + $controllerInstance = NULL; + + // Get the command name + $controllerName = $this->getControllerName(); + + // Get the command + $controllerInstance = $this->loadController($controllerName); + + // And validate it + if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { + // This command has an invalid instance! + throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set last controller + $this->setResolvedInstance($controllerInstance); + + // Return the maybe resolved instance + return $controllerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/controller/html/.htaccess b/application/hub/classes/resolver/controller/html/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/controller/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php b/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php new file mode 100644 index 000000000..1376a827e --- /dev/null +++ b/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubHtmlControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'Html' + $this->setClassPrefix('Html'); + } + + /** + * Creates an instance of a resolver class with a given command + * + * @param $controllerName The controller we shall resolve + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public static final function createHubHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HubHtmlControllerResolver(); + + // Is the variable $controllerName set and the command is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { + // Invalid command found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Set command name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default + * command + * @throws InvalidControllerInstanceException Thrown if $controllerInstance + * is invalid + */ + public function resolveController () { + // Init variables + $controllerName = ''; + $controllerInstance = NULL; + + // Get the command name + $controllerName = $this->getControllerName(); + + // Get the command + $controllerInstance = $this->loadController($controllerName); + + // And validate it + if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { + // This command has an invalid instance! + throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set last controller + $this->setResolvedInstance($controllerInstance); + + // Return the maybe resolved instance + return $controllerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/protocol/.htaccess b/application/hub/classes/resolver/protocol/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/protocol/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/protocol/class_ b/application/hub/classes/resolver/protocol/class_ new file mode 100644 index 000000000..ccc83ffcc --- /dev/null +++ b/application/hub/classes/resolver/protocol/class_ @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class !!!ProtocolResolver extends BaseProtocolResolver implements ProtocolResolver, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of a !!! protocol resolver + * + * @return $resolverInstance The prepared command resolver instance + */ + public static final function create!!!ProtocolResolver () { + // Create the new instance + $resolverInstance = new !!!ProtocolResolver(); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an instance of a LocateableNode class for a given NodeHelper + * instance or null if it was not found. + * + * @param $nodeInstance An instance of a NodeHelper class + * @return $unlInstance An instance of a LocateableNode class + * @todo 0% done + */ + public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) { + $this->partialStub('Please implement this method. nodeInstance=' . $nodeInstance->__toString()); + } + + /** + * Returns the UNL as string from given configuration key. + * + * @param $configKey Configuration key for UNL address (valid: internal,external) + * @return $unl Universal node locator + * @todo 90% done + */ + public function resolveUniversalNodeLocatorFromConfigKey ($configKey) { + // Put all together + $unl = sprintf('%s://%s', + $this->getProtocolName(), + $this->getConfigInstance()->getConfigEntry($configKey . '_address') + ); + + /* + * And return it. Please note that e.g. a FaxProtocolResolver will + * return a different UNL and therefore all protocol resolvers must do + * it on their own way. + */ + return $unl; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/protocol/class_BaseProtocolResolver.php b/application/hub/classes/resolver/protocol/class_BaseProtocolResolver.php new file mode 100644 index 000000000..966971b08 --- /dev/null +++ b/application/hub/classes/resolver/protocol/class_BaseProtocolResolver.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseProtocolResolver extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/protocol/tcp/.htaccess b/application/hub/classes/resolver/protocol/tcp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/protocol/tcp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php new file mode 100644 index 000000000..a7f79e98c --- /dev/null +++ b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php @@ -0,0 +1,129 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolver, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set protocol type + $this->setProtocolName('tcp'); + } + + /** + * Creates an instance of a TCP protocol resolver + * + * @return $resolverInstance The prepared command resolver instance + */ + public static final function createTcpProtocolResolver () { + // Create the new instance + $resolverInstance = new TcpProtocolResolver(); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an instance of a LocateableNode class for a given NodeHelper + * instance or null if it was not found. + * + * @param $nodeInstance An instance of a NodeHelper class + * @return $unlInstance An instance of a LocateableNode class + * @todo 0% done + */ + public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) { + // Get search instance (to lookup database result) + $searchInstance = $nodeInstance->getSearchInstance(); + + // Make sure the in stance is valid + assert($searchInstance instanceof SearchCriteria); + + // Refetch and rewind iterator + $resultInstance = $nodeInstance->getWrapperInstance()->doSelectByCriteria($searchInstance); + + // Is the result valid? + if ((!$resultInstance->valid()) || (!$resultInstance->next())) { + // Node not found in database, this could mean that your database file is damaged. + return NULL; + } // END - if + + // Get current entry + $current = $resultInstance->current(); + + // This should always be the case, if not your database file might be damaged. + assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]); + + // Get UNL instance and handle over all data + $unlInstance = ObjectFactory::createObjectByConfiguredName('universal_node_locator_class', array($current)); + + // Return resolved instance + return $unlInstance; + } + + /** + * Returns the UNL as string from given configuration key. + * + * @param $configKey Configuration key for UNL address (valid: internal,external) + * @return $unl Universal node locator + */ + public function resolveUniversalNodeLocatorFromConfigKey ($configKey) { + // Get address + $address = $this->getConfigInstance()->getConfigEntry($configKey . '_address'); + + // Is the address empty? + if (empty($address)) { + // Okay, then find it + switch ($configKey) { + case 'external': // External IP + $address = ConsoleTools::determineExternalAddress(); + break; + + case 'internal': // Internal IP + $address = ConsoleTools::acquireSelfIPAddress(); + break; + } // END - switch + } // END - if + + // Put all together + $unl = sprintf('%s://%s:%s', + $this->getProtocolName(), + $address, + $this->getConfigInstance()->getConfigEntry('node_listen_port') + ); + + /* + * And return it. Please note that e.g. a FaxProtocolResolver will + * return a different UNL and therefore all protocol resolvers must do + * it on their own way. + */ + return $unl; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/state/.htaccess b/application/hub/classes/resolver/state/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/state/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/state/class_BaseStateResolver.php b/application/hub/classes/resolver/state/class_BaseStateResolver.php new file mode 100644 index 000000000..8744b7156 --- /dev/null +++ b/application/hub/classes/resolver/state/class_BaseStateResolver.php @@ -0,0 +1,165 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseStateResolver extends BaseResolver { + /** + * Prefix for local, remote or other resolver + */ + private $statePrefix = ''; + + /** + * Validated state name + */ + private $stateName = ''; + + /** + * Protected constructor + * + * @param $className Name of the real class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for state prefix + * + * @param $statePrefix Last validated statePrefix + * @return void + */ + protected final function setStatePrefix ($statePrefix) { + $this->statePrefix = $statePrefix; + } + + /** + * Getter for state prefix + * + * @param $statePrefix Last validated statePrefix + * @return void + */ + protected final function getStatePrefix () { + return $this->statePrefix; + } + + /** + * Setter for state name + * + * @param $stateName Last validated state name + * @return void + */ + protected final function setStateName ($stateName) { + $this->stateName = $stateName; + } + + /** + * Getter for state name + * + * @return $stateName Last validated state name + */ + public final function getStateName () { + return $this->stateName; + } + + /** + * "Loads" a given state and instances it if not yet cached. If the + * state was not found an UnresolveableStateException is thrown + * + * @param $stateName A state name we shall look for + * @return $stateInstance A loaded state instance + * @throws UnresolveableStateException Thrown if even the requested + * state class is missing (bad!) + */ + protected function loadState ($stateName) { + // Init state instance + $stateInstance = NULL; + + // Create state class name + $className = $this->getStatePrefix() . '' . self::convertToClassName($stateName) . 'State'; + + // ... and set it + $this->setClassName($className); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Throw an exception here + throw new UnresolveableStateException(array($this, $stateName), self::EXCEPTION_INVALID_STATE); + } // END - if + + // Initialize the state + $stateInstance = ObjectFactory::createObjectByName( + $this->getClassName(), + array($this) + ); + + // Return the result + return $stateInstance; + } + + /** + * Checks whether the given state is valid + * + * @param $stateName The default state we shall execute + * @return $isValid Whether the given state is valid + * @throws EmptyVariableException Thrown if given state is not set + * @throws DefaultStateException Thrown if default state was not found + */ + public function isStateValid ($stateName) { + // By default nothing shall be valid + $isValid = FALSE; + + // Is a state set? + if (empty($stateName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($this, 'stateName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Create class name + $className = $this->statePrefix . self::convertToClassName($stateName) . 'State'; + + // Now, let us create the full name of the state class + $this->setClassName($className); + + // Try it hard to get an state + while ($isValid === FALSE) { + // Is this class already loaded? + if (class_exists($this->getClassName())) { + // This class does exist. :-) + $isValid = TRUE; + } elseif ($this->getClassName() != $this->statePrefix . 'DefaultState') { + // Set default state + $this->setClassName($this->statePrefix . 'DefaultState'); + } else { + // All is tried, give it up here + throw new DefaultStateException($this, self::EXCEPTION_DEFAULT_STATE_GONE); + } + } // END - while + + // Return the result + return $isValid; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/resolver/state/network/.htaccess b/application/hub/classes/resolver/state/network/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/state/network/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/state/peer/.htaccess b/application/hub/classes/resolver/state/peer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/resolver/state/peer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php b/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php new file mode 100644 index 000000000..4429f1b91 --- /dev/null +++ b/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php @@ -0,0 +1,95 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PeerStateResolver extends BaseStateResolver implements StateResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'Peer' + $this->setStatePrefix('Peer'); + } + + /** + * Creates an instance of a resolver class with a given state + * + * @return $resolverInstance The prepared state resolver instance + */ + public static final function createPeerStateResolver () { + // Create the new instance + $resolverInstance = new PeerStateResolver(); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an state instance for a given raw package data and socket resource + * + * @param $helperInstance An instance of a ConnectionHelper class + * @param $packageData Raw package data + * @param $socketResource A valid socket resource + * @return $stateInstance An instance of the resolved state + * @throws InvalidSocketException If socketResource, even from getSocketResource() is no valid resource + * @todo ~30% done + */ + public static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource) { + // Get temporary resolver instance + $resolverInstance = self::createPeerStateResolver(); + + // Init state instance + $stateInstance = NULL; + + // Is the socket resource valid? + if (!is_resource($socketResource)) { + // No, so get socket resource from helper + $socketResource = $helperInstance->getSocketResource(); + + // Still no socket resource? + if (!is_resource($socketResource)) { + // Then abort here with an exception (may happen after socket_shutdown()) + throw new InvalidSocketException(array($helperInstance, $socketResource, 'unknown', 'unknown'), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + } // END - if + + // Get error code from it + $errorCode = socket_last_error($socketResource); + + // Translate the error code to an own name + $errorCode = $helperInstance->translateSocketErrorCodeToName($errorCode); + + // Create a state instance based on $errorCode. This factory does the hard work for us + $stateInstance = PeerStateFactory::createPeerStateInstanceBySocketStatusCode($helperInstance, $packageData, $socketResource, $errorCode); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/scanner/.htaccess b/application/hub/classes/scanner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/scanner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/scanner/class_ b/application/hub/classes/scanner/class_ new file mode 100644 index 000000000..5cc29c9e5 --- /dev/null +++ b/application/hub/classes/scanner/class_ @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Scanner extends BaseScanner implements Scanner, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $scannerInstance An instance of a Scanner class + */ + public final static function create???Scanner () { + // Get new instance + $scannerInstance = new ???Scanner(); + + // Return the prepared instance + return $scannerInstance; + } + + /** + * Runs the scanner (please no loops here) + * + * @return void + * @todo 0% done + */ + public function execute () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/scanner/class_BaseScanner.php b/application/hub/classes/scanner/class_BaseScanner.php new file mode 100644 index 000000000..a890efa8c --- /dev/null +++ b/application/hub/classes/scanner/class_BaseScanner.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseScanner extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/scanner/crawler/.htaccess b/application/hub/classes/scanner/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/scanner/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/scanner/crawler/class_Crawler b/application/hub/classes/scanner/crawler/class_Crawler new file mode 100644 index 000000000..d02f28cd4 --- /dev/null +++ b/application/hub/classes/scanner/crawler/class_Crawler @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Crawler???Scanner extends BaseScanner implements Scanner, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $scannerInstance An instance of a Scanner class + */ + public final static function createCrawler???Scanner () { + // Get new instance + $scannerInstance = new Crawler???Scanner(); + + // Return the prepared instance + return $scannerInstance; + } + + /** + * Runs the scanner (please no loops here) + * + * @return void + * @todo 0% done + */ + public function execute () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/scanner/crawler/uploaded_list/.htaccess b/application/hub/classes/scanner/crawler/uploaded_list/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/scanner/crawler/uploaded_list/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php b/application/hub/classes/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php new file mode 100644 index 000000000..1dfac0f40 --- /dev/null +++ b/application/hub/classes/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUploadedListScanner extends BaseScanner implements Scanner, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $scannerInstance An instance of a Scanner class + */ + public final static function createCrawlerUploadedListScanner () { + // Get new instance + $scannerInstance = new CrawlerUploadedListScanner(); + + // Return the prepared instance + return $scannerInstance; + } + + /** + * Runs the scanner (please no loops here) + * + * @return void + * @todo 0% done + */ + public function execute () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/.htaccess b/application/hub/classes/source/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/source/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/source/class_ b/application/hub/classes/source/class_ new file mode 100644 index 000000000..0f70d7fe7 --- /dev/null +++ b/application/hub/classes/source/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Source extends BaseSource implements Source!!! { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Source class + */ + public final static function create???Source () { + // Get new instance + $sourceInstance = new ???Source(); + + // Return the prepared instance + return $sourceInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/class_BaseSource.php b/application/hub/classes/source/class_BaseSource.php new file mode 100644 index 000000000..d15fd2369 --- /dev/null +++ b/application/hub/classes/source/class_BaseSource.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseSource extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/class_BaseUrlSource.php b/application/hub/classes/source/class_BaseUrlSource.php new file mode 100644 index 000000000..c4ef08404 --- /dev/null +++ b/application/hub/classes/source/class_BaseUrlSource.php @@ -0,0 +1,116 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseUrlSource extends BaseSource { + // Stack name for all URLs + const STACKER_NAME_URLS = 'urls'; + + // Array elements for CSV data array + const CRAWL_JOB_ARRAY_START_URL = 'start_url'; + const CRAWL_JOB_ARRAY_DEPTH = 'start_depth'; + const CRAWL_JOB_ARRAY_EXTERNAL_DEPTH = 'external_depth'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initalizes this source + * + * @param $prefix Prefix for this source + * @param $sourceName Name of this source + * @return void + */ + protected function initSource ($prefix, $sourceName) { + // Use another object factory + $stackInstance = FileStackFactory::createFileStackInstance($prefix . '_url', $sourceName); + + // Set the stack here + $this->setStackInstance($stackInstance); + } + + /** + * Determines whether the stack 'urls' is empty. + * + * @return $isEmpty Whether the stack 'urls' is empty. + */ + public function isUrlStackEmpty () { + // Determine it + $isEmpty = $this->getStackInstance()->isStackEmpty(self::STACKER_NAME_URLS); + + // Return result + return $isEmpty; + } + + /** + * Enriches the given associative array with more data, now at least 2 + * elements are required: + * + * 'start_url' - Starting URL + * 'start_depth' - Crawl depth for starting URL + * + * @param $crawlData Array with partial data for being queued + * @return void + * @todo ~10% done + */ + protected function enrichCrawlerQueueData (array &$crawlData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: crawlData()=' . count($crawlData) . ' - CALLED!'); + + // Check for minimum array elements + assert(isset($crawlData[self::CRAWL_JOB_ARRAY_START_URL])); + assert(isset($crawlData[self::CRAWL_JOB_ARRAY_DEPTH])); + + // @TODO Add more elements + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Enqueues given crawler array in assigned file-based stack + * + * @param $crawlData Array with partial data for being queued + * @return void + */ + protected function enqueueInFileStack (array $crawlData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: crawlData()=' . count($crawlData) . ' - CALLED!'); + + // Get the stack instance and enqueue it + $this->getStackInstance()->pushNamed(self::STACKER_NAME_URLS, $crawlData); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/units/.htaccess b/application/hub/classes/source/units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/source/units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/source/units/class_TestUnitSource.php b/application/hub/classes/source/units/class_TestUnitSource.php new file mode 100644 index 000000000..eef01ff2a --- /dev/null +++ b/application/hub/classes/source/units/class_TestUnitSource.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TestUnitSource extends BaseSource implements UnitSource, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Source class + */ + public final static function createTestUnitSource () { + // Get new instance + $sourceInstance = new TestUnitSource(); + + // Create a RNG instance and set it in this class + $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); + $sourceInstance->setRngInstance($rngInstance); + + // And also a crypto instance (for our encrypted messages) + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + $sourceInstance->setCryptoInstance($cryptoInstance); + + // Return the prepared instance + return $sourceInstance; + } + + /** + * Generates an encrypted random message + * + * @return $encryptedMessage The encrypted random message + */ + public function generateMessageFromSource () { + // Get a very secret message by encoding and random string with BASE64 + $secretMessage = base64_encode($this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_message_length'))); + + // Get a random, secret key + $secretKey = $this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length') / 8); + + // Now encrypt the message with our key and a good (strong) cipher + $encryptedMessage = base64_encode($this->getCryptoInstance()->encryptString($secretMessage, $secretKey)); + + // Return it + return $encryptedMessage; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/urls/.htaccess b/application/hub/classes/source/urls/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/source/urls/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/source/urls/class_Crawler b/application/hub/classes/source/urls/class_Crawler new file mode 100644 index 000000000..5ef38a60a --- /dev/null +++ b/application/hub/classes/source/urls/class_Crawler @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Crawler???UrlSource extends BaseUrlSource implements UrlSource, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Source class + */ + public final static function createCrawler???UrlSource () { + // Get new instance + $sourceInstance = new Crawler???UrlSource(); + + // Init source + $sourceInstance->initSource('crawler', '!!!'); + + // Return the prepared instance + return $sourceInstance; + } + + /** + * Processes entries in the stack. + * + * @return void + * @todo ~ 10% done + */ + public function processStack () { + // Does the stack have some entries left? + if ($this->isUrlStackEmpty()) { + // Nothing to handle here + return; + } // END - if + + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/urls/class_CrawlerFoundRssUrlSource.php b/application/hub/classes/source/urls/class_CrawlerFoundRssUrlSource.php new file mode 100644 index 000000000..cad4691e7 --- /dev/null +++ b/application/hub/classes/source/urls/class_CrawlerFoundRssUrlSource.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerFoundRssUrlSource extends BaseUrlSource implements UrlSource, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Source class + */ + public final static function createCrawlerFoundRssUrlSource () { + // Get new instance + $sourceInstance = new CrawlerFoundRssUrlSource(); + + // Init source + $sourceInstance->initSource('crawler', 'found_rss'); + + // Return the prepared instance + return $sourceInstance; + } + + /** + * Fills the URL stack with new entries from source + * + * @return void + * @todo 0% done + */ + public function fillUrlStack () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/urls/class_CrawlerLocalStartUrlSource.php b/application/hub/classes/source/urls/class_CrawlerLocalStartUrlSource.php new file mode 100644 index 000000000..fdabe0642 --- /dev/null +++ b/application/hub/classes/source/urls/class_CrawlerLocalStartUrlSource.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerLocalStartUrlSource extends BaseUrlSource implements UrlSource, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Source class + */ + public final static function createCrawlerLocalStartUrlSource () { + // Get new instance + $sourceInstance = new CrawlerLocalStartUrlSource(); + + // Init source + $sourceInstance->initSource('crawler', 'local_start'); + + // Return the prepared instance + return $sourceInstance; + } + + /** + * Fills the URL stack with new entries from source + * + * @return void + * @todo 0% done + */ + public function fillUrlStack () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/urls/class_CrawlerRssStartUrlSource.php b/application/hub/classes/source/urls/class_CrawlerRssStartUrlSource.php new file mode 100644 index 000000000..ef6ade1bd --- /dev/null +++ b/application/hub/classes/source/urls/class_CrawlerRssStartUrlSource.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerRssStartUrlSource extends BaseUrlSource implements UrlSource, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Source class + */ + public final static function createCrawlerRssStartUrlSource () { + // Get new instance + $sourceInstance = new CrawlerRssStartUrlSource(); + + // Init source + $sourceInstance->initSource('crawler', 'rss_start'); + + // Return the prepared instance + return $sourceInstance; + } + + /** + * Fills the URL stack with new entries from source + * + * @return void + * @todo 0% done + */ + public function fillUrlStack () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php new file mode 100644 index 000000000..33caffaf8 --- /dev/null +++ b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php @@ -0,0 +1,369 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, Registerable { + /** + * Stack name for a CSV file + */ + const STACK_NAME_CSV_FILE = 'csv_file'; + + /** + * Stack name for a CSV entry + */ + const STACK_NAME_CSV_ENTRY = 'csv_entry'; + + /** + * Size of crawl (CSV) entry which is an indexed array: + * + * 0 = URL to crawl + * 1 = Crawl depth of URL + * 2 = Crawl depth of linked URLs (same other host only) + */ + const CRAWL_ENTRY_SIZE = 3; + + /** + * "Cached" CSV path + */ + private $csvFilePath = ''; + + /** + * Last CSV file instance + */ + private $lastCsvFileInstance = NULL; + + /** + * Stack for pushing data from this clas to another + */ + private $stackSourceInstance = NULL; + + /** + * "Imported" CSV files + */ + private $csvFileImported = array(); + + /** + * "Cached" separator for columns + */ + private $columnSeparator = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // "Cache" CSV path for faster usage + $this->csvFilePath = $this->getConfigInstance()->getConfigEntry('base_path') . '/' . $this->getConfigInstance()->getConfigEntry('crawler_csv_file_path'); + + // Initialize directory instance + $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($this->csvFilePath)); + + // Set it here + $this->setDirectoryInstance($directoryInstance); + + // Init stack instance + $this->stackSourceInstance = ObjectFactory::createObjectByConfiguredName('crawler_uploaded_list_url_source_stack_class'); + + // Init stacks + $this->getStackSourceInstance()->initStack(self::STACK_NAME_CSV_FILE); + $this->getStackSourceInstance()->initStack(self::STACK_NAME_CSV_ENTRY); + + // "Cache" column separator + $this->columnSeparator = $this->getConfigInstance()->getConfigEntry('crawler_url_list_column_separator'); + } + + /** + * Checks whether a CSV file is found in configured path + * + * @return $isFound Whether a CSV file is found + */ + private function isCsvFileFound () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Is it valid? + if (!$this->getDirectoryInstance()->getDirectoryIteratorInstance()->valid()) { + // Rewind to start + $this->getDirectoryInstance()->getDirectoryIteratorInstance()->rewind(); + } // END - if + + // Read next entry + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: this->csvFileImported=' . print_r($this->csvFileImported, TRUE)); + $directoryEntry = $this->getDirectoryInstance()->readDirectoryExcept(array_merge(array('.htaccess', '.', '..'), $this->csvFileImported)); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry); + + // Is it empty or wrong file extension? + if ((empty($directoryEntry)) || (substr($directoryEntry, -4, 4) != '.csv')) { + // Skip further processing + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - SKIPPED!'); + return FALSE; + } // END - if + + // Initialize CSV file instance + $this->lastCsvFileInstance = ObjectFactory::createObjectByConfiguredName('csv_input_file_class', array($this->csvFilePath . '/' . $directoryEntry)); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - Instance created - EXIT!'); + + // Found an entry + return TRUE; + } + + /** + * Creates an instance of this class + * + * @return $sourceInstance An instance of a Source class + */ + public final static function createCrawlerUploadedListUrlSource () { + // Get new instance + $sourceInstance = new CrawlerUploadedListUrlSource(); + + // Init source + $sourceInstance->initSource('crawler', 'uploaded_list'); + + // Return the prepared instance + return $sourceInstance; + } + + /** + * Enriches and saves the given CSV entry (array) in the assigned + * file-based stack. To such entry a lot more informations are added, such + * as which files shall be crawled and many more. + * + * @param $csvData Array with data from a CSV file + * @return void + */ + private function saveCsvDataInCrawlerQueue (array $csvData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData()=' . count($csvData) . ' - CALLED!'); + + // The array must have a fixed amount of elements, later enhancements may accept more + assert(count($csvData) == self::CRAWL_ENTRY_SIZE); + + /* + * First converted the indexed array into an assoziative array. Don't + * forget to expand this array as well when you want to add another + * column to the CSV file. + */ + $csvArray = array( + self::CRAWL_JOB_ARRAY_START_URL => $csvData[0], + self::CRAWL_JOB_ARRAY_DEPTH => $csvData[1], + self::CRAWL_JOB_ARRAY_EXTERNAL_DEPTH => $csvData[2] + ); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvArray()=' . count($csvArray) . ' - BEFORE!'); + + // Then add more data to it + $this->enrichCrawlerQueueData($csvArray); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvArray()=' . count($csvArray) . ' - AFTER!'); + + /* + * Then enqueue it in the file stack. The local crawler "task" will + * then pick this up. + */ + $this->enqueueInFileStack($csvArray); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Checks whether a CSV file has been loaded (added to the stack) + * + * @return $isAdded Whether a CSV file has been loaded + */ + private function isCsvFileAdded () { + // Check whether the stacker is not empty + $isAdded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_FILE)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_FILE))); + + // Return the result + return $isAdded; + } + + /** + * Checks whether a CSV entry has been added to the stack + * + * @return $isAdded Whether a CSV entry has been added + */ + private function isCsvEntryAdded () { + // Check whether the stacker is not empty + $isAdded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_ENTRY)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_ENTRY))); + + // Return the result + return $isAdded; + } + + /** + * Initializes the import of the CSV file which is being processed by other task + * + * @return void + * @throws NullPointerException If lastCsvFileInstance is not set + */ + private function addCsvFile () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Is the instance set? + if (is_null($this->lastCsvFileInstance)) { + // This should not happen + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Stack this file + $this->getStackSourceInstance()->pushNamed(self::STACK_NAME_CSV_FILE, $this->lastCsvFileInstance); + + // ... and mark it as "imported" + array_push($this->csvFileImported, basename($this->lastCsvFileInstance->getFileName())); + + // ... and finally NULL it (to save some RAM) + $this->lastCsvFileInstance = NULL; + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Parses the next stacked CSV file by reading only one line from it. Then + * the read line is being validated and if found good being feed to the next + * stack. The file is removed from stack only if it has been fully parsed. + * + * @return void + */ + private function parseCsvFile () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Get next entry + $csvFileInstance = $this->getStackSourceInstance()->popNamed(self::STACK_NAME_CSV_FILE); + + // Read full "CSV line" + $csvData = $csvFileInstance->readCsvFileLine($this->columnSeparator); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData[' . gettype($csvData) . ']=' . print_r($csvData, TRUE)); + + // Expect always an array + assert(is_array($csvData)); + + // Is the array empty? + if (count($csvData) == 0) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: File ' . $csvFileInstance->getFileName() . ' has been fully read.'); + + // Try to close it by actually unsetting (destructing) it + unset($csvFileInstance); + + // This file as been fully read, so don't push it back on stack. + return; + } // END - if + + // ... with a fixed amount of elements, later enhancements may accept more + assert(count($csvData) == self::CRAWL_ENTRY_SIZE); + + /* + * Push the file back on stack as it may contain more entries. This way + * all files got rotated on stack which may improve crawler performance. + */ + $this->getStackSourceInstance()->pushNamed(self::STACK_NAME_CSV_FILE, $csvFileInstance); + + // Push array on next stack + $this->getStackSourceInstance()->pushNamed(self::STACK_NAME_CSV_ENTRY, $csvData); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Parses the next stacked CSV entry. + * + * @return void + */ + private function parseCsvEntry () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Pop it from stack + $csvData = $this->getStackSourceInstance()->popNamed(self::STACK_NAME_CSV_ENTRY); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData[' . gettype($csvData) . ']=' . print_r($csvData, TRUE)); + + // It must have a fixed amount of elements (see method parseCsvFile() for details) + assert(count($csvData) == self::CRAWL_ENTRY_SIZE); + + // Save it in crawler queue (which will enrich it with way more informations + $this->saveCsvDataInCrawlerQueue($csvData); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Getter for stackSourceInstance variable + * + * @return $stackSourceInstance An instance of an additional stack + */ + public final function getStackSourceInstance () { + return $this->stackSourceInstance; + } + + /** + * Fills the URL stack with new entries from source + * + * @return void + * @todo ~40% done + */ + public function fillUrlStack () { + // Does the stack have some entries left? + if ($this->isCsvEntryAdded()) { + /* + * A CSV file has been found and "imported" (added to stack). Now + * the file can be read line by line and checked every one of it. + */ + $this->parseCsvEntry(); + } elseif ($this->isCsvFileAdded()) { + /* + * A CSV file has been found and "imported" (added to stack). Now + * the file can be read line by line and checked every one of it. + */ + $this->parseCsvFile(); + } elseif ($this->isCsvFileFound()) { + /* + * A file containing an URL list is found. Please note the format is + * CSV-like as you may wish to provide meta data such as crawl + * depth, handling of 3rd-party URLs and such. + */ + $this->addCsvFile(); + } + + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/.htaccess b/application/hub/classes/states/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/communicator/.htaccess b/application/hub/classes/states/communicator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/communicator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/communicator/active/.htaccess b/application/hub/classes/states/communicator/active/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/communicator/active/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/communicator/active/class_CommunicatorActiveState.php b/application/hub/classes/states/communicator/active/class_CommunicatorActiveState.php new file mode 100644 index 000000000..64267457d --- /dev/null +++ b/application/hub/classes/states/communicator/active/class_CommunicatorActiveState.php @@ -0,0 +1,57 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CommunicatorActiveState extends BaseCommunicatorState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructo + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('active'); + } + + /** + * Creates an instance of this class + * + * @param $communicatorInstance An instance of a Communicator class + * @return $stateInstance An instance of a Stateable class + */ + public static final function createCommunicatorActiveState (Communicator $communicatorInstance) { + // Get new instance + $stateInstance = new CommunicatorActiveState(); + + // Set the communicator instance + $stateInstance->setCommunicatorInstance($communicatorInstance); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/communicator/class_ b/application/hub/classes/states/communicator/class_ new file mode 100644 index 000000000..c50b5408a --- /dev/null +++ b/application/hub/classes/states/communicator/class_ @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014, 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Communicator???State extends BaseCommunicatorState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } + + /** + * Creates an instance of this class + * + * @param $communicatorInstance An instance of a Communicator class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createCommunicator???State (Communicator $communicatorInstance) { + // Get new instance + $stateInstance = new Communicator???State(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE: Has changed from ' . $communicatorInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the communicator instance + $stateInstance->setCommunicatorInstance($communicatorInstance); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/communicator/class_BaseCommunicatorState.php b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php new file mode 100644 index 000000000..32a055406 --- /dev/null +++ b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014, 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCommunicatorState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Validates whether the state is 'active' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' + */ + public function validateCommunicatorStateIsActive () { + // Just compare it... + if (!$this instanceof CommunicatorActiveState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/communicator/init/.htaccess b/application/hub/classes/states/communicator/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/communicator/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/communicator/init/class_CommunicatorInitState.php b/application/hub/classes/states/communicator/init/class_CommunicatorInitState.php new file mode 100644 index 000000000..30d3a628d --- /dev/null +++ b/application/hub/classes/states/communicator/init/class_CommunicatorInitState.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CommunicatorInitState extends BaseCommunicatorState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructo + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * Creates an instance of this class + * + * @param $communicatorInstance An instance of a Communicator class + * @return $stateInstance An instance of a Stateable class + */ + public static final function createCommunicatorInitState (Communicator $communicatorInstance) { + // Get new instance + $stateInstance = new CommunicatorInitState(); + + // Set the communicator instance + $stateInstance->setCommunicatorInstance($communicatorInstance); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + * @todo 0% done? + */ + public function executeState (Executor $executorInstance) { + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/crawler/.htaccess b/application/hub/classes/states/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/crawler/active/.htaccess b/application/hub/classes/states/crawler/active/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/crawler/active/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/crawler/active/class_CrawlerActiveState.php b/application/hub/classes/states/crawler/active/class_CrawlerActiveState.php new file mode 100644 index 000000000..5abe58723 --- /dev/null +++ b/application/hub/classes/states/crawler/active/class_CrawlerActiveState.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerActiveState extends BaseCrawlerState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructo + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('active'); + } + + /** + * Creates an instance of this class + * + * @param $crawlerInstance An instance of a Crawler class + * @return $stateInstance An instance of a Stateable class + */ + public static final function createCrawlerActiveState () { + // Get new instance + $stateInstance = new CrawlerActiveState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + * @todo 0% done + */ + public function executeState (Executor $executorInstance) { + $this->partialStub('Unfinished method, executorInstance=' . $executorInstance->__toString()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/crawler/booting/.htaccess b/application/hub/classes/states/crawler/booting/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/crawler/booting/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.ph b/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.ph new file mode 100644 index 000000000..ffb733e30 --- /dev/null +++ b/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.ph @@ -0,0 +1,14 @@ + + /** + * State change if the communicator has fully initialized. + * + * @return void + * @todo ~30% done + */ + public function communicatorHasInitialized () { + // Please implement + $this->partialStub('Unfinished method.'); + + // Change state to 'active' + CrawlerStateFactory::createCrawlerStateInstanceByName('active'); + } diff --git a/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.php b/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.php new file mode 100644 index 000000000..6edbdbbd7 --- /dev/null +++ b/application/hub/classes/states/crawler/booting/class_CrawlerBootingState.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerBootingState extends BaseCrawlerState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructo + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('booting'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public static final function createCrawlerBootingState () { + // Get new instance + $stateInstance = new CrawlerBootingState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + * @todo 0% done + */ + public function executeState (Executor $executorInstance) { + $this->partialStub('Unfinished method, executorInstance=' . $executorInstance->__toString()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/crawler/class_ b/application/hub/classes/states/crawler/class_ new file mode 100644 index 000000000..7579778ab --- /dev/null +++ b/application/hub/classes/states/crawler/class_ @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Crawler???State extends BaseCrawlerState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } + + /** + * Creates an instance of this class + * + * @param $crawlerInstance An instance of a Crawler class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createCrawler???State (Crawler $crawlerInstance) { + // Get new instance + $stateInstance = new Crawler???State(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE: Has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the crawler instance + $stateInstance->setCrawlerInstance($crawlerInstance); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/crawler/class_BaseCrawlerState.php b/application/hub/classes/states/crawler/class_BaseCrawlerState.php new file mode 100644 index 000000000..fbb75fda4 --- /dev/null +++ b/application/hub/classes/states/crawler/class_BaseCrawlerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCrawlerState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Validates whether the state is 'active' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' + */ + public function validateCrawlerStateIsActive () { + // Just compare it... + if (!$this instanceof CrawlerActiveState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/crawler/init/.htaccess b/application/hub/classes/states/crawler/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/crawler/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/crawler/init/class_CrawlerInitState.php b/application/hub/classes/states/crawler/init/class_CrawlerInitState.php new file mode 100644 index 000000000..fffd219ed --- /dev/null +++ b/application/hub/classes/states/crawler/init/class_CrawlerInitState.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerInitState extends BaseCrawlerState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructo + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public static final function createCrawlerInitState () { + // Get new instance + $stateInstance = new CrawlerInitState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + // Initialize the executor (can be a Communicator instance) + $executorInstance->initExecutor($this); + } + + /** + * State change if the communicator has fully initialized. + * + * @return void + * @todo ~30% done + */ + public function communicatorHasInitialized () { + // Please implement + $this->partialStub('Unfinished method.'); + + // Change state to 'booting' + CrawlerStateFactory::createCrawlerStateInstanceByName('booting'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/cruncher/.htaccess b/application/hub/classes/states/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/cruncher/class_ b/application/hub/classes/states/cruncher/class_ new file mode 100644 index 000000000..03b5bc2df --- /dev/null +++ b/application/hub/classes/states/cruncher/class_ @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Cruncher???State extends BaseCruncherState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } + + /** + * Creates an instance of this class + * + * @param $cruncherInstance An instance of a CruncherHelper class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createCruncher???State (CruncherHelper $cruncherInstance) { + // Get new instance + $stateInstance = new Cruncher???State(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER-STATE: Has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the cruncher instance + $stateInstance->setCruncherInstance($cruncherInstance); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + $this->partialStub('This state needs implementation. executorInstance=' . $executorInstance->__toString()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/cruncher/class_BaseCruncherState.php b/application/hub/classes/states/cruncher/class_BaseCruncherState.php new file mode 100644 index 000000000..246bd812e --- /dev/null +++ b/application/hub/classes/states/cruncher/class_BaseCruncherState.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCruncherState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Validates whether the state is 'active' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' + */ + public function validateCruncherStateIsActive () { + // Just compare it... + if (!$this instanceof CruncherActiveState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Checks if this state is 'virgin' + * + * @return $isVirgin Whether this state is 'virgin' + */ + public function isCruncherStateVirgin () { + // Just compare it... + return ($this instanceof CruncherVirginState); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/cruncher/init/.htaccess b/application/hub/classes/states/cruncher/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/cruncher/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/cruncher/init/class_CruncherInitState.php b/application/hub/classes/states/cruncher/init/class_CruncherInitState.php new file mode 100644 index 000000000..8c1938590 --- /dev/null +++ b/application/hub/classes/states/cruncher/init/class_CruncherInitState.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherInitState extends BaseCruncherState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public final static function createCruncherInitState () { + // Get new instance + $stateInstance = new CruncherInitState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + // Initialize the unit production to maybe become 'virgin' or 'active' if work/test units are there + $executorInstance->initUnitProduction($this); + } + + /** + * An encrypted message has been generated so we change the state to + * 'virgin'. + * + * @return void + */ + public function encryptedMessageGenerated () { + // Change the state now to 'virgin' + CruncherStateFactory::createCruncherStateInstanceByName('virgin'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/cruncher/virgin/.htaccess b/application/hub/classes/states/cruncher/virgin/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/cruncher/virgin/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/cruncher/virgin/class_CruncherVirginState.php b/application/hub/classes/states/cruncher/virgin/class_CruncherVirginState.php new file mode 100644 index 000000000..a5d2f15de --- /dev/null +++ b/application/hub/classes/states/cruncher/virgin/class_CruncherVirginState.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherVirginState extends BaseCruncherState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('virgin'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public final static function createCruncherVirginState () { + // Get new instance + $stateInstance = new CruncherVirginState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + // Produce some keys now + $executorInstance->produceKeys($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/dht/.htaccess b/application/hub/classes/states/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/dht/active/.htaccess b/application/hub/classes/states/dht/active/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/dht/active/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/dht/active/class_DhtActiveState.php b/application/hub/classes/states/dht/active/class_DhtActiveState.php new file mode 100644 index 000000000..549f0fd03 --- /dev/null +++ b/application/hub/classes/states/dht/active/class_DhtActiveState.php @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtActiveState extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('active'); + } + + /** + * Creates an instance of this class + * + * @param $dhtInstance An instance of a Distributable class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createDhtActiveState (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new DhtActiveState(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the dht instance + $stateInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/dht/booting/.htaccess b/application/hub/classes/states/dht/booting/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/dht/booting/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/dht/booting/class_DhtBootingState.php b/application/hub/classes/states/dht/booting/class_DhtBootingState.php new file mode 100644 index 000000000..f6f05cdc5 --- /dev/null +++ b/application/hub/classes/states/dht/booting/class_DhtBootingState.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtBootingState extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('booting'); + } + + /** + * Creates an instance of this class + * + * @param $dhtInstance An instance of a Distributable class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createDhtBootingState (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new DhtBootingState(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the dht instance + $stateInstance->setDhtInstance($dhtInstance); + + // Get node instance and enable DHT bootstrap requests + NodeObjectFactory::createNodeInstance()->enableAcceptDhtBootstrap(); + + // Update DHT node info as well + $dhtInstance->enableAcceptDhtBootstrap(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/dht/class_ b/application/hub/classes/states/dht/class_ new file mode 100644 index 000000000..01bb0c505 --- /dev/null +++ b/application/hub/classes/states/dht/class_ @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Dht???State extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } + + /** + * Creates an instance of this class + * + * @param $dhtInstance An instance of a Distributable class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createDht???State (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new Dht???State(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the dht instance + $stateInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/dht/class_BaseDhtState.php b/application/hub/classes/states/dht/class_BaseDhtState.php new file mode 100644 index 000000000..44e0b5584 --- /dev/null +++ b/application/hub/classes/states/dht/class_BaseDhtState.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Create generic DHT interface + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDhtState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Validates whether the DHT state is 'virgin' or throws an exception if it + * is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'virgin' + */ + public function validateDhtStateIsVirginOrInit () { + // Just compare it... + if ((!$this instanceof DhtVirginState) && (!$this instanceof DhtInitState)) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Checks whether the DHT's state is 'booting' by comparing it with the + * state's class name. + * + * @return $isBooting Whether this DHT's state is 'booting' + */ + public function ifDhtIsBooting () { + // Check state + $isBooting = ($this instanceof DhtBootingState); + + // Return status + return $isBooting; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/dht/init/.htaccess b/application/hub/classes/states/dht/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/dht/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/dht/init/class_DhtInitState.php b/application/hub/classes/states/dht/init/class_DhtInitState.php new file mode 100644 index 000000000..25e6a8262 --- /dev/null +++ b/application/hub/classes/states/dht/init/class_DhtInitState.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtInitState extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * Creates an instance of this class + * + * @param $dhtInstance An instance of a Distributable class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createDhtInitState (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new DhtInitState(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the dht instance + $stateInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $stateInstance; + } + + /** + * The DHT has been initialized. This means that the state can be changed + * to the next one: virgin. + * + * @return void + */ + public function dhtHasInitialized () { + // Create a new instance + DhtStateFactory::createDhtStateInstanceByName('virgin', $this->getDhtInstance()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/dht/virgin/.htaccess b/application/hub/classes/states/dht/virgin/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/dht/virgin/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/dht/virgin/class_DhtVirginState.php b/application/hub/classes/states/dht/virgin/class_DhtVirginState.php new file mode 100644 index 000000000..e9998fa4a --- /dev/null +++ b/application/hub/classes/states/dht/virgin/class_DhtVirginState.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtVirginState extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('virgin'); + } + + /** + * Creates an instance of this class + * + * @param $dhtInstance An instance of a Distributable class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createDhtVirginState (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new DhtVirginState(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the dht instance + $stateInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Called when the DHT is booting. This means that the bootstrap message + * has been queued. + * + * @return void + */ + public function dhtIsBooting () { + // Get new instance and set it + DhtStateFactory::createDhtStateInstanceByName('booting', $this->getDhtInstance()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/generic/.htaccess b/application/hub/classes/states/generic/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/generic/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/hub/.htaccess b/application/hub/classes/states/hub/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/hub/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/miner/.htaccess b/application/hub/classes/states/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/miner/booting/.htaccess b/application/hub/classes/states/miner/booting/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/miner/booting/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/miner/booting/class_MinerBootingState.php b/application/hub/classes/states/miner/booting/class_MinerBootingState.php new file mode 100644 index 000000000..a30e8a641 --- /dev/null +++ b/application/hub/classes/states/miner/booting/class_MinerBootingState.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerBootingState extends BaseMinerState implements Stateable { + /** + * Array of booted producers + */ + private $bootedProducer = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('booting'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public final static function createMinerBootingState () { + // Get new instance + $stateInstance = new MinerBootingState(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + // Has this executor (producer) run? + if (isset($this->bootedProducer[$executorInstance->__toString()])) { + // Then silently skip this + return; + } // END - if + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Calling prepareBlockProduction() on ' . $executorInstance->__toString() . ' ...'); + + // Now prepare the unit production to maybe become 'virgin' or 'active' if work/test units are there + $executorInstance->prepareBlockProduction($this); + + // Mark producer as booted + $this->bootedProducer[$executorInstance->__toString()] = TRUE; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/miner/class_BaseMinerState.php b/application/hub/classes/states/miner/class_BaseMinerState.php new file mode 100644 index 000000000..cf53991ee --- /dev/null +++ b/application/hub/classes/states/miner/class_BaseMinerState.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMinerState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Validates whether the state is 'active' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' + */ + public function validateMinerStateIsActive () { + // Just compare it... + if (!$this instanceof MinerActiveState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Validates whether the state is 'init' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'init' + */ + public function validateMinerStateIsInit () { + // Just compare it... + if (!$this instanceof MinerInitState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Validates whether the state is 'booting' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'booting' + */ + public function validateMinerStateIsBooting () { + // Just compare it... + if (!$this instanceof MinerBootingState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Checks if this state is 'virgin' + * + * @return $isVirgin Whether this state is 'virgin' + */ + public function isMinerStateVirgin () { + // Just compare it... + return ($this instanceof MinerVirginState); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/miner/class_Miner b/application/hub/classes/states/miner/class_Miner new file mode 100644 index 000000000..b2020ce94 --- /dev/null +++ b/application/hub/classes/states/miner/class_Miner @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Miner???State extends BaseMinerState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } + + /** + * Creates an instance of this class + * + * @param $minerInstance An instance of a MinerHelper class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createMiner???State (MinerHelper $minerInstance) { + // Get new instance + $stateInstance = new Miner???State(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the miner instance + $stateInstance->setMinerInstance($minerInstance); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + $this->partialStub('This state needs implementation. executorInstance=' . $executorInstance->__toString()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/miner/init/.htaccess b/application/hub/classes/states/miner/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/miner/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/miner/init/class_MinerInitState.php b/application/hub/classes/states/miner/init/class_MinerInitState.php new file mode 100644 index 000000000..1b687ebd5 --- /dev/null +++ b/application/hub/classes/states/miner/init/class_MinerInitState.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerInitState extends BaseMinerState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public final static function createMinerInitState () { + // Get new instance + $stateInstance = new MinerInitState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + * @todo 0% done? + */ + public function executeState (Executor $executorInstance) { + } + + /** + * An encrypted message has been generated so we change the state to + * 'virgin'. + * + * @return void + */ + public function encryptedMessageGenerated () { + // Change the state now to 'virgin' + MinerStateFactory::createMinerStateInstanceByName('virgin'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/miner/virgin/.htaccess b/application/hub/classes/states/miner/virgin/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/miner/virgin/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/miner/virgin/class_MinerVirginState.php b/application/hub/classes/states/miner/virgin/class_MinerVirginState.php new file mode 100644 index 000000000..40340a67d --- /dev/null +++ b/application/hub/classes/states/miner/virgin/class_MinerVirginState.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerVirginState extends BaseMinerState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('virgin'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public final static function createMinerVirginState () { + // Get new instance + $stateInstance = new MinerVirginState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + */ + public function executeState (Executor $executorInstance) { + // Produce some keys now + $executorInstance->produceKeys($this); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/.htaccess b/application/hub/classes/states/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/node/active/.htaccess b/application/hub/classes/states/node/active/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/node/active/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/node/active/class_NodeActiveState.php b/application/hub/classes/states/node/active/class_NodeActiveState.php new file mode 100644 index 000000000..0352ff754 --- /dev/null +++ b/application/hub/classes/states/node/active/class_NodeActiveState.php @@ -0,0 +1,80 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeActiveState extends BaseNodeState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('active'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public static final function createNodeActiveState () { + // Get new instance + $stateInstance = new NodeActiveState(); + + // Get node instance and set 'active' flag + NodeObjectFactory::createNodeInstance()->enableIsActive(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * State change for if the node got announced to it's upper hubs + * + * @return void + */ + public function nodeAnnouncingToUpperHubs () { + // Create the new state instance + NodeStateFactory::createNodeStateInstanceByName('announcing'); + } + + /** + * State change for if the node has just connected to itself and + * node/session id are both equal. The self-connect means that + * the node possibly reachable from outside. This may require + * confirmation by other peers. + * + * @return void + * @todo We might want to move some calls to this method to fill it with life + */ + public function nodeHasSelfConnected () { + // Create the new state instance + NodeStateFactory::createNodeStateInstanceByName('reachable'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/announced/.htaccess b/application/hub/classes/states/node/announced/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/node/announced/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/node/announced/class_NodeAnnouncementCompletedState.php b/application/hub/classes/states/node/announced/class_NodeAnnouncementCompletedState.php new file mode 100644 index 000000000..f9fdba626 --- /dev/null +++ b/application/hub/classes/states/node/announced/class_NodeAnnouncementCompletedState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncementCompletedState extends BaseNodeState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('announcement_completed'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public static final function createNodeAnnouncementCompletedState () { + // Get new instance + $stateInstance = new NodeAnnouncementCompletedState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/announced/class_NodeAnnouncingState.php b/application/hub/classes/states/node/announced/class_NodeAnnouncingState.php new file mode 100644 index 000000000..d8b114eaa --- /dev/null +++ b/application/hub/classes/states/node/announced/class_NodeAnnouncingState.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncingState extends BaseNodeState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('announcing'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public static final function createNodeAnnouncingState () { + // Get new instance + $stateInstance = new NodeAnnouncingState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Changes the state if the announcement (to bootstrap node) was + * successful. + * + * @return void + */ + public function nodeAnnouncementSuccessful () { + // The node's announcement was successful + NodeStateFactory::createNodeStateInstanceByName('announcement_completed'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/class_ b/application/hub/classes/states/node/class_ new file mode 100644 index 000000000..82f1903d9 --- /dev/null +++ b/application/hub/classes/states/node/class_ @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???State extends BaseNodeState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance An instance of a NodeHelper class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createNode???State (NodeHelper $nodeInstance) { + // Get new instance + $stateInstance = new Node???State(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the node instance + $stateInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/class_BaseNodeState.php b/application/hub/classes/states/node/class_BaseNodeState.php new file mode 100644 index 000000000..171331df8 --- /dev/null +++ b/application/hub/classes/states/node/class_BaseNodeState.php @@ -0,0 +1,98 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Validates whether the state is 'active' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' + */ + public function validateNodeStateIsActive () { + // Just compare it... + if (!$this instanceof NodeActiveState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Validates whether the state is 'active' or 'announcing' or throws an + * exception if it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' and not 'announcing' + */ + public function validateNodeStateIsActiveOrAnnouncing () { + // Just compare it... + if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeAnnouncingState)) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Validates whether the state is 'active' or 'reachable' or throws an + * exception if it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' and not 'reachable' + */ + public function validateNodeStateIsActiveOrReachable () { + // Just compare it... + if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeReachableState)) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Validates if the state is 'announcement_completed' or throws an + * exception if it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'active' and not 'announcing' + */ + public function validateNodeStateIsAnnouncementCompleted () { + // Just compare it... + if (!$this instanceof NodeAnnouncementCompletedState) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/init/.htaccess b/application/hub/classes/states/node/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/node/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/node/init/class_NodeInitState.php b/application/hub/classes/states/node/init/class_NodeInitState.php new file mode 100644 index 000000000..6f4014f17 --- /dev/null +++ b/application/hub/classes/states/node/init/class_NodeInitState.php @@ -0,0 +1,65 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeInitState extends BaseNodeState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructo + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public static final function createNodeInitState () { + // Get new instance + $stateInstance = new NodeInitState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * State change for if the node has just generated a session id. This makes + * nodes with current state 'init' now 'virgin'. + * + * @return void + * @todo We might want to move some calls to this method to fill it with life + */ + public function nodeGeneratedSessionId () { + // Create the new state instance + NodeStateFactory::createNodeStateInstanceByName('virgin'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/seniors/.htaccess b/application/hub/classes/states/node/seniors/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/node/seniors/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/node/seniors/class_NodeReachableState.php b/application/hub/classes/states/node/seniors/class_NodeReachableState.php new file mode 100644 index 000000000..424198877 --- /dev/null +++ b/application/hub/classes/states/node/seniors/class_NodeReachableState.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeReachableState extends BaseNodeState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('reachable'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public final static function createNodeReachableState () { + // Get new instance + $stateInstance = new NodeReachableState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * State change for if the node got announced to it's upper hubs + * + * @return void + */ + public function nodeAnnouncingToUpperHubs () { + // Create the new state instance + NodeStateFactory::createNodeStateInstanceByName('announcing'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/node/virgin/.htaccess b/application/hub/classes/states/node/virgin/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/node/virgin/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/node/virgin/class_NodeVirginState.php b/application/hub/classes/states/node/virgin/class_NodeVirginState.php new file mode 100644 index 000000000..2d83f58e1 --- /dev/null +++ b/application/hub/classes/states/node/virgin/class_NodeVirginState.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeVirginState extends BaseNodeState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('virgin'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a Stateable class + */ + public static final function createNodeVirginState () { + // Get new instance + $stateInstance = new NodeVirginState(); + + // Return the prepared instance + return $stateInstance; + } + + /** + * Change the state to 'active' when the hub has initialized all + * listeners, tasks, queues, etc. An active hub does not imply that it + * can be reached from outside so we have to deal with that state with + * yet another state class. + * + * @return void + */ + public function nodeIsActivated () { + // Create the new state instance + NodeStateFactory::createNodeStateInstanceByName('active'); + } + +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/.htaccess b/application/hub/classes/states/peer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/peer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/peer/class_ b/application/hub/classes/states/peer/class_ new file mode 100644 index 000000000..850482bc8 --- /dev/null +++ b/application/hub/classes/states/peer/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???PeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_!!!); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function create???PeerState () { + // Get new instance + $stateInstance = new ???PeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/class_BasePeerState.php b/application/hub/classes/states/peer/class_BasePeerState.php new file mode 100644 index 000000000..cbbc183f2 --- /dev/null +++ b/application/hub/classes/states/peer/class_BasePeerState.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePeerState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Validates whether the state is 'connected' or throws an exception if + * it is every other state. + * + * @return void + * @throws UnexpectedStateException If the state is not 'connected' + */ + public function validatePeerStateConnected () { + // Just compare it... + if (!$this->isPeerStateConnected()) { + // Throw the exception + throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } + + /** + * Checks whether the peer's state is 'connected' + * + * @return $isConnected Whether the state is 'connected' + */ + public function isPeerStateConnected () { + // Just compare it... + return ($this instanceof ConnectedPeerState); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/connected/.htaccess b/application/hub/classes/states/peer/connected/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/peer/connected/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/peer/connected/class_ConnectedPeerState.php b/application/hub/classes/states/peer/connected/class_ConnectedPeerState.php new file mode 100644 index 000000000..5080888d2 --- /dev/null +++ b/application/hub/classes/states/peer/connected/class_ConnectedPeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConnectedPeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_CONNECTED); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createConnectedPeerState () { + // Get new instance + $stateInstance = new ConnectedPeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/errors/.htaccess b/application/hub/classes/states/peer/errors/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/peer/errors/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php b/application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php new file mode 100644 index 000000000..813a703cb --- /dev/null +++ b/application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConnectionRefusedPeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_CONNECTION_REFUSED); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createConnectionRefusedPeerState () { + // Get new instance + $stateInstance = new ConnectionRefusedPeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php b/application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php new file mode 100644 index 000000000..40f91a6c8 --- /dev/null +++ b/application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConnectionTimedOutPeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_CONNECTION_TIMED_OUT); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createConnectionTimedOutPeerState () { + // Get new instance + $stateInstance = new ConnectionTimedOutPeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php b/application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php new file mode 100644 index 000000000..a8c69784f --- /dev/null +++ b/application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoRouteToHostPeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_NO_ROUTE_TO_HOST); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createNoRouteToHostPeerState () { + // Get new instance + $stateInstance = new NoRouteToHostPeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php b/application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php new file mode 100644 index 000000000..9491ef79e --- /dev/null +++ b/application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class OperationAlreadyProgressPeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createOperationAlreadyProgressPeerState () { + // Get new instance + $stateInstance = new OperationAlreadyProgressPeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/errors/class_ProblemPeerState.php b/application/hub/classes/states/peer/errors/class_ProblemPeerState.php new file mode 100644 index 000000000..06dbb9d57 --- /dev/null +++ b/application/hub/classes/states/peer/errors/class_ProblemPeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ProblemPeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_UNKNOWN); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createProblemPeerState () { + // Get new instance + $stateInstance = new ProblemPeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php b/application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php new file mode 100644 index 000000000..375cf7bf4 --- /dev/null +++ b/application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TransportEndpointGonePeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createTransportEndpointGonePeerState () { + // Get new instance + $stateInstance = new TransportEndpointGonePeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/init/.htaccess b/application/hub/classes/states/peer/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/peer/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/peer/init/class_InitPeerState.php b/application/hub/classes/states/peer/init/class_InitPeerState.php new file mode 100644 index 000000000..2a1490725 --- /dev/null +++ b/application/hub/classes/states/peer/init/class_InitPeerState.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InitPeerState extends BasePeerState implements PeerStateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * Creates an instance of this class + * + * @return $stateInstance An instance of a PeerStateable class + */ + public final static function createInitPeerState () { + // Get new instance + $stateInstance = new InitPeerState(); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/states/peer/new/.htaccess b/application/hub/classes/states/peer/new/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/peer/new/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/states/peer/transport_endpoint/.htaccess b/application/hub/classes/states/peer/transport_endpoint/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/states/peer/transport_endpoint/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/statistics/.htaccess b/application/hub/classes/statistics/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/statistics/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/statistics/connection/.htaccess b/application/hub/classes/statistics/connection/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/statistics/connection/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php b/application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php new file mode 100644 index 000000000..a624e8dd5 --- /dev/null +++ b/application/hub/classes/statistics/connection/class_ConnectionStatisticsHelper.php @@ -0,0 +1,105 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConnectionStatisticsHelper extends BaseHubSystem { + /** + * Statistics array + * @TODO Add more protocols to use + */ + private static $connectionStatistics = array( + // Statistics for TCP connections + 'tcp' => array( + // Tried TCP connection attempts + 'retry_count' => array(), + ), + // Statistics for UDP connections + 'udp' => array( + // Tried UDP connection attempts + 'retry_count' => array(), + ) + ); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + parent::__construct(__CLASS__); + } + + /** + * Checks whether the retry count has reached a configured limit for given + * connection. + * + * @param $helperInstance An instance of a ConnectionHelper class + * @return $isExhausted Whether the retry count has been reached + */ + public static function isConnectRetryExhausted (ConnectionHelper $helperInstance) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - CALLED!'); + // Construct config entry + $configEntry = $helperInstance->getProtocolName() . '_connect_retry_max'; + + // Check it out + $isExhausted = ( + ( + isset(self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count']) + ) && ( + self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] >= $helperInstance->getConfigInstance()->getConfigEntry($configEntry) + ) + ); + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ',isExhausted=' . intval($isExhausted) . ' - EXIT!'); + return $isExhausted; + } + + /** + * Increaes connect-retry count for given connection + * + * @param $helperInstance An instance of a ConnectionHelper class + * @return void + */ + public static function increaseConnectRetry (ConnectionHelper $helperInstance) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - CALLED!'); + // Is the counter there + if (!isset(self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'])) { + // First attempt + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - FIRST!'); + self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] = 1; + } else { + // Next attempt + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - INCREMENT!'); + self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count']++; + } + + // Create/update 'last_update' for purging + // @TODO last_update is not being used at the moment + self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['last_update'] = time(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/streams/.htaccess b/application/hub/classes/streams/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/streams/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/streams/package/.htaccess b/application/hub/classes/streams/package/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/streams/package/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/streams/package/input/.htaccess b/application/hub/classes/streams/package/input/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/streams/package/input/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/streams/package/output/.htaccess b/application/hub/classes/streams/package/output/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/streams/package/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/streams/raw_data/.htaccess b/application/hub/classes/streams/raw_data/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/streams/raw_data/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/streams/raw_data/input/.htaccess b/application/hub/classes/streams/raw_data/input/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/streams/raw_data/input/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php b/application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php new file mode 100644 index 000000000..dcd58ca37 --- /dev/null +++ b/application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php @@ -0,0 +1,103 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RawDataInputStream extends BaseStream implements InputStream { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this node class + * + * @return $streamInstance An instance of this node class + */ + public final static function createRawDataInputStream () { + // Get a new instance + $streamInstance = new RawDataInputStream(); + + // Return the instance + return $streamInstance; + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @todo Do we need to do something more here? + * @throws Base64EncodingModuloException If the data's length modulo 4 is not zero + * @throws Base64EncodingBadException If the data contains characters which are not in the "alphabet" of BASE64 messages. + * @throws MultipleMessageSentException If the sender has sent two messages and both end up here + */ + public function streamData ($data) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-INPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ': data(' . strlen($data) . ')=' . $data); + + // Do we have start and end marker again? + assert($this->ifStartEndMarkersSet($data)); + + // Count of start and end markers must be the same + assert(substr_count($data, BaseRawDataHandler::STREAM_START_MARKER) == substr_count($data, BaseRawDataHandler::STREAM_END_MARKER)); + + // Check if more than two start markers exist and if so, split it. + if (substr_count($data, BaseRawDataHandler::STREAM_START_MARKER) > 1) { + // Please do it outside this method + throw new MultipleMessageSentException(array($this, $data), BaseHubSystem::EXCEPTION_MULTIPLE_MESSAGE_SENT); + } // END - if + + // Remove both + $data = substr($data, strlen(BaseRawDataHandler::STREAM_START_MARKER), -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER)); + + // Can it be validated? + if ((strlen($data) % 4) != 0) { + // Length modulo 4 must be zero, else it is an invalid Base64 message + throw new Base64EncodingModuloException(array($this, $data), BaseHubSystem::EXCEPTION_BASE64_ENCODING_NOT_MODULO_4); + } elseif (!$this->isBase64Encoded($data)) { + // Is not a valid Base64-encoded message + throw new Base64EncodingBadException(array($this, $data), BaseHubSystem::EXCEPTION_BASE64_BAD_ENCODING); + } else { + // Decode the data with BASE64-encoding + $data = base64_decode($data); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-INPUT-STREAM: Length of data is now ' . strlen($data) . ' Bytes.'); + + // Return it + return $data; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/streams/raw_data/output/.htaccess b/application/hub/classes/streams/raw_data/output/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/streams/raw_data/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php b/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php new file mode 100644 index 000000000..97ce0ae21 --- /dev/null +++ b/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RawDataOutputStream extends BaseStream implements OutputStream { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this node class + * + * @return $streamInstance An instance of this node class + */ + public final static function createRawDataOutputStream () { + // Get a new instance + $streamInstance = new RawDataOutputStream(); + + // Return the instance + return $streamInstance; + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + */ + public function streamData ($data) { + /* + * Encode the data with BASE64 encoding and put it in a "frame": + * + * [[S]] - Start marker + * [[E]] - End marker + */ + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-OUTPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ']: data()=' . strlen($data) . ' - BEFORE!'); + $data = BaseRawDataHandler::STREAM_START_MARKER . base64_encode($data) . BaseRawDataHandler::STREAM_END_MARKER; + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-OUTPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ']: data(' . strlen($data) . ')=' . $data); + + // Return it + return $data; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tags/.htaccess b/application/hub/classes/tags/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tags/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tags/class_ b/application/hub/classes/tags/class_ new file mode 100644 index 000000000..919141fab --- /dev/null +++ b/application/hub/classes/tags/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Tags extends BaseTags implements Tagable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $tagsInstance An instance of a Tagable class + */ + public final static function create???Tags () { + // Get new instance + $tagsInstance = new ???Tags(); + + // Return the prepared instance + return $tagsInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tags/class_BaseTags.php b/application/hub/classes/tags/class_BaseTags.php new file mode 100644 index 000000000..f48581776 --- /dev/null +++ b/application/hub/classes/tags/class_BaseTags.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseTags extends BaseHubSystem implements Registerable { + /** + * An array with all tags + */ + private $tags = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for whole tags array + * + * @param $tags A new simple array with tags + * @return void + */ + protected final function setTags (array $tags) { + $this->tags = $tags; + } + + /** + * Getter for whole tags array + * + * @return $tags A new simple array with tags + */ + protected final function getTags () { + return $this->tags; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tags/package/.htaccess b/application/hub/classes/tags/package/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tags/package/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tags/package/class_PackageTags.php b/application/hub/classes/tags/package/class_PackageTags.php new file mode 100644 index 000000000..b2985f766 --- /dev/null +++ b/application/hub/classes/tags/package/class_PackageTags.php @@ -0,0 +1,190 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PackageTags extends BaseTags implements Tagable { + // Exception codes + const EXCEPTION_INVALID_TAG = 0x160; + + /** + * Last found protocol instance + */ + private $lastProtocol = NULL; + + /** + * Last found recipient type + */ + private $lastRecipientType = 'invalid'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init the object registry + $this->initObjectRegistry(); + } + + /** + * Creates an instance of this class + * + * @return $tagsInstance An instance of a Tagable class + */ + public static final function createPackageTags () { + // Get new instance + $tagsInstance = new PackageTags(); + + // Return the prepared instance + return $tagsInstance; + } + + /** + * Loads the XML file (our "object registry") and saves an instance for + * faster re-use. + * + * @return void + */ + private function initObjectRegistry () { + // Output debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Initializing object registry - CALLED!'); + + // Get the application instance + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_object_registry_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML file + $this->getTemplateInstance()->loadXmlTemplate(); + + // Render the XML content + $this->getTemplateInstance()->renderXmlContent(); + + // Output debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Initializing object registry - EXIT!'); + } + + /** + * Extracts the tags from given package data + * + * @param $packageData Raw package data + * @return void + */ + private function extractTagsFromPackageData (array $packageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE)); + + /* + * We take a look at the tags (in most cases only one is needed) so + * first we need the content data splitted up into all it's parts. + */ + $contentData = explode(NetworkPackage::PACKAGE_MASK_SEPARATOR, $packageData[NetworkPackage::PACKAGE_DATA_CONTENT]); + + // Get the tags and store them locally + $this->setTags(explode(NetworkPackage::PACKAGE_TAGS_SEPARATOR, $contentData[NetworkPackage::INDEX_TAGS])); + } + + /** + * Verifies all tags by looking them up in an XML file. This method is + * the key method to make sure only known objects are being distributed and + * shared over the whole hub-network. So if the "tag" (let's better say + * object type) isn't found in that XML the package won't be distributed. + * + * @param $packageData Raw package data + * @return void + * @throws InvalidTagException If a provided tag from the package data is invalid + */ + private function verifyAllTags (array $packageData) { + // Get the registry + $objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); + + // "Walk" over all tags + foreach ($this->getTags() as $tag) { + // Debug output + self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Validating tag ' . $tag . ' ...'); + + // Get an array from this tag + $entry = $objectRegistryInstance->getArrayFromKey(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME, $tag); + + /* + * If it is no array or the array is empty or an entry is missing + * the entry is invalid. + */ + if ((!is_array($entry)) || (count($entry) == 0) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_PROTOCOL])) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]))) { + // Invalid entry found + throw new InvalidTagException(array($this, $tag), self::EXCEPTION_INVALID_TAG); + } // END - if + + // Now save the last discovered protocol/recipient type + $this->lastProtocol = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData); + $this->lastRecipientType = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]; + } // END - foreach + } + + /** + * Chooses the right protocol from given package data + * + * @param $packageData Raw package data + * @return $lastProtocol An instance of the last used HandleableProtocol class + */ + public function chooseProtocolFromPackageData (array $packageData) { + // Extract the tags + $this->extractTagsFromPackageData($packageData); + + // Now we need to verify every single tag + $this->verifyAllTags($packageData); + + // Return the last (and only) found protocol (e.g. 'tcp' is very usual) + return $this->lastProtocol; + } + + /** + * Checks whether the given package data is accepted by the listener + * + * @param $packageData Raw package data + * @param $listenerInstance A Listenable instance + * @return $accepts Whether it is accepted + */ + public function ifPackageDataIsAcceptedByListener (array $packageData, Listenable $listenerInstance) { + // Extract the tags + $this->extractTagsFromPackageData($packageData); + + // Now we need to verify every single tag + $this->verifyAllTags($packageData); + + // Now simply check it out + $accepts = (($this->lastRecipientType == $listenerInstance->getListenerType()) && ($listenerInstance->getListenerType() != 'invalid')); + + // And return the result + return $accepts; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/.htaccess b/application/hub/classes/tasks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/apt-proxy/.htaccess b/application/hub/classes/tasks/apt-proxy/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/apt-proxy/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/apt-proxy/class_ b/application/hub/classes/tasks/apt-proxy/class_ new file mode 100644 index 000000000..51bc2a853 --- /dev/null +++ b/application/hub/classes/tasks/apt-proxy/class_ @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxy???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createAptProxy???Task () { + // Get new instance + $taskInstance = new AptProxy???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/apt-proxy/class_AptProxyListenerTask.php b/application/hub/classes/tasks/apt-proxy/class_AptProxyListenerTask.php new file mode 100644 index 000000000..8b9b3f5dd --- /dev/null +++ b/application/hub/classes/tasks/apt-proxy/class_AptProxyListenerTask.php @@ -0,0 +1,81 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AptProxyListenerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createAptProxyListenerTask () { + // Get new instance + $taskInstance = new AptProxyListenerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/chat/.htaccess b/application/hub/classes/tasks/chat/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/chat/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/chat/class_ b/application/hub/classes/tasks/chat/class_ new file mode 100644 index 000000000..dec772a49 --- /dev/null +++ b/application/hub/classes/tasks/chat/class_ @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Chat???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createChat???Task () { + // Get new instance + $taskInstance = new Chat???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/chat/class_ChatTelnetListenerTask.php b/application/hub/classes/tasks/chat/class_ChatTelnetListenerTask.php new file mode 100644 index 000000000..81e19043e --- /dev/null +++ b/application/hub/classes/tasks/chat/class_ChatTelnetListenerTask.php @@ -0,0 +1,81 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2012 Chat Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ChatTelnetListenerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createChatTelnetListenerTask () { + // Get new instance + $taskInstance = new ChatTelnetListenerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/.htaccess b/application/hub/classes/tasks/crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/class_BaseUrlSourceTask.php b/application/hub/classes/tasks/crawler/class_BaseUrlSourceTask.php new file mode 100644 index 000000000..9399ae89c --- /dev/null +++ b/application/hub/classes/tasks/crawler/class_BaseUrlSourceTask.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseUrlSourceTask extends BaseTask { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initializes URL source task (to keep the constructor small) + * + * @return void + */ + protected function initUrlSourceTask () { + // Get source instance + $sourceInstance = UrlSourceObjectFactory::createUrlSourceInstance($this); + + // And set it here + $this->setUrlSourceInstance($sourceInstance); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/class_Crawler b/application/hub/classes/tasks/crawler/class_Crawler new file mode 100644 index 000000000..f4d0f010b --- /dev/null +++ b/application/hub/classes/tasks/crawler/class_Crawler @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Crawler???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawler???Task () { + // Get new instance + $taskInstance = new Crawler???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/communicator/.htaccess b/application/hub/classes/tasks/crawler/communicator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/communicator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php b/application/hub/classes/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php new file mode 100644 index 000000000..3befcd344 --- /dev/null +++ b/application/hub/classes/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php @@ -0,0 +1,91 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerNodeCommunicatorTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerNodeCommunicatorTask () { + // Get new instance + $taskInstance = new CrawlerNodeCommunicatorTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the communicator instance + $communicatorInstance = CommunicatorFactory::createCommunicatorInstance('crawler_node_communicator_class', 'node'); + + // Get the current crawler state from registry + $stateInstance = Registry::getRegistry()->getInstance('crawler')->getStateInstance(); + + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); + + // We can now invoke that state instance and pass our communicator instance for generating some test units + $stateInstance->executeState($communicatorInstance); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/document_parser/.htaccess b/application/hub/classes/tasks/crawler/document_parser/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/document_parser/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/document_parser/class_CrawlerDocumentParserTask.php b/application/hub/classes/tasks/crawler/document_parser/class_CrawlerDocumentParserTask.php new file mode 100644 index 000000000..2091ecc4e --- /dev/null +++ b/application/hub/classes/tasks/crawler/document_parser/class_CrawlerDocumentParserTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerDocumentParserTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerDocumentParserTask () { + // Get new instance + $taskInstance = new CrawlerDocumentParserTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/mime_sniffer/.htaccess b/application/hub/classes/tasks/crawler/mime_sniffer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/mime_sniffer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/mime_sniffer/class_CrawlerMimeSnifferTask.php b/application/hub/classes/tasks/crawler/mime_sniffer/class_CrawlerMimeSnifferTask.php new file mode 100644 index 000000000..976835caf --- /dev/null +++ b/application/hub/classes/tasks/crawler/mime_sniffer/class_CrawlerMimeSnifferTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerMimeSnifferTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerMimeSnifferTask () { + // Get new instance + $taskInstance = new CrawlerMimeSnifferTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/ping/.htaccess b/application/hub/classes/tasks/crawler/ping/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/ping/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/ping/class_CrawlerPingTask.php b/application/hub/classes/tasks/crawler/ping/class_CrawlerPingTask.php new file mode 100644 index 000000000..879bb94c6 --- /dev/null +++ b/application/hub/classes/tasks/crawler/ping/class_CrawlerPingTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerPingTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerPingTask () { + // Get new instance + $taskInstance = new CrawlerPingTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/publisher/.htaccess b/application/hub/classes/tasks/crawler/publisher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/publisher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/publisher/class_CrawlerRemoteJobPublisherTask.php b/application/hub/classes/tasks/crawler/publisher/class_CrawlerRemoteJobPublisherTask.php new file mode 100644 index 000000000..73c5830d6 --- /dev/null +++ b/application/hub/classes/tasks/crawler/publisher/class_CrawlerRemoteJobPublisherTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerRemoteJobPublisherTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerRemoteJobPublisherTask () { + // Get new instance + $taskInstance = new CrawlerRemoteJobPublisherTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/scanner/.htaccess b/application/hub/classes/tasks/crawler/scanner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/scanner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/scanner/class_Crawler b/application/hub/classes/tasks/crawler/scanner/class_Crawler new file mode 100644 index 000000000..4418af42f --- /dev/null +++ b/application/hub/classes/tasks/crawler/scanner/class_Crawler @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Crawler???ScannerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawler???ScannerTask () { + // Get new instance + $taskInstance = new Crawler???ScannerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Call factory for a scanner instance and execute it + ScannerFactory::createScannerInstance($this)->execute(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/scanner/uploaded_list/.htaccess b/application/hub/classes/tasks/crawler/scanner/uploaded_list/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/scanner/uploaded_list/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/scanner/uploaded_list/class_CrawlerUploadedListScannerTask.php b/application/hub/classes/tasks/crawler/scanner/uploaded_list/class_CrawlerUploadedListScannerTask.php new file mode 100644 index 000000000..14bde83b3 --- /dev/null +++ b/application/hub/classes/tasks/crawler/scanner/uploaded_list/class_CrawlerUploadedListScannerTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUploadedListScannerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerUploadedListScannerTask () { + // Get new instance + $taskInstance = new CrawlerUploadedListScannerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Call factory for a scanner instance and execute it + ScannerObjectFactory::createScannerInstance($this)->execute(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/snippet_extractor/.htaccess b/application/hub/classes/tasks/crawler/snippet_extractor/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/snippet_extractor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/snippet_extractor/class_CrawlerSnippetExtractorTask.php b/application/hub/classes/tasks/crawler/snippet_extractor/class_CrawlerSnippetExtractorTask.php new file mode 100644 index 000000000..e884207b9 --- /dev/null +++ b/application/hub/classes/tasks/crawler/snippet_extractor/class_CrawlerSnippetExtractorTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerSnippetExtractorTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerSnippetExtractorTask () { + // Get new instance + $taskInstance = new CrawlerSnippetExtractorTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/structure_analyzer/.htaccess b/application/hub/classes/tasks/crawler/structure_analyzer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/structure_analyzer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/structure_analyzer/class_CrawlerStructureAnalyzerTask.php b/application/hub/classes/tasks/crawler/structure_analyzer/class_CrawlerStructureAnalyzerTask.php new file mode 100644 index 000000000..70215e802 --- /dev/null +++ b/application/hub/classes/tasks/crawler/structure_analyzer/class_CrawlerStructureAnalyzerTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerStructureAnalyzerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerStructureAnalyzerTask () { + // Get new instance + $taskInstance = new CrawlerStructureAnalyzerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/url_crawler/.htaccess b/application/hub/classes/tasks/crawler/url_crawler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_crawler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/url_crawler/local/.htaccess b/application/hub/classes/tasks/crawler/url_crawler/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_crawler/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/url_crawler/local/class_CrawlerLocalUrlCrawlerTask.php b/application/hub/classes/tasks/crawler/url_crawler/local/class_CrawlerLocalUrlCrawlerTask.php new file mode 100644 index 000000000..df4828a06 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_crawler/local/class_CrawlerLocalUrlCrawlerTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerLocalUrlCrawlerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerLocalUrlCrawlerTask () { + // Get new instance + $taskInstance = new CrawlerLocalUrlCrawlerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/url_crawler/remote/.htaccess b/application/hub/classes/tasks/crawler/url_crawler/remote/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_crawler/remote/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/url_crawler/remote/class_CrawlerRemoteUrlCrawlerTask.php b/application/hub/classes/tasks/crawler/url_crawler/remote/class_CrawlerRemoteUrlCrawlerTask.php new file mode 100644 index 000000000..6eebf1045 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_crawler/remote/class_CrawlerRemoteUrlCrawlerTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerRemoteUrlCrawlerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerRemoteUrlCrawlerTask () { + // Get new instance + $taskInstance = new CrawlerRemoteUrlCrawlerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/url_source/.htaccess b/application/hub/classes/tasks/crawler/url_source/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_source/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSource b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSource new file mode 100644 index 000000000..7134efc27 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSource @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUrlSource???Task extends BaseUrlSourceTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawler???Task () { + // Get new instance + $taskInstance = new Crawler???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get source instance + $sourceInstance = $this->getUrlSourceInstance(); + + // Is it not set? + if (is_null($sourceInstance)) { + // Initialize it + $this->initUrlSourceTask(); + + // And re-get it + $sourceInstance = $this->getUrlSourceInstance(); + } // END - if + + // Get the URL source instance and fill the stack with crawl entries + $sourceInstance->fillUrlStack(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php new file mode 100644 index 000000000..6059c56f5 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUrlSourceFoundRssTask extends BaseUrlSourceTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerUrlSourceFoundRssTask () { + // Get new instance + $taskInstance = new CrawlerUrlSourceFoundRssTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get source instance + $sourceInstance = $this->getUrlSourceInstance(); + + // Is it not set? + if (is_null($sourceInstance)) { + // Initialize it + $this->initUrlSourceTask(); + + // And re-get it + $sourceInstance = $this->getUrlSourceInstance(); + } // END - if + + // Get the URL source instance and fill the stack with crawl entries + $sourceInstance->fillUrlStack(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php new file mode 100644 index 000000000..04131e44d --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUrlSourceLocalStartTask extends BaseUrlSourceTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerUrlSourceLocalStartTask () { + // Get new instance + $taskInstance = new CrawlerUrlSourceLocalStartTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get source instance + $sourceInstance = $this->getUrlSourceInstance(); + + // Is it not set? + if (is_null($sourceInstance)) { + // Initialize it + $this->initUrlSourceTask(); + + // And re-get it + $sourceInstance = $this->getUrlSourceInstance(); + } // END - if + + // Get the URL source instance and fill the stack with crawl entries + $sourceInstance->fillUrlStack(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php new file mode 100644 index 000000000..5626afd80 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUrlSourceRssStartTask extends BaseUrlSourceTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerUrlSourceRssStartTask () { + // Get new instance + $taskInstance = new CrawlerUrlSourceRssStartTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get source instance + $sourceInstance = $this->getUrlSourceInstance(); + + // Is it not set? + if (is_null($sourceInstance)) { + // Initialize it + $this->initUrlSourceTask(); + + // And re-get it + $sourceInstance = $this->getUrlSourceInstance(); + } // END - if + + // Get the URL source instance and fill the stack with crawl entries + $sourceInstance->fillUrlStack(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php new file mode 100644 index 000000000..0b6b89176 --- /dev/null +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Crawler Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CrawlerUrlSourceUploadedListTask extends BaseUrlSourceTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCrawlerUrlSourceUploadedListTask () { + // Get new instance + $taskInstance = new CrawlerUrlSourceUploadedListTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get source instance + $sourceInstance = $this->getUrlSourceInstance(); + + // Is it not set? + if (is_null($sourceInstance)) { + // Initialize it + $this->initUrlSourceTask(); + + // And re-get it + $sourceInstance = $this->getUrlSourceInstance(); + } // END - if + + // Get the URL source instance and fill the stack with crawl entries + $sourceInstance->fillUrlStack(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/cruncher/.htaccess b/application/hub/classes/tasks/cruncher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/cruncher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/cruncher/class_Cruncher b/application/hub/classes/tasks/cruncher/class_Cruncher new file mode 100644 index 000000000..2c9cbf859 --- /dev/null +++ b/application/hub/classes/tasks/cruncher/class_Cruncher @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Cruncher???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createCruncher???Task () { + // Get new instance + $taskInstance = new Cruncher???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/cruncher/class_CruncherKeyProducerTask.php b/application/hub/classes/tasks/cruncher/class_CruncherKeyProducerTask.php new file mode 100644 index 000000000..a19428218 --- /dev/null +++ b/application/hub/classes/tasks/cruncher/class_CruncherKeyProducerTask.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherKeyProducerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public final static function createCruncherKeyProducerTask () { + // Get new instance + $taskInstance = new CruncherKeyProducerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the instance + $producerInstance = ProducerFactory::createProducerInstance('cruncher_key_producer_class', 'key'); + + // Get the current cruncher state from registry + $stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance(); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); + + // We can now invoke that state instance and pass our producer instance for generating some test units + $stateInstance->executeState($producerInstance); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/cruncher/class_CruncherTestUnitProducerTask.php b/application/hub/classes/tasks/cruncher/class_CruncherTestUnitProducerTask.php new file mode 100644 index 000000000..dc5aeb72c --- /dev/null +++ b/application/hub/classes/tasks/cruncher/class_CruncherTestUnitProducerTask.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherTestUnitProducerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public final static function createCruncherTestUnitProducerTask () { + // Get new instance + $taskInstance = new CruncherTestUnitProducerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the producer instance + $producerInstance = ProducerFactory::createProducerInstance('cruncher_test_unit_producer_class', 'test_unit'); + + // Get the current cruncher state from registry + $stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance(); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); + + // We can now invoke that state instance and pass our producer instance for generating some test units + $stateInstance->executeState($producerInstance); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php b/application/hub/classes/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php new file mode 100644 index 000000000..87068b0b2 --- /dev/null +++ b/application/hub/classes/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CruncherWorkUnitFetcherTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public final static function createCruncherWorkUnitFetcherTask () { + // Get new instance + $taskInstance = new CruncherWorkUnitFetcherTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + /* + * Get the cruncher instance and call a method which should check if + * the in-buffer is going to depleted. If so, new WUs are fetched from + * network or (if enabled in config) a random test WU is being + * generated. This test WU is for developing only or, if you like, to + * test your cruncher loop. + * + * Please report any bugs you encounter to me. + */ + Registry::getRegistry()->getInstance('cruncher')->doFetchWorkUnits(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/miner/.htaccess b/application/hub/classes/tasks/miner/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/miner/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/miner/block_fetcher/.htaccess b/application/hub/classes/tasks/miner/block_fetcher/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/miner/block_fetcher/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php b/application/hub/classes/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php new file mode 100644 index 000000000..22de1ae89 --- /dev/null +++ b/application/hub/classes/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerBlockFetcherTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public final static function createMinerBlockFetcherTask () { + // Get new instance + $taskInstance = new MinerBlockFetcherTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + /* + * Get the miner instance and call a method which should check if + * the in-buffer is going to depleted. If so, new WUs are fetched from + * network or (if enabled in config) a random test WU is being + * generated. This test WU is for developing only or, if you like, to + * test your miner loop. + * + * Please report any bugs you encounter to me. + */ + Registry::getRegistry()->getInstance('miner')->doSearchForBlocks(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/miner/block_producer/.htaccess b/application/hub/classes/tasks/miner/block_producer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/miner/block_producer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/miner/block_producer/class_MinerRealGenesisBlockProducerTask.php b/application/hub/classes/tasks/miner/block_producer/class_MinerRealGenesisBlockProducerTask.php new file mode 100644 index 000000000..7ca28a3ac --- /dev/null +++ b/application/hub/classes/tasks/miner/block_producer/class_MinerRealGenesisBlockProducerTask.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerRealGenesisBlockProducerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public final static function createMinerRealGenesisBlockProducerTask () { + // Get new instance + $taskInstance = new MinerRealGenesisBlockProducerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the producer instance + $producerInstance = ProducerFactory::createProducerInstance('miner_real_genesis_block_producer_class', 'real_unit'); + + // Get the current miner state from registry + $stateInstance = Registry::getRegistry()->getInstance('miner')->getStateInstance(); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); + + // We can now invoke that state instance and pass our producer instance for generating some test units + $stateInstance->executeState($producerInstance); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php b/application/hub/classes/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php new file mode 100644 index 000000000..0cdda15dc --- /dev/null +++ b/application/hub/classes/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerTestGenesisBlockProducerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public final static function createMinerTestGenesisBlockProducerTask () { + // Get new instance + $taskInstance = new MinerTestGenesisBlockProducerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the producer instance + $producerInstance = ProducerFactory::createProducerInstance('miner_test_genesis_block_producer_class', 'test_unit'); + + // Get the current miner state from registry + $stateInstance = Registry::getRegistry()->getInstance('miner')->getStateInstance(); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); + + // We can now invoke that state instance and pass our producer instance for generating some test units + $stateInstance->executeState($producerInstance); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/miner/class_Miner b/application/hub/classes/tasks/miner/class_Miner new file mode 100644 index 000000000..bc946d8a7 --- /dev/null +++ b/application/hub/classes/tasks/miner/class_Miner @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Miner???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createMiner???Task () { + // Get new instance + $taskInstance = new Miner???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/miner/communicator/.htaccess b/application/hub/classes/tasks/miner/communicator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/miner/communicator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php b/application/hub/classes/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php new file mode 100644 index 000000000..5f87718a2 --- /dev/null +++ b/application/hub/classes/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php @@ -0,0 +1,91 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2014 Miner Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MinerNodeCommunicatorTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createMinerNodeCommunicatorTask () { + // Get new instance + $taskInstance = new MinerNodeCommunicatorTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the communicator instance + $communicatorInstance = CommunicatorFactory::createCommunicatorInstance('miner_node_communicator_class', 'node'); + + // Get the current miner state from it + $stateInstance = $communicatorInstance->getStateInstance(); + + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); + + // We can now invoke that state instance and pass our communicator instance for generating some test units + $stateInstance->executeState($communicatorInstance); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/network/.htaccess b/application/hub/classes/tasks/network/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/network/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/network/class_NetworkPackage b/application/hub/classes/tasks/network/class_NetworkPackage new file mode 100644 index 000000000..0f649ccde --- /dev/null +++ b/application/hub/classes/tasks/network/class_NetworkPackage @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkPackage???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNetworkPackage???Task () { + // Get new instance + $taskInstance = new NetworkPackage???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php new file mode 100644 index 000000000..1cbbb8f93 --- /dev/null +++ b/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php @@ -0,0 +1,119 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createNetworkPackageReaderTask () { + // Get new instance + $taskInstance = new NetworkPackageReaderTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Also visit some sub-objects? + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // "Cache" package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Do we have something to handle? + if ($packageInstance->isProcessedMessagePending()) { + /* + * A previously proccessed message is waiting for being + * "interpreted". This is done by trying to find a configuration + * entry based on 'message_type' element. + */ + $packageInstance->handleProcessedMessage(); + } elseif ($packageInstance->isNewMessageArrived()) { + /* + * A fully "decoded" message has been received and added for being + * processed. Processing a message should not take long, so mostly + * this step involves reading all data through a XML template engine + * as "XML variables" from the content (which must be a well-formed + * XML) and then pushing it on the next stack "processed messages". + */ + $packageInstance->handleNewlyArrivedMessage(); + } elseif ($packageInstance->isIncomingRawDataHandled()) { + /* + * Incoming decoded data has been handled (see below) so it needs to + * be assembled back to a "package array". Please see NetworkPackage + * for further details (what array elements are required et cetera). + */ + $packageInstance->assembleDecodedDataToPackage(); + } elseif ($packageInstance->ifMultipleMessagesPending()) { + /* + * Some raw data contained multiple messages which where now splitted. + */ + $packageInstance->handleMultipleMessages(); + } elseif ($packageInstance->isNewRawDataPending()) { + // Raw, decoded data has been received + $packageInstance->handleIncomingDecodedData(); + } elseif ($packageInstance->ifAssemblerHasPendingDataLeft()) { + // Handle any pending data from the package assembler + $packageInstance->handleAssemblerPendingData(); + } // END - if + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/network/class_NetworkPackageWriterTask.php b/application/hub/classes/tasks/network/class_NetworkPackageWriterTask.php new file mode 100644 index 000000000..3f24ec0f6 --- /dev/null +++ b/application/hub/classes/tasks/network/class_NetworkPackageWriterTask.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createNetworkPackageWriterTask () { + // Get new instance + $taskInstance = new NetworkPackageWriterTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Also visit some sub-objects? + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // "Cache" package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Do we have something to deliver? + if ($packageInstance->isEncodedDataPending()) { + // Sent encoded (raw) data + $packageInstance->sendEncodedData(); + } elseif ($packageInstance->isPackageWaitingForDelivery()) { + // Sent it finally out + $packageInstance->sendWaitingPackage(); + } elseif ($packageInstance->isPackageDeclared()) { + // Prepare package for delivery + $packageInstance->processDeclaredPackage(); + } elseif ($packageInstance->isPackageEnqueued()) { + // Okay, then deliver (better discover its recipients) this package + $packageInstance->declareEnqueuedPackage(); + } + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/.htaccess b/application/hub/classes/tasks/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/announcement/.htaccess b/application/hub/classes/tasks/node/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/announcement/class_NodeAnnouncementTask.php b/application/hub/classes/tasks/node/announcement/class_NodeAnnouncementTask.php new file mode 100644 index 000000000..6ca0a0a71 --- /dev/null +++ b/application/hub/classes/tasks/node/announcement/class_NodeAnnouncementTask.php @@ -0,0 +1,81 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncementTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createNodeAnnouncementTask () { + // Get new instance + $taskInstance = new NodeAnnouncementTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the node instance and announce us + NodeObjectFactory::createNodeInstance()->announceToUpperNodes($this); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/chunks/.htaccess b/application/hub/classes/tasks/node/chunks/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/chunks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/chunks/class_NodeChunkAssemblerTask.php b/application/hub/classes/tasks/node/chunks/class_NodeChunkAssemblerTask.php new file mode 100644 index 000000000..da9edb417 --- /dev/null +++ b/application/hub/classes/tasks/node/chunks/class_NodeChunkAssemblerTask.php @@ -0,0 +1,116 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeChunkAssemblerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeChunkAssemblerTask () { + // Get new instance + $taskInstance = new NodeChunkAssemblerTask(); + + // Get a chunk handler instance + $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); + + // And add it to this task instance + $taskInstance->setHandlerInstance($handlerInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Also visit some sub-objects? + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // "Cache" handler instance + $handlerInstance = $this->getHandlerInstance(); + + // Are there chunks to handle or a final array to assemble? + if ($handlerInstance->ifUnassembledChunksAvailable()) { + /* + * Then do the final steps: + * + * 1) Sort the final array with ksort(). This will bring the "hash + * chunk" up to the last array index and the EOP chunk to the + * pre-last array index + * 2) Assemble all chunks except two last (see above step) + * 3) While so, do the final check on all hashes + * 4) If the package is assembled back together, hash it again for + * the very final verification. + */ + $handlerInstance->assembleChunksFromFinalArray(); + } elseif ($handlerInstance->ifUnhandledChunksWithFinalAvailable()) { + /* + * Then handle them (not all!). This should push all chunks into a + * 'final array' for last verification. + */ + $handlerInstance->handleAvailableChunksWithFinal(); + } elseif ($handlerInstance->ifRawPackageDataIsAvailable()) { + /* + * The final raw package data is back together again. So feed it + * into the next stack for further decoding/processing + */ + $handlerInstance->handledAssembledRawPackageData(); + } + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/class_Node b/application/hub/classes/tasks/node/class_Node new file mode 100644 index 000000000..b73ff490b --- /dev/null +++ b/application/hub/classes/tasks/node/class_Node @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNode???Task () { + // Get new instance + $taskInstance = new Node???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% done + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/decoder/.htaccess b/application/hub/classes/tasks/node/decoder/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/decoder/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/decoder/class_NodePackageDecoderTask.php b/application/hub/classes/tasks/node/decoder/class_NodePackageDecoderTask.php new file mode 100644 index 000000000..f12b2205e --- /dev/null +++ b/application/hub/classes/tasks/node/decoder/class_NodePackageDecoderTask.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodePackageDecoderTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodePackageDecoderTask () { + // Get new instance + $taskInstance = new NodePackageDecoderTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get a decoder instance + $decoderInstance = DecoderFactory::createPackageDecoderInstance(); + + // Check if the stacker has some entries left + if ($decoderInstance->ifUnhandledRawPackageDataLeft()) { + // Then handle it + $decoderInstance->handleRawPackageData(); + } elseif ($decoderInstance->ifDeocedPackagesLeft()) { + // Some decoded packages have arrived (for this peer) + $decoderInstance->handleDecodedPackage(); + } + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/dht/.htaccess b/application/hub/classes/tasks/node/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/dht/class_NodeDht b/application/hub/classes/tasks/node/dht/class_NodeDht new file mode 100644 index 000000000..74640b57d --- /dev/null +++ b/application/hub/classes/tasks/node/dht/class_NodeDht @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDht???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeDht???Task () { + // Get new instance + $taskInstance = new NodeDht???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% done + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtBootstrapTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtBootstrapTask.php new file mode 100644 index 000000000..a794cafa7 --- /dev/null +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtBootstrapTask.php @@ -0,0 +1,87 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtBootstrapTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeDhtBootstrapTask () { + // Get new instance + $taskInstance = new NodeDhtBootstrapTask(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Let the DHT class do the work for us + $this->getDhtInstance()->bootstrapDht(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtInitializationTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtInitializationTask.php new file mode 100644 index 000000000..6485392f7 --- /dev/null +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtInitializationTask.php @@ -0,0 +1,87 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtInitializationTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeDhtInitializationTask () { + // Get new instance + $taskInstance = new NodeDhtInitializationTask(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Intiailize the DHT + $this->getDhtInstance()->initDht(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtLateBootstrapTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtLateBootstrapTask.php new file mode 100644 index 000000000..367a3d813 --- /dev/null +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtLateBootstrapTask.php @@ -0,0 +1,87 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtLateBootstrapTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeDhtLateBootstrapTask () { + // Get new instance + $taskInstance = new NodeDhtLateBootstrapTask(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Let the DHT class do the work for us + $this->getDhtInstance()->bootstrapDht(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php new file mode 100644 index 000000000..48da0743c --- /dev/null +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtPublicationCheckTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeDhtPublicationCheckTask () { + // Get new instance + $taskInstance = new NodeDhtPublicationCheckTask(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo Add more? + */ + public function executeTask () { + // Get DHT instance + $dhtInstance = $this->getDhtInstance(); + + // Has the DHT some unpublished entries? + if (($dhtInstance->hasFullyBootstrapped()) && ($dhtInstance->hasUnpublishedEntries())) { + // Then initiate publishing them + $dhtInstance->initEntryPublication(); + } // END - if + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php new file mode 100644 index 000000000..813e4e2ad --- /dev/null +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtPublicationTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeDhtPublicationTask () { + // Get new instance + $taskInstance = new NodeDhtPublicationTask(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo Add more? + */ + public function executeTask () { + // Get DHT instance + $dhtInstance = $this->getDhtInstance(); + + // Has the DHT some entries pending publication? + if ($dhtInstance->hasEntriesPendingPublication()) { + // Then publish next entry + $dhtInstance->publishEntry(); + } // END - if + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php new file mode 100644 index 000000000..503f0474d --- /dev/null +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodeDhtQueryTask () { + // Get new instance + $taskInstance = new NodeDhtQueryTask(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo ~5% done + */ + public function executeTask () { + // Get DHT instance + $dhtInstance = $this->getDhtInstance(); + + // Are there "INSERT" node data entries? + if ($dhtInstance->ifInsertNodeDataPending()) { + // Then insert a single entry + $dhtInstance->insertSingleNodeData(); + } // END - if + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/listener/.htaccess b/application/hub/classes/tasks/node/listener/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/listener/class_NodeSocketListenerTask.php b/application/hub/classes/tasks/node/listener/class_NodeSocketListenerTask.php new file mode 100644 index 000000000..6bf9901eb --- /dev/null +++ b/application/hub/classes/tasks/node/listener/class_NodeSocketListenerTask.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeSocketListenerTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createNodeSocketListenerTask () { + // Get new instance + $taskInstance = new NodeSocketListenerTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Get the node instance from registry + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Visit the pool listener task + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('LISTENER-TASK[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...'); + $nodeInstance->getListenerPoolInstance()->accept($visitorInstance); + + // Visit this task + // @TODO Do we need to visit this task? $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% done + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/ping/.htaccess b/application/hub/classes/tasks/node/ping/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/ping/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/ping/class_NodePingTask.php b/application/hub/classes/tasks/node/ping/class_NodePingTask.php new file mode 100644 index 000000000..4457e98d1 --- /dev/null +++ b/application/hub/classes/tasks/node/ping/class_NodePingTask.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodePingTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A Listable instance + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createNodePingTask (Listable $listInstance) { + // Get new instance + $taskInstance = new NodePingTask(); + + // Se the list instance in this task + $taskInstance->setListInstance($listInstance); + + // Init ping iterator instance + $iteratorInstance = $listInstance->getListIterator(); + + // Set it as well + $taskInstance->setIteratorInstance($iteratorInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Also visit some sub-objects? + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% done + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/self_connect/.htaccess b/application/hub/classes/tasks/node/self_connect/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/self_connect/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/self_connect/class_NodeSelfConnectTask.php b/application/hub/classes/tasks/node/self_connect/class_NodeSelfConnectTask.php new file mode 100644 index 000000000..8a7d99fb1 --- /dev/null +++ b/application/hub/classes/tasks/node/self_connect/class_NodeSelfConnectTask.php @@ -0,0 +1,81 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeSelfConnectTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createNodeSelfConnectTask () { + // Get new instance + $taskInstance = new NodeSelfConnectTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get the node instance and try it + NodeObjectFactory::createNodeInstance()->doSelfConnection($this); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/tags/.htaccess b/application/hub/classes/tasks/node/tags/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/tags/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/tags/class_NodePackageTagsInitTask.php b/application/hub/classes/tasks/node/tags/class_NodePackageTagsInitTask.php new file mode 100644 index 000000000..e183bedd3 --- /dev/null +++ b/application/hub/classes/tasks/node/tags/class_NodePackageTagsInitTask.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodePackageTagsInitTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNodePackageTagsInitTask () { + // Get new instance + $taskInstance = new NodePackageTagsInitTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Get a factory instance and do no more as this loads the object (tags) registry + $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/tasks/node/update/.htaccess b/application/hub/classes/tasks/node/update/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tasks/node/update/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tasks/node/update/class_NodeUpdateCheckTask.php b/application/hub/classes/tasks/node/update/class_NodeUpdateCheckTask.php new file mode 100644 index 000000000..49eeef88f --- /dev/null +++ b/application/hub/classes/tasks/node/update/class_NodeUpdateCheckTask.php @@ -0,0 +1,81 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeUpdateCheckTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createNodeUpdateCheckTask () { + // Get new instance + $taskInstance = new NodeUpdateCheckTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo 0% + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/.htaccess b/application/hub/classes/template/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/announcement/.htaccess b/application/hub/classes/template/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php new file mode 100644 index 000000000..5c528e852 --- /dev/null +++ b/application/hub/classes/template/announcement/class_XmlAnnouncementTemplateEngine.php @@ -0,0 +1,358 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id'; + const ANNOUNCEMENT_DATA_NODE_ID = 'node-id'; + const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; + const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status'; + const ANNOUNCEMENT_DATA_NODE_MODE = 'node-mode'; + const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'external-address'; + const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'internal-address'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + 'announcement-data', + 'listener', + self::ANNOUNCEMENT_DATA_NODE_STATUS, + self::ANNOUNCEMENT_DATA_NODE_MODE, + self::ANNOUNCEMENT_DATA_NODE_ID, + self::ANNOUNCEMENT_DATA_SESSION_ID, + self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, + self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, + 'object-type-list', + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlAnnouncementTemplateEngine () { + // Get a new instance + $templateInstance = new XmlAnnouncementTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'announcement'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_announcement'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the announcement + * + * @return void + */ + protected function startAnnouncement () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'announcement'); + } + + /** + * Starts the announcement data + * + * @return void + */ + protected function startAnnouncementData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'announcement-data'); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'listener'); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_SESSION_ID); + } + + /** + * Starts the node id + * + * @return void + */ + protected function startNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_ID); + } + + /** + * Starts the private key hash + * + * @return void + */ + protected function startPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the private ip + * + * @return void + */ + protected function startInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the object type list + * + * @return void + */ + protected function startObjectTypeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'object-type-list'); + } + + /** + * Starts the object type + * + * @return void + */ + protected function startObjectType () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement', 'object-type'); + } + + /** + * Finishes the object type + * + * @return void + */ + protected function finishObjectType () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the object type list + * + * @return void + */ + protected function finishObjectTypeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the private key hash + * + * @return void + */ + protected function finishPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the node id + * + * @return void + */ + protected function finishNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the private ip + * + * @return void + */ + protected function finishInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the announcement data + * + * @return void + */ + protected function finishAnnouncementData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } + + /** + * Finishes the announcement + * + * @return void + */ + protected function finishAnnouncement () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/answer/.htaccess b/application/hub/classes/template/answer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/answer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/answer/announcement/.htaccess b/application/hub/classes/template/answer/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/answer/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php new file mode 100644 index 000000000..87ed8fa54 --- /dev/null +++ b/application/hub/classes/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -0,0 +1,406 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const ANNOUNCEMENT_DATA_NODE_ID = 'my-node-id'; + const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id'; + const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; + const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status'; + const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address'; + const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub-nodes array + $this->setSubNodes(array( + // These nodes don't contain any data + 'my-data', + 'your-data', + // Data from *this* node + self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, + self::ANNOUNCEMENT_DATA_NODE_STATUS, + self::ANNOUNCEMENT_DATA_NODE_ID, + self::ANNOUNCEMENT_DATA_SESSION_ID, + self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, + // Data from other node + 'your-external-address', + 'your-internal-address', + 'your-node-id', + 'your-session-id', + 'your-private-key-hash', + // Answer status (generic field) + self::ANSWER_STATUS, + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlAnnouncementAnswerTemplateEngine () { + // Get a new instance + $templateInstance = new XmlAnnouncementAnswerTemplateEngine(); + + // Init instance + $templateInstance->initXmlTemplateEngine('node', 'announcement_answer'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getAnnouncementAnswerCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the announcement-answer + * + * @return void + */ + protected function startAnnouncementAnswer () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer'); + } + + /** + * Starts the my-data + * + * @return void + */ + protected function startMyData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data'); + } + + /** + * Starts the my-external-address + * + * @return void + */ + protected function startMyExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the my-internal-address + * + * @return void + */ + protected function startMyInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the my-node-id + * + * @return void + */ + protected function startMyNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_ID); + } + + /** + * Starts the my-session-id + * + * @return void + */ + protected function startMySessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID); + } + + /** + * Starts the my-private-key-hash + * + * @return void + */ + protected function startMyPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the my-status + * + * @return void + */ + protected function startMyStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS); + } + + /** + * Finishes the my-status + * + * @return void + */ + protected function finishMyStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-private-key-hash + * + * @return void + */ + protected function finishMyPrivateKeyhash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-session-id + * + * @return void + */ + protected function finishMySessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-node-id + * + * @return void + */ + protected function finishMyNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-internal-address + * + * @return void + */ + protected function finishMyInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-external-address + * + * @return void + */ + protected function finishMyExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the my-data + * + * @return void + */ + protected function finishMyData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Starts the your-data + * + * @return void + */ + protected function startYourData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data'); + } + + /** + * Starts the your-external-address + * + * @return void + */ + protected function startYourExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address'); + } + + /** + * Starts the your-internal-address + * + * @return void + */ + protected function startYourInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address'); + } + + /** + * Starts the your-session-id + * + * @return void + */ + protected function startYourSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id'); + } + + /** + * Starts the your-node-id + * + * @return void + */ + protected function startYourNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-node-id'); + } + + /** + * Starts the your-private-key-hash + * + * @return void + */ + protected function startYourPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-private-key-hash'); + } + + /** + * Finishes the your-private-key-hash + * + * @return void + */ + protected function finishYourPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-node-id + * + * @return void + */ + protected function finishYourNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-session-id + * + * @return void + */ + protected function finishYourSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-internal-address + * + * @return void + */ + protected function finishYourInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-external-address + * + * @return void + */ + protected function finishYourExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the your-data + * + * @return void + */ + protected function finishYourData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } + + /** + * Finishes the announcement-answer + * + * @return void + */ + protected function finishAnnouncementAnswer () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_announcement_answer'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/answer/class_ b/application/hub/classes/template/answer/class_ new file mode 100644 index 000000000..7aba4b38d --- /dev/null +++ b/application/hub/classes/template/answer/class_ @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXml???TemplateEngine () { + // Get a new instance + $templateInstance = new Xml???TemplateEngine(); + + // Init template instannce + $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + // Assign data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function get???CacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the ||| + * + * @return void + */ + protected function start??? () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('!!!', '|||'); + } + + /** + * Finishes the ||| + * + * @return void + */ + protected function finish??? () { + // Pop the last entry + $this->getStackInstance()->popNamed('!!!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php b/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php new file mode 100644 index 000000000..261d834d1 --- /dev/null +++ b/application/hub/classes/template/answer/class_BaseXmlAnswerTemplateEngine.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Generic 'answer-status' field + */ + const ANSWER_STATUS = 'answer-status'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Starts the answer-status + * + * @return void + */ + protected function startAnswerStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed($this->getStackerName(), self::ANSWER_STATUS); + } + + /** + * Finishes the answer-status + * + * @return void + */ + protected function finishAnswerStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed($this->getStackerName()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/answer/dht/.htaccess b/application/hub/classes/template/answer/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/answer/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php new file mode 100644 index 000000000..38a46461a --- /dev/null +++ b/application/hub/classes/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php @@ -0,0 +1,384 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const DHT_BOOTSTRAP_DATA_SESSION_ID = 'my-session-id'; + const DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; + const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'my-status'; + const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'my-external-address'; + const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'my-internal-address'; + const DHT_BOOTSTRAP_DATA_NODE_LIST = 'dht-nodes-list'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub-nodes array + $this->setSubNodes(array( + // These nodes don't contain any data + 'my-data', + 'your-data', + // Data from *this* node + self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_NODE_STATUS, + self::DHT_BOOTSTRAP_DATA_SESSION_ID, + // Data from other node + 'your-external-address', + 'your-internal-address', + 'your-session-id', + // Answer status (generic field) + self::ANSWER_STATUS, + // DHT node list + self::DHT_BOOTSTRAP_DATA_NODE_LIST, + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlDhtBootstrapAnswerTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtBootstrapAnswerTemplateEngine(); + + // Init instance + $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap_answer'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_dht_bootstrap_answer'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getDhtBootstrapAnswerCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the dht_bootstrap-answer + * + * @return void + */ + protected function startDhtBootstrapAnswer () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'dht_bootstrap-answer'); + } + + /** + * Starts the my-data + * + * @return void + */ + protected function startMyData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'my-data'); + } + + /** + * Starts the my-external-address + * + * @return void + */ + protected function startMyExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the my-internal-address + * + * @return void + */ + protected function startMyInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the my-session-id + * + * @return void + */ + protected function startMySessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_SESSION_ID); + } + + /** + * Starts the my-private-key-hash + * + * @return void + */ + protected function startMyPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the my-status + * + * @return void + */ + protected function startMyStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); + } + + /** + * Starts the dht-nodes-list + * + * @return void + */ + protected function startDhtNodesList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_LIST); + } + + /** + * Finishes the dht-nodes-list + * + * @return void + */ + protected function finishDhtNodesList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-status + * + * @return void + */ + protected function finishMyStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-private-key-hash + * + * @return void + */ + protected function finishMyPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-session-id + * + * @return void + */ + protected function finishMySessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-internal-address + * + * @return void + */ + protected function finishMyInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-external-address + * + * @return void + */ + protected function finishMyExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the my-data + * + * @return void + */ + protected function finishMyData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Starts the your-data + * + * @return void + */ + protected function startYourData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-data'); + } + + /** + * Starts the your-external-address + * + * @return void + */ + protected function startYourExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-external-address'); + } + + /** + * Starts the your-internal-address + * + * @return void + */ + protected function startYourInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-internal-address'); + } + + /** + * Starts the your-session-id + * + * @return void + */ + protected function startYourSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-session-id'); + } + + /** + * Starts the your-private-key-hash + * + * @return void + */ + protected function startYourPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-private-key-hash'); + } + + /** + * Finishes the your-private-key-hash + * + * @return void + */ + protected function finishYourPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-session-id + * + * @return void + */ + protected function finishYourSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-internal-address + * + * @return void + */ + protected function finishYourInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-external-address + * + * @return void + */ + protected function finishYourExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the your-data + * + * @return void + */ + protected function finishYourData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } + + /** + * Finishes the dht_bootstrap-answer + * + * @return void + */ + protected function finishDhtBootstrapAnswer () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/answer/requests/.htaccess b/application/hub/classes/template/answer/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/answer/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php new file mode 100644 index 000000000..681078334 --- /dev/null +++ b/application/hub/classes/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php @@ -0,0 +1,172 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + // Constants for array elements + const REQUEST_DATA_SESSION_ID = 'session-id'; + const REQUEST_DATA_NODE_LIST = 'node-list'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub-nodes array + $this->setSubNodes(array( + self::REQUEST_DATA_SESSION_ID, + self::REQUEST_DATA_NODE_LIST, + // Answer status (generic field) + self::ANSWER_STATUS, + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlRequestNodeListAnswerTemplateEngine () { + // Get a new instance + $templateInstance = new XmlRequestNodeListAnswerTemplateEngine(); + + // Init instance + $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer'); + + // Get a template instance for list entries (as they are dynamic) + $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class'); + + // Set it here + $templateInstance->setTemplateInstance($entriesInstance); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_answer'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getRequestNodeListAnswerCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the 'request-node-list-answer' + * + * @return void + */ + protected function startRequestNodeListAnswer () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer'); + } + + /** + * Starts the session-id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_SESSION_ID); + } + + /** + * Starts the node-list + * + * @return void + */ + protected function startNodeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_NODE_LIST); + } + + /** + * Finishes the node-list + * + * @return void + */ + protected function finishNodeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_answer'); + } + + /** + * Finishes the session-id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_answer'); + } + + /** + * Finishes the 'request-node-list-answer' + * + * @return void + */ + protected function finishRequestNodeListAnswer () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_answer'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/class_ b/application/hub/classes/template/class_ new file mode 100644 index 000000000..a36aad5f5 --- /dev/null +++ b/application/hub/classes/template/class_ @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXml???TemplateEngine () { + // Get a new instance + $templateInstance = new Xml???TemplateEngine(); + + // Init template instannce + $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + // Assign data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function get???CacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the ||| + * + * @return void + */ + protected function start??? () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('!!!', '|||'); + } + + /** + * Finishes the ||| + * + * @return void + */ + protected function finish??? () { + // Pop the last entry + $this->getStackInstance()->popNamed('!!!'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/class_BaseXmlTemplateEngine.php b/application/hub/classes/template/class_BaseXmlTemplateEngine.php new file mode 100644 index 000000000..6fca12e7c --- /dev/null +++ b/application/hub/classes/template/class_BaseXmlTemplateEngine.php @@ -0,0 +1,326 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseXmlTemplateEngine extends BaseTemplateEngine { + /** + * Main nodes in the XML tree + */ + private $mainNodes = array(); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array(); + + /** + * Current main node + */ + private $curr = array(); + + /** + * XML template type + */ + private $xmlTemplateType = 'xml'; + + /** + * Type prefix + */ + private $typePrefix = 'xml'; + + /** + * Name of stacker + */ + private $stackerName = ''; + + /** + * Content from dependency + */ + protected $dependencyContent = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Does a generic initialization of the template engine + * + * @param $typePrefix Type prefix + * @param $xmlTemplateType Type of XML template + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + protected function initXmlTemplateEngine ($typePrefix, $xmlTemplateType) { + // Get template instance + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Determine base path + $templateBasePath = $this->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; + + // Is the base path valid? + if (empty($templateBasePath)) { + // Base path is empty + throw new BasePathIsEmptyException($this, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($templateBasePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($this, $templateBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($templateBasePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($this, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($templateBasePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($this, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $this->setTemplateBasePath($templateBasePath); + + // Set template extensions + $this->setRawTemplateExtension($this->getConfigInstance()->getConfigEntry('raw_template_extension')); + $this->setCodeTemplateExtension($this->getConfigInstance()->getConfigEntry($typePrefix . '_message_template_extension')); + + // Absolute output path for compiled templates + $this->setCompileOutputPath($this->getConfigInstance()->getConfigEntry('base_path') . $this->getConfigInstance()->getConfigEntry('compile_output_path')); + + // Init a variable stacker + $stackInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class'); + + // Set name + $this->stackerName = $typePrefix . '_' . $xmlTemplateType; + + // Init stacker + $stackInstance->initStack($this->stackerName); + + // Set it + $this->setStackInstance($stackInstance); + + // Set XML template type and prefix + $this->xmlTemplateType = $xmlTemplateType; + $this->typePrefix = $typePrefix; + + // Set it in main nodes + array_push($this->mainNodes, str_replace('_', '-', $xmlTemplateType)); + } + + /** + * Load a specified XML template into the engine + * + * @param $templateName Optional name of template + * @return void + */ + public function loadXmlTemplate ($templateName = '') { + // Is the template name empty? + if (empty($templateName)) { + // Set generic template name + $templateName = $this->typePrefix . '_' . $this->xmlTemplateType . '_template_type'; + } // END - if + + // Set template type + $this->setTemplateType($this->getConfigInstance()->getConfigEntry($templateName)); + + // Load the special template + $this->loadTemplate($this->xmlTemplateType); + } + + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->curr['main_node']; + } + + /** + * Setter for current main node + * + * @param $element Element name to set as current main node + * @return $currMainNode Current main node + */ + private final function setCurrMainNode ($element) { + $this->curr['main_node'] = (string) $element; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for stacker name + * + * @return $stackerName Name of stacker of this class + */ + protected final function getStackerName () { + return $this->stackerName; + } + + /** + * Setter for sub node array + * + * @param $subNodes Array with valid sub node names + * @return void + */ + public final function setSubNodes (array $subNodes) { + $this->subNodes = $subNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + + /** + * Read XML variables by calling readVariable() with 'general' as + * variable stack. + * + * @param $key Key to read from + * @return $value Value from variable + */ + public function readXmlData ($key) { + // Read the variable + $value = parent::readVariable($key, 'general'); + + // Is this null? + if (is_null($value)) { + // Bah, needs fixing. + $this->debugInstance('key=' . $key . ' returns NULL'); + } // END - if + + // Return value + return $value; + } + + /** + * Handles the template dependency for given XML node + * + * @param $node The XML node we should load a dependency template + * @param $templateDependency A template to load to satisfy dependencies + * @return void + */ + protected function handleTemplateDependency ($node, $templateDependency) { + // Check that the XML node is not empty + assert(!empty($node)); + + // Is the template dependency set? + if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { + // Get a temporay template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '_' . self::convertDashesToUnderscores($node) . '_' . $this->xmlTemplateType . '_template_class'); + + // Then load it + $templateInstance->loadXmlTemplate($templateDependency); + + // Parse the XML content + $templateInstance->renderXmlContent(); + + // Save the parsed raw content in our dependency array + $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); + } // END - if + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + public final function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = 'init' . self::convertToClassName($this->xmlTemplateType); + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + //* DEBUG: */ echo "START: >".$element."<
\n"; + if (in_array($element, $this->getMainNodes())) { + // Okay, main node found! + $methodName = 'start' . self::convertToClassName($element); + + // Set it + $this->setCurrMainNode($element); + } elseif (in_array($element, $this->getSubNodes())) { + // Sub node found + $methodName = 'start' . self::convertToClassName($element); + } else { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + public final function finishElement ($resource, $nodeName) { + // Make all lower-case + $nodeName = strtolower($nodeName); + + // Does this match with current main node? + //* DEBUG: */ echo "END: >".$nodeName."<
\n"; + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { + // Did not match! + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); + } // END - if + + // Construct method name + $methodName = 'finish' . self::convertToClassName($nodeName); + + // Call the corresponding method + //* DEBUG: */ echo "call: ".$methodName."
\n"; + call_user_func_array(array($this, $methodName), array()); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/connect/.htaccess b/application/hub/classes/template/connect/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/connect/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php new file mode 100644 index 000000000..543fc7251 --- /dev/null +++ b/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php @@ -0,0 +1,187 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Data nodes + */ + const SELF_CONNECT_DATA_NODE_ID = 'node-id'; + const SELF_CONNECT_DATA_SESSION_ID = 'session-id'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + 'self-connect-data', + self::SELF_CONNECT_DATA_NODE_ID, + self::SELF_CONNECT_DATA_SESSION_ID + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlSelfConnectTemplateEngine () { + // Get a new instance + $templateInstance = new XmlSelfConnectTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'self_connect'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name + */ + parent::assignVariable($this->getStackInstance()->getNamed('node_self_connect'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the self_connect + * + * @return void + */ + protected function startSelfConnect () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect'); + } + + /** + * Starts the self_connect data + * + * @return void + */ + protected function startSelfConnectData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect-data'); + } + + /** + * Starts the node id + * + * @return void + */ + protected function startNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_NODE_ID); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_SESSION_ID); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } + + /** + * Finishes the node id + * + * @return void + */ + protected function finishNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } + + /** + * Finishes the self_connect data + * + * @return void + */ + protected function finishSelfConnectData () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } + + /** + * Finishes the self_connect + * + * @return void + */ + protected function finishSelfConnect () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_self_connect'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/dht/.htaccess b/application/hub/classes/template/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php new file mode 100644 index 000000000..c99756b53 --- /dev/null +++ b/application/hub/classes/template/dht/class_XmlDhtBootstrapTemplateEngine.php @@ -0,0 +1,274 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data'; + const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id'; + const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; + const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; + const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address'; + const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA, + 'listener', + self::DHT_BOOTSTRAP_DATA_NODE_STATUS, + self::DHT_BOOTSTRAP_DATA_NODE_MODE, + self::DHT_BOOTSTRAP_DATA_SESSION_ID, + self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlDhtBootstrapTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtBootstrapTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('dht_bootstrap'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the dht bootstrap + * + * @return void + */ + protected function startDhtBootstrap () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', 'dht-bootstrap'); + } + + /** + * Starts the dht bootstrap data + * + * @return void + */ + protected function startDhtBootstrapData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener'); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the private ip + * + * @return void + */ + protected function startInternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_SESSION_ID); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the private ip + * + * @return void + */ + protected function finishInternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the dht bootstrap data + * + * @return void + */ + protected function finishDhtBootstrapData () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the dht bootstrap + * + * @return void + */ + protected function finishDhtBootstrap () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_bootstrap'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/entries/.htaccess b/application/hub/classes/template/entries/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/entries/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php new file mode 100644 index 000000000..bc95609ec --- /dev/null +++ b/application/hub/classes/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php @@ -0,0 +1,111 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlRequestNodeListEntryTemplateEngine () { + // Get a new instance + $templateInstance = new XmlRequestNodeListEntryTemplateEngine(); + + // Init template instannce + $templateInstance->initXmlTemplateEngine('node', 'request_node_list_entry'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Assign data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_entry'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getRequestNodeListEntryCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the request-node-list-entry + * + * @return void + */ + protected function startRequestNodeListEntry () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list_entry', 'request-node-list-entry'); + } + + /** + * Finishes the request-node-list-entry + * + * @return void + */ + protected function finishRequestNodeListEntry () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list_entry'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/objects/.htaccess b/application/hub/classes/template/objects/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/objects/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php new file mode 100644 index 000000000..2ca364a20 --- /dev/null +++ b/application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php @@ -0,0 +1,288 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + // Constants + const OBJECT_TYPE_DATA_NAME = 'object-name'; + const OBJECT_TYPE_DATA_RECIPIENT_LIMITATION = 'object-recipient-limitation'; + const OBJECT_TYPE_DATA_MAX_SPREAD = 'object-max-spread'; + const OBJECT_TYPE_DATA_PROTOCOL = 'object-protocol'; + const OBJECT_TYPE_DATA_RECIPIENT_TYPE = 'object-recipient-type'; + + /** + * Instance for the object registry + */ + private $objectRegistryInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init object type registry instance + $this->objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); + + // Init sub nodes + $this->setSubNodes(array( + 'object-list', + 'object-list-entry', + self::OBJECT_TYPE_DATA_NAME, + self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION, + self::OBJECT_TYPE_DATA_MAX_SPREAD, + self::OBJECT_TYPE_DATA_PROTOCOL, + self::OBJECT_TYPE_DATA_RECIPIENT_TYPE + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlObjectRegistryTemplateEngine () { + // Get a new instance + $templateInstance = new XmlObjectRegistryTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'object_registry'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Get current XML node name as an array index + $nodeName = $this->getStackInstance()->getNamed('node_object_registry'); + + // Is the node name self::OBJECT_TYPE_DATA_NAME? + if ($nodeName == self::OBJECT_TYPE_DATA_NAME) { + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Adding object type ' . $characters . ' to registry.'); + } // END - if + + // Add it to the registry + $this->objectRegistryInstance->addEntry($nodeName, $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getObjectRegistryCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the object-registry + * + * @return void + */ + protected function startObjectRegistry () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', 'object-registry'); + } + + /** + * Starts the object-list + * + * @param $objectCount Count of all objects + * @return void + * @todo Handle $objectCount + */ + protected function startObjectList ($objectCount) { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', 'object-list'); + } + + /** + * Starts the object-list-entry + * + * @return void + */ + protected function startObjectListEntry () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', 'object-list-entry'); + } + + /** + * Starts the object-name + * + * @return void + */ + protected function startObjectName () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_NAME); + } + + /** + * Starts the object-recipient-limitation + * + * @return void + */ + protected function startObjectRecipientLimitation () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION); + } + + /** + * Starts the object-max-spread + * + * @return void + */ + protected function startObjectMaxSpread () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_MAX_SPREAD); + } + + /** + * Starts the object-protocol + * + * @return void + */ + protected function startObjectProtocol () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_PROTOCOL); + } + + /** + * Starts the object-recipient-type + * + * @return void + */ + protected function startObjectRecipientType () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_TYPE); + } + + /** + * Finishes the object-recipient-type + * + * @return void + */ + protected function finishObjectRecipientType () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-protocol + * + * @return void + */ + protected function finishObjectProtocol () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-max-spread + * + * @return void + */ + protected function finishObjectMaxSpread () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-recipient-limitation + * + * @return void + */ + protected function finishObjectRecipientLimitation () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-name + * + * @return void + */ + protected function finishObjectName () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-list-entry + * + * @return void + */ + protected function finishObjectListEntry () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-list + * + * @return void + */ + protected function finishObjectList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } + + /** + * Finishes the object-registry + * + * @return void + */ + protected function finishObjectRegistry () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_object_registry'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/producer/.htaccess b/application/hub/classes/template/producer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/producer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/producer/test_units/.htaccess b/application/hub/classes/template/producer/test_units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/producer/test_units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php new file mode 100644 index 000000000..40f19412d --- /dev/null +++ b/application/hub/classes/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php @@ -0,0 +1,369 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub nodes + $this->setSubNodes(array( + 'meta-data', + 'global-project-identifier', + 'test-unit-created', + 'cipher', + 'cipher-function', + 'cipher-name', + 'unprocessed-data', + 'encrypted-message', + 'cruncher-key-list', + 'cruncher-key', + 'key-id', + 'key-value' + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlCruncherTestUnitTemplateEngine () { + // Get a new instance + $templateInstance = new XmlCruncherTestUnitTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('cruncher', 'test_unit'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Assign the found characters to variable and use the last entry from + // stack as the name + parent::assignVariable($this->getStackInstance()->getNamed('cruncher_test_unit'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getCruncherTestUnitCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the test-unit + * + * @return void + */ + protected function startTestUnit () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit'); + } + + /** + * Starts the meta-data + * + * @return void + */ + protected function startMetaData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'meta-data'); + } + + /** + * Starts the global-project-identifier + * + * @return void + */ + protected function startGlobalProjectIdentifier () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier'); + } + + /** + * Finishes the global-project-identifier + * + * @return void + */ + protected function finishGlobalProjectIdentifier () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the test-unit-created + * + * @return void + */ + protected function startTestUnitCreated () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'test-unit-created'); + } + + /** + * Finishes the test-unit-created + * + * @return void + */ + protected function finishTestUnitCreated () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the cipher + * + * @return void + */ + protected function startCipher () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher'); + } + + /** + * Starts the cipher-function + * + * @return void + */ + protected function startCipherFunction () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-function'); + } + + /** + * Finishes the cipher-function + * + * @return void + */ + protected function finishCipherFunction () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the cipher-name + * + * @return void + */ + protected function startCipherName () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-name'); + } + + /** + * Finishes the cipher-name + * + * @return void + */ + protected function finishCipherName () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the cipher + * + * @return void + */ + protected function finishCipher () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the meta-data + * + * @return void + */ + protected function finishMetaData () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the unprocessed-data + * + * @return void + */ + protected function startUnprocessedData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data'); + } + + /** + * Starts the encrypted-message + * + * @return void + */ + protected function startEncryptedMessage () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'encrypted-message'); + } + + /** + * Finishes the encrypted-message + * + * @return void + */ + protected function finishEncryptedMessage () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the cruncher-key-list + * + * @param $keyCount Count of keys in this test unit + * @return void + * @todo Handle $keyCount + */ + protected function startCruncherKeyList ($keyCount) { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list'); + } + + /** + * Starts the cruncher-key + * + * @return void + */ + protected function startCruncherKey () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key'); + } + + /** + * Starts the key-id + * + * @return void + */ + protected function startKeyId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-id'); + } + + /** + * Finishes the key-id + * + * @return void + */ + protected function finishKeyId () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Starts the key-value + * + * @return void + */ + protected function startKeyValue () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-value'); + } + + /** + * Finishes the key-value + * + * @return void + */ + protected function finishKeyValue () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the cruncher-key + * + * @return void + */ + protected function finishCruncherKey () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the cruncher-key-list + * + * @return void + */ + protected function finishCruncherKeyList () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the unprocessed-data + * + * @return void + */ + protected function finishUnprocessedData () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } + + /** + * Finishes the test-unit + * + * @return void + */ + protected function finishTestUnit () { + // Pop the last entry + $this->getStackInstance()->popNamed('cruncher_test_unit'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/producer/work_units/.htaccess b/application/hub/classes/template/producer/work_units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/producer/work_units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/publish/.htaccess b/application/hub/classes/template/publish/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/publish/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php new file mode 100644 index 000000000..167857f0e --- /dev/null +++ b/application/hub/classes/template/publish/class_XmlDhtPublishEntryTemplateEngine.php @@ -0,0 +1,358 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const PUBLISH_DATA_NODE_ID = 'node-id'; + const PUBLISH_DATA_SESSION_ID = 'session-id'; + const PUBLISH_DATA_NODE_STATUS = 'node-status'; + const PUBLISH_DATA_NODE_MODE = 'node-mode'; + const PUBLISH_DATA_EXTERNAL_ADDRESS = 'external-address'; + const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; + const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->setSubNodes(array( + 'publish-data', + 'listener', + self::PUBLISH_DATA_NODE_STATUS, + self::PUBLISH_DATA_NODE_MODE, + self::PUBLISH_DATA_PRIVATE_KEY_HASH, + self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES, + self::PUBLISH_DATA_NODE_ID, + self::PUBLISH_DATA_SESSION_ID, + self::PUBLISH_DATA_EXTERNAL_ADDRESS, + 'object-type-list', + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlDhtPublishEntryTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtPublishEntryTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'dht_publish'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackInstance()->getNamed('dht_publish'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the publish + * + * @return void + */ + protected function startPublish () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'publish'); + } + + /** + * Starts the publish data + * + * @return void + */ + protected function startPublishData () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'publish-data'); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'listener'); + } + + /** + * Starts accepted object types + * + * @return void + */ + protected function startAcceptedObjectTypes () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES); + } + + /** + * Starts hash from private key + * + * @return void + */ + protected function startPrivateKeyHash () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_PRIVATE_KEY_HASH); + } + + /** + * Starts the node id + * + * @return void + */ + protected function startNodeId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_ID); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_SESSION_ID); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalAddress () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_ADDRESS); + } + + /** + * Starts the object type list + * + * @return void + */ + protected function startObjectTypeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'object-type-list'); + } + + /** + * Starts the object type + * + * @return void + */ + protected function startObjectType () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('dht_publish', 'object-type'); + } + + /** + * Finishes the object type + * + * @return void + */ + protected function finishObjectType () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the object type list + * + * @return void + */ + protected function finishObjectTypeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node id + * + * @return void + */ + protected function finishNodeId () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalAddress () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes hash from private key + * + * @return void + */ + protected function finishPrivateKeyHash () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes accepted object types + * + * @return void + */ + protected function finishAcceptedObjectTypes () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the publish data + * + * @return void + */ + protected function finishPublishData () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } + + /** + * Finishes the publish + * + * @return void + */ + protected function finishPublish () { + // Pop the last entry + $this->getStackInstance()->popNamed('dht_publish'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/requests/.htaccess b/application/hub/classes/template/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php new file mode 100644 index 000000000..23b16636c --- /dev/null +++ b/application/hub/classes/template/requests/class_XmlRequestNodeListTemplateEngine.php @@ -0,0 +1,161 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + // Constants for array elements + const REQUEST_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; + const REQUEST_DATA_SESSION_ID = 'session-id'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init sub nodes + $this->setSubNodes(array( + self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, + self::REQUEST_DATA_SESSION_ID, + )); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlRequestNodeListTemplateEngine () { + // Get a new instance + $templateInstance = new XmlRequestNodeListTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'request_node_list'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Assign data with matching variable here + parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getRequestNodeListCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the node-request-node-list + * + * @return void + */ + protected function startRequestNodeList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list', 'node-request-node-list'); + } + + /** + * Starts the accepted-object-types + * + * @return void + */ + protected function startAcceptedObjectTypes () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES); + } + + /** + * Starts the session-id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_SESSION_ID); + } + + /** + * Finishes the session-id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list'); + } + + /** + * Finishes the accepted-object-types + * + * @return void + */ + protected function finishAcceptedObjectTypes () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list'); + } + + /** + * Finishes the node-request-node-list + * + * @return void + */ + protected function finishRequestNodeList () { + // Pop the last entry + $this->getStackInstance()->popNamed('node_request_node_list'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/template/work_units/.htaccess b/application/hub/classes/template/work_units/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/template/work_units/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tools/.htaccess b/application/hub/classes/tools/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/tools/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/tools/class_HubTools.php b/application/hub/classes/tools/class_HubTools.php new file mode 100644 index 000000000..988fa7a4d --- /dev/null +++ b/application/hub/classes/tools/class_HubTools.php @@ -0,0 +1,323 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HubTools extends BaseHubSystem { + // Constants for exceptions + const EXCEPTION_SESSION_ID_IS_INVALID = 0x200; + const EXCEPTION_HOSTNAME_NOT_FOUND = 0x201; + + /** + * Cache for session ids + */ + private $sessionIdCache = array(); + + /** + * Length for session id (should be 32+salt_length + */ + private $sessionIdLength = 0; + + /** + * Self instance + */ + private static $selfInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set it here + $this->setDhtInstance($dhtInstance); + + // Init salt length + $this->sessionIdLength = 32 + $this->getConfigInstance()->getConfigEntry('salt_length'); + } + + /** + * Singleton getter for self instance + * + * @retuen $selfInstance An instance of this class + */ + public static final function getSelfInstance () { + // Is the instance set + if (is_null(self::$selfInstance)) { + // Then set it + self::$selfInstance = new HubTools(); + } // END - if + + // Return own instance + return self::$selfInstance; + } + + /** + * Getter for session id length + * + * @return $sessionIdLength Length of session ids + */ + protected final function getSessionIdLength () { + return $this->sessionIdLength; + } + + /** + * Resolves a session id into an instance of a LocateableNode class. The opposite method + * is resolveSessionIdByUniversalNodeLocator() + * + * @param $sessionId A valid session id + * @return $recipientUniversalNodeLocator Recipient as Universal Node Locator + */ + protected function resolveUniversalNodeLocatorBySessionId ($sessionId) { + // Init variable + $recipientUniversalNodeLocator = 'invalid://invalid:invalid'; + + // And ask it for Universal Node Locator by given session id + $recipient = $this->getDhtInstance()->findNodeLocalBySessionId($sessionId); + //* DEBUG-DIE: */ die(__METHOD__ . ': UNFINISHED: recipient[' . gettype($recipient) . ']=' . print_r($recipient, TRUE) . ',sessionId=' . $sessionId . PHP_EOL); + + // Is the recipient valid? + if (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) { + // Then use this + $recipientUniversalNodeLocator = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]; + } else { + // Get the instance, this might throw a NPE + $nodeInstance = NodeObjectFactory::createNodeInstance(); + + // Is the session id the same? + if ($nodeInstance->getSessionId() == $sessionId) { + // Then get an instance of a LocateableNode class from it, assume TCP by default + $recipientUniversalNodeLocator = self::determineOwnExternalAddress() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port'); + } // END - if + } + + // Return result + return $recipientUniversalNodeLocator; + } + + /** + * Resolves a session id into a node id by asking local DHT. + * + * @param $sessionId Session id + * @return $nodeId Node id + */ + public static function resolveNodeIdBySessionId ($sessionId) { + // Get an own instance + $selfInstance = self::getSelfInstance(); + + // And ask it for session id by given Universal Node Locator + $nodeData = $selfInstance->getDhtInstance()->findNodeLocalBySessionId($sessionId); + + // Make sure the node id is there + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE)); + assert(isset($nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID])); + + // Return it + return $nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID]; + } + + /** + * Resolves a Universal Node Locator into a session id. The "opposite" method + * is resolveUniversalNodeLocatorBySessionId(). + * + * @param $unlInstance Universal Node Locator + * @return $sessionId Valid session id + */ + public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $unlInstance) { + // Get an own instance + $selfInstance = self::getSelfInstance(); + + // And ask it for session id by given Universal Node Locator + $recipient = $selfInstance->getDhtInstance()->findNodeByUniversalNodeLocator($unlInstance); + die(__METHOD__.':recipient='.print_r($recipient, TRUE)); + + // Return result + return $sessionId; + } + + /** + * Resolves given session id into an instance of a LocateableNode class, if Universal Node Locator is set, it won't be translated + * + * @param $address Session id or Universal Node Locator + * @return $recipient Recipient as Universal Node Locator + * @throws InvalidSessionIdException If the provided session id is invalid (and no Universal Node Locator) + * @throws NoValidHostnameException If the provided hostname cannot be resolved into an IP address + */ + public static function resolveSessionId ($address) { + // Get an own instance + $selfInstance = self::getSelfInstance(); + + // Default is direct Universal Node Locator + $recipient = $address; + + // Does it match a direct Universal Node Locator? (hint: see www.regexlib.com for the regular expression) + if (preg_match('/([a-z0-9]{3,10})\/\/:([a-z0-9\.]{5,})/', $address)) { + // @TODO ((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])):([0-9]{3,5}) + // Direct Universal Node Locator found + self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Direct Universal Node Locator ' . $address . ' detected.'); + } elseif (isset($selfInstance->sessionIdCache[$address])) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using entry from sessionIdCache[] array.'); + + // Found in cache! + $recipient = $selfInstance->sessionIdCache[$address]; + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: sessionIdCache[' . $address . ']=' . $recipient); + } elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $address)) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using internal session id resolver.'); + + // Resolve session id into an instance of a LocateableNode class + $recipient = $selfInstance->resolveUniversalNodeLocatorBySessionId($address); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Session id ' . $address . ' resolved to ' . $recipient); + } else { + // Invalid session id/UNL + throw new InvalidSessionIdException($address, self::EXCEPTION_SESSION_ID_IS_INVALID); + } + + // Return it + return $recipient; + } + + /** + * Determine UNL or 'external_address' if set + * + * @return $unl The determined external UNL of this node + */ + public static function determineOwnExternalAddress () { + // Is the external_address config entry set? + if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_address') != '') { + // Use it as external address + $unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_address'); + } else { + // Determine own external address by connecting to my (coder) server at 188.138.90.169 + $unl = self::determineExternalUniversalNodeLocator(); + } + + // Return it + return $unl; + } + + /** + * Determine UNL or 'internal_address' if set + * + * @return $unl The determined internal UNL of this node + */ + public static function determineOwnInternalAddress () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Is the internal_address config entry set? + if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('allow_publish_internal_address') == 'N') { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...'); + + // Not allowed to publish internal address, so use external + $unl = self::determineOwnExternalAddress(); + } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address') != '') { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Getting config entry internal_address ...'); + + // Use it as internal address + $unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address'); + } else { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Calling self::determineInternalUniversalNodeLocator() ...'); + + // Determine own internal address + $unl = self::determineInternalUniversalNodeLocator(); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ' - EXIT!'); + + // Return it + return $unl; + } + + /** + * Determines the UNL (Universal Node Locator) for the internal address + * + * @return $internalUnl Internal UNL + */ + public static function determineInternalUniversalNodeLocator () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Is there cache? (This shortens a lot calls) + if (!isset($GLOBALS[__METHOD__])) { + // Determine UNL based on this node: + // 1) Get discovery class + $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class'); + + // 2) "Determine" it + $GLOBALS[__METHOD__] = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('internal'); + + // Make sure it is valid + // @TODO Find a better validation than empty() + assert(!empty($GLOBALS[__METHOD__])); + } // END - if + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); + return $GLOBALS[__METHOD__]; + } + + /** + * Determines the UNL (Universal Node Locator) for the external address + * + * @return $externalUnl External UNL + */ + public static function determineExternalUniversalNodeLocator () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + + // Is there cache? (This shortens a lot calls) + if (!isset($GLOBALS[__METHOD__])) { + // Determine UNL based on this node: + // 1) Get discovery class + $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class'); + + // 2) "Determine" it + $GLOBALS[__METHOD__] = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('external'); + + // Make sure it is valid + // @TODO Find a better validation than empty() + assert(!empty($GLOBALS[__METHOD__])); + } // END - if + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); + return $GLOBALS[__METHOD__]; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/unl/.htaccess b/application/hub/classes/unl/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/unl/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/unl/class_UniversalNodeLocator.php b/application/hub/classes/unl/class_UniversalNodeLocator.php new file mode 100644 index 000000000..5064328fd --- /dev/null +++ b/application/hub/classes/unl/class_UniversalNodeLocator.php @@ -0,0 +1,108 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UniversalNodeLocator extends BaseFrameworkSystem implements LocateableNode { + //------- UNL parts ------- + // Protocol + const UNL_PART_PROTOCOL = 'protocol'; + // Address + const UNL_PART_ADDRESS = 'address'; + // Extra part + const UNL_PART_EXTRA = 'extra'; + // Port (if any) + const UNL_PART_PORT = 'port'; + + /** + * UNL data array + */ + private $unlData = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional. + * @return $unlInstance An instance of a LocateableNode class + */ + public final static function createUniversalNodeLocator (array $current = array()) { + // Get new instance + $unlInstance = new UniversalNodeLocator(); + + // Init instance + $unlInstance->initUniversalNodeLocator($current); + + // Return the prepared instance + return $unlInstance; + } + + /** + * Initializes the UNL instance by givena array. If an entry is found, it + * will be copied, otherwise the entry is set empty. + * + * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional. + * @return void + */ + private function initUniversalNodeLocator (array $current = array()) { + // Init UNL array + $this->unlData = array(); + + // Copy all found entries + foreach (array( + NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, + NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, + NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, + NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, + NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, + NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) { + // Init entry + $this->unlData[$key] = NULL; + + // Is the key found? + if (isset($current[$key])) { + // The copy the entry + $this->unlData[$key] = $current[$key]; + } // END - if + } // END - foreach + } + + /** + * Getter for UNL data array + * + * @return $unlData An array with UNL data + */ + public final function getUnlData () { + return $this->unlData; + } +} + +// [EOF] +?> diff --git a/application/hub/classes/visitor/.htaccess b/application/hub/classes/visitor/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/visitor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/visitor/pool/.htaccess b/application/hub/classes/visitor/pool/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/visitor/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/visitor/pool/class_ b/application/hub/classes/visitor/pool/class_ new file mode 100644 index 000000000..4f7674896 --- /dev/null +++ b/application/hub/classes/visitor/pool/class_ @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Visitor extends BaseVisitor implements PoolVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('???'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function create???Visitor () { + // Get new instance + $visitorInstance = new ???Visitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + * @todo 0% + */ + public function visitPool (Poolable $poolInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/visitor/pool/handler/.htaccess b/application/hub/classes/visitor/pool/handler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/visitor/pool/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/visitor/pool/handler/class_Handler b/application/hub/classes/visitor/pool/handler/class_Handler new file mode 100644 index 000000000..56d71dccc --- /dev/null +++ b/application/hub/classes/visitor/pool/handler/class_Handler @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Handler???Visitor extends BaseVisitor implements PoolVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('handler'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function createHandler???Visitor () { + // Get new instance + $visitorInstance = new Handler???Visitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + * @todo 0% + */ + public function visitPool (Poolable $poolInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/visitor/pool/monitor/.htaccess b/application/hub/classes/visitor/pool/monitor/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/visitor/pool/monitor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php b/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php new file mode 100644 index 000000000..630360f5e --- /dev/null +++ b/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, ListenerVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('monitor'); + } + + /** + * Creates an instance of this class + * + * @param $receiverInstance An instance of a Receivable class + * @return $visitorInstance An instance of a Visitorable class + */ + public final static function createRawDataPoolMonitorVisitor () { + // Get new instance + $visitorInstance = new RawDataPoolMonitorVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + */ + public function visitPool (Poolable $poolInstance) { + // A pool doesn't normally have any raw data waiting + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: poolInstance=' . $poolInstance->__toString() . ' - CALLED!'); + } + + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + public function visitListener (Listenable $listenerInstance) { + /* + * The listener itself cannot distinguish between node and client + * traffic. This is why we don't call its monitorIncomingRawData() + * method. + */ + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); + } + + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A decorator instance + * @return void + */ + public function visitDecorator (BaseDecorator $decoratorInstance) { + // Do monitor here + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - CALLED!'); + $decoratorInstance->monitorIncomingRawData(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - FINISH'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/visitor/pool/shutdown/.htaccess b/application/hub/classes/visitor/pool/shutdown/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/visitor/pool/shutdown/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/visitor/pool/shutdown/class_Shutdown b/application/hub/classes/visitor/pool/shutdown/class_Shutdown new file mode 100644 index 000000000..d85f52e97 --- /dev/null +++ b/application/hub/classes/visitor/pool/shutdown/class_Shutdown @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub; Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Shutdown???Visitor extends BaseVisitor implements PoolVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('shutdown'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function createShutdown???Visitor () { + // Get new instance + $visitorInstance = new Shutdown???Visitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + * @todo 0% + */ + public function visitPool (Poolable $poolInstance) { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php b/application/hub/classes/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php new file mode 100644 index 000000000..758f97b91 --- /dev/null +++ b/application/hub/classes/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('shutdown'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public static final function createShutdownListenerPoolVisitor () { + // Get new instance + $visitorInstance = new ShutdownListenerPoolVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + */ + public function visitPool (Poolable $poolInstance) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $poolInstance->__toString() . ' - CALLED!'); + + // Pre-shutdown the pool + $poolInstance->preShutdown(); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $poolInstance->__toString() . ' - EXIT!'); + } + + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A Listenable decorator instance + * @return void + */ + public function visitDecorator (Listenable $decoratorInstance) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $decoratorInstance->__toString() . ' - CALLED!'); + + // Pre-shutdown the pool + $decoratorInstance->doShutdown(); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $decoratorInstance->__toString() . ' - EXIT!'); + } + + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable class instance + * @return void + */ + public function visitListener (Listenable $listenerInstance) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $listenerInstance->__toString() . ' - CALLED!'); + + // Pre-shutdown the pool + $listenerInstance->doShutdown(); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $listenerInstance->__toString() . ' - EXIT!'); + } +} + +// +?> diff --git a/application/hub/classes/visitor/socket/.htaccess b/application/hub/classes/visitor/socket/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/classes/visitor/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/classes/visitor/socket/class_HalfShutdownSocketVisitor.php b/application/hub/classes/visitor/socket/class_HalfShutdownSocketVisitor.php new file mode 100644 index 000000000..41f743324 --- /dev/null +++ b/application/hub/classes/visitor/socket/class_HalfShutdownSocketVisitor.php @@ -0,0 +1,87 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HalfShutdownSocketVisitor extends BaseVisitor implements Visitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('socket'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public static final function createHalfShutdownSocketVisitor () { + // Get new instance + $visitorInstance = new HalfShutdownSocketVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * "Visit" method to do the actual request. Here we want to shutdown the + * attached socket. + * + * @param $helperInstance An instance of a ConnectionHelper class + * @return void + */ + public function visitConnectionHelper (ConnectionHelper $helperInstance) { + // Do we have reached the retry count? + if (ConnectionStatisticsHelper::isConnectRetryExhausted($helperInstance)) { + // Also visit the network package to clear any out-going packages + NetworkPackageFactory::createNetworkPackageInstance()->accept($this); + + // Still shutdown the visitor (look in visitNetworkPackage() for details) + $helperInstance->doShutdown(); + } else { + // We can still move on and retry the connection attempt + ConnectionStatisticsHelper::increaseConnectRetry($helperInstance); + } + } + + /** + * "Visit" method to do the actual request. This method does remove the last + * failed package from the stack because all retries are fully exhausted + * (see visitConnectionHelper() for the logic). + * + * @param $packageInstance An instance of a Deliverable class + * @return void + */ + public function visitNetworkPackage (Deliverable $packageInstance) { + // Just call it back + $packageInstance->removeFirstFailedPackage(); + } +} + +// [EOF] +?> diff --git a/application/hub/classes/visitor/socket/class_ShutdownSocketVisitor.php b/application/hub/classes/visitor/socket/class_ShutdownSocketVisitor.php new file mode 100644 index 000000000..7196f8356 --- /dev/null +++ b/application/hub/classes/visitor/socket/class_ShutdownSocketVisitor.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ShutdownSocketVisitor extends BaseVisitor implements Visitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('socket'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public static final function createShutdownSocketVisitor () { + // Get new instance + $visitorInstance = new ShutdownSocketVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * "Visit" method to do the actual request. Here we want to shutdown the + * attached socket. + * + * @param $helperInstance An instance of a ConnectionHelper class + * @return void + */ + public function visitConnectionHelper (ConnectionHelper $helperInstance) { + // Do we have reached the retry count? + if (ConnectionStatisticsHelper::isConnectRetryExhausted($helperInstance)) { + // Also visit the network package to clear any out-going packages + NetworkPackageFactory::createNetworkPackageInstance()->accept($this); + + // Shutdown the connection + $helperInstance->doShutdown(); + } else { + // We can still move on and retry the connection attempt + ConnectionStatisticsHelper::increaseConnectRetry($helperInstance); + } + } + + /** + * "Visit" method to do the actual request. Here we want to "partly shutdown" + * the network package instance to clear all stacks. + * + * @param $packageInstance An instance of a Deliverable class + * @return void + */ + public function visitNetworkPackage (Deliverable $packageInstance) { + // Just call it back + $packageInstance->clearAllStacks(); + } + + /** + * "Visit" the assembler instance. This shall clear any pending data + * + * @param $assemblerInstance An instance of a Assembler class + * @return void + */ + public function visitAssembler (Assembler $assemblerInstance) { + // Clear pending data + $assemblerInstance->clearPendingData(); + } +} + +// [EOF] +?> diff --git a/application/hub/config-local.php-dist b/application/hub/config-local.php-dist index 3525a612a..554d7a265 100644 --- a/application/hub/config-local.php-dist +++ b/application/hub/config-local.php-dist @@ -57,5 +57,8 @@ $cfg->setConfigEntry('hub_bootstrap_nodes', 'tcp://188.138.90.169:9060'); // CFG: ENABLE-FEATURE-HUBCOINS-REWARD // Disable this if you don't want to "earn" HubCoins: $cfg->setConfigEntry('enable_feature_hubcoins_reward', 'N'); +// CFG: ENABLE-FEATURE-FUSE +// Enable this, if you have fuse.dll/so installed and want to access your node: $cfg->setConfigEntry('enable_feature_fuse', 'Y'); + // [EOF] ?> diff --git a/application/hub/config.php b/application/hub/config.php index b4c67a00e..027b48348 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -45,9 +45,6 @@ $cfg->setConfigEntry('tpl_engine', 'ConsoleOutput'); // CFG: OUTPUT-CLASS $cfg->setConfigEntry('output_class', 'DebugConsoleOutput'); -// CFG: DEBUG-CLASS -$cfg->setConfigEntry('debug_class', 'DebugConsoleOutput'); - // CFG: NODE-INFO-DB-WRAPPER-CLASS $cfg->setConfigEntry('node_info_db_wrapper_class', 'NodeInformationDatabaseWrapper'); @@ -357,9 +354,6 @@ $cfg->setConfigEntry('node_dht_bootstrap_template_type', 'xml/dht_bootstrap'); // CFG: DHT-PUBLISH-TEMPLATE-TYPE $cfg->setConfigEntry('node_dht_publish_template_type', 'xml/dht_publish'); -// CFG: CODE-TEMPLATE-TYPE -$cfg->setConfigEntry('code_template_type', 'xml'); - // CFG: RAW-TEMPLATE-EXTENSION (to speed-up things) $cfg->setConfigEntry('raw_template_extension', '.xml'); @@ -793,9 +787,6 @@ $cfg->setConfigEntry('node_raw_data_output_stream_class', 'RawDataOutputStream') // CFG: NODE-RAW-DATA-INPUT-STREAM-CLASS $cfg->setConfigEntry('node_raw_data_input_stream_class', 'RawDataInputStream'); -// CFG: DEBUG-OUTPUT-TIMINGS -$cfg->setConfigEntry('debug_output_timings', 'Y'); - // CFG: SOCKET-TIMEOUT-SECONDS $cfg->setConfigEntry('socket_timeout_seconds', 3); @@ -1487,19 +1478,6 @@ $cfg->setConfigEntry('crawler_csv_file_path', 'data/url_lists'); // CFG: CRAWLER-URL-LIST-COLUMN-SEPARATOR $cfg->setConfigEntry('crawler_url_list_column_separator', ','); -/////////////////////////////////////////////////////////////////////////////// -// HTTP Configuration -/////////////////////////////////////////////////////////////////////////////// - -// CFG: DEFAULT-WEB-COMMAND -$cfg->setConfigEntry('default_web_command', 'home'); - -// CFG: WEB-CMD-HOME-RESOLVER-CLASS -$cfg->setConfigEntry('web_cmd_home_resolver_class', 'WebCommandResolver'); - -// CFG: NEWS-HOME-LIMIT -$cfg->setConfigEntry('news_home_limit', 10); - /////////////////////////////////////////////////////////////////////////////// // Apt-Proxy Configuration /////////////////////////////////////////////////////////////////////////////// @@ -1543,5 +1521,49 @@ $cfg->setConfigEntry('task_apt_proxy_listener_interval_delay', 10); // CFG: TASK-APT-PROXY-LISTENER-MAX-RUNS $cfg->setConfigEntry('task_apt_proxy_listener_max_runs', 0); +/////////////////////////////////////////////////////////////////////////////// +// HTML interface // +/////////////////////////////////////////////////////////////////////////////// + +// CFG: DEFAULT-HUB-HTML-COMMAND +$cfg->setConfigEntry('default_hub_html_command', 'index'); + +// CFG: DEFAULT-HTML-CONTROLLER +$cfg->setConfigEntry('default_html_controller', 'index'); + +// CFG: HTML-CMD-INDEX-RESOLVER-CLASS +$cfg->setConfigEntry('html_cmd_index_resolver_class', 'HubHtmlCommandResolver'); + +// CFG: NEWS-READER-INDEX-CLASS +$cfg->setConfigEntry('news_reader_index_class', 'DefaultNewsReader'); + +// CFG: NEWS-INDEX-LIMIT +$cfg->setConfigEntry('news_index_limit', 10); + +// CFG: HUB-INDEX-MENU-CLASS +$cfg->setConfigEntry('hub_index_menu_class', 'HubIndexMenu'); + +// CFG: HTML-FORM-HELPER +$cfg->setConfigEntry('html_form_helper_class', 'HtmlFormHelper'); + +// CFG: FORM-ACTION +$cfg->setConfigEntry('form_action', 'index.php?app={?app_short_name?}&command=do_form'); + +// CFG: FORM-METHOD +$cfg->setConfigEntry('form_method', 'post'); + +// CFG: FORM-TARGET +$cfg->setConfigEntry('form_target', '_self'); + +/////////////////////////////////////////////////////////////////////////////// +// Virtual file system with FUSE // +/////////////////////////////////////////////////////////////////////////////// + +// CFG: HUB-CONSOLE-CMD-FUSE-RESOLVER-CLASS +$cfg->setConfigEntry('hub_console_cmd_fuse_resolver_class', 'ConsoleCommandResolver'); + +// CFG: ENABLE-FEATURE-FUSE +$cfg->setConfigEntry('enable_feature_fuse', 'N'); + // [EOF] ?> diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index d5339b1a6..8eefa5ea5 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -33,11 +33,14 @@ function hub_exception_handler ($exceptionInstance) { // Init argument string $argsString = ''; - // Convert arguments type into human-readable - foreach ($traceArray['args'] as $arg) { - $argsString .= ', ' . gettype($arg); - } // END - foreach - $argsString = substr($argsString, 2); + // Any arguments? + if ((isset($traceArray['args'])) && (is_array($traceArray['args'])) && (count($traceArray['args']) > 0)) { + // Convert arguments type into human-readable + foreach ($traceArray['args'] as $arg) { + $argsString .= ', ' . gettype($arg); + } // END - foreach + $argsString = substr($argsString, 2); + } // END - if // Set missing file/line if (!isset($traceArray['file'])) $traceArray['file'] = 'unknown'; diff --git a/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php b/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php index 33bfea6b8..474d86e2b 100644 --- a/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php +++ b/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php @@ -35,7 +35,7 @@ class DhtBootstrapNotAcceptedException extends FrameworkException { $message = sprintf('[%s:%d] This node (%s) is not accepting DHT bootstrap requests, but got one from session-id=%s,unl=%s/%s,status=%s,mode=%s', $messageArray[0]->__toString(), $this->getLine(), - $messageArray[0]->getNodeInstance()->__toString(), + NodeObjectFactory::createNodeInstance()->__toString(), $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID], $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS], $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS], diff --git a/application/hub/init.php b/application/hub/init.php index 8699bacb7..1c750dc76 100644 --- a/application/hub/init.php +++ b/application/hub/init.php @@ -37,7 +37,7 @@ require($cfg->getConfigEntry('base_path') . 'inc/database.php'); // Get own internal address and set it in config $cfg->setConfigEntry('internal_address', HubTools::determineOwnInternalAddress()); -// By default scrypt is assumed (and later tested) NOT being there +// By default scrypt is assumed absent and later tested being there $cfg->setConfigEntry('extension_scrypt_loaded', FALSE); // [EOF] diff --git a/application/hub/language/.htaccess b/application/hub/language/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/.htaccess b/application/hub/main/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/apt-proxy/.htaccess b/application/hub/main/apt-proxy/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/apt-proxy/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/apt-proxy/class_ b/application/hub/main/apt-proxy/class_ deleted file mode 100644 index 2ec43314b..000000000 --- a/application/hub/main/apt-proxy/class_ +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Node???AptProxy extends BaseNodeAptProxy implements AptProxyter { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $proxyInstance An instance of a AptProxyter class - */ - public final static function createNode???AptProxy () { - // Get new instance - $proxyInstance = new Node???AptProxy(); - - // Return the prepared instance - return $proxyInstance; - } - - /** - * Method to "bootstrap" the apt-proxy. This step does also apply provided - * command-line arguments stored in the request instance. You should now - * get it from calling $this->getRequestInstance(). - * - * @return void - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - $this->partialStub('Please implement this method.'); - } - - /** - * Add some apt-proxy-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/apt-proxy/class_BaseNodeAptProxy.php b/application/hub/main/apt-proxy/class_BaseNodeAptProxy.php deleted file mode 100644 index c372b2e26..000000000 --- a/application/hub/main/apt-proxy/class_BaseNodeAptProxy.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseNodeAptProxy extends BaseHubSystem { - /** - * Whether this apt-proxy is active - */ - private $isActive = FALSE; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Enables/disables the apt-proxy (just sets a flag) - * - * @param $version Version number of this apt-proxy - * @return void - */ - public final function enableIsActive ($isActive = TRUE) { - $this->isActive = (bool) $isActive; - } - - /** - * Determines whether the apt-proxy is active - * - * @return $isActive Whether the apt-proxy is active - */ - public final function isActive () { - return $this->isActive; - } -} - -// [EOF] -?> diff --git a/application/hub/main/apt-proxy/console/.htaccess b/application/hub/main/apt-proxy/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/apt-proxy/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/apt-proxy/console/class_NodeConsoleAptProxy.php b/application/hub/main/apt-proxy/console/class_NodeConsoleAptProxy.php deleted file mode 100644 index 06c91a534..000000000 --- a/application/hub/main/apt-proxy/console/class_NodeConsoleAptProxy.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeConsoleAptProxy extends BaseNodeAptProxy implements AptProxy, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $proxyInstance An instance of a AptProxy class - */ - public final static function createNodeConsoleAptProxy () { - // Get new instance - $proxyInstance = new NodeConsoleAptProxy(); - - // Return the prepared instance - return $proxyInstance; - } - - /** - * Method to "bootstrap" the apt-proxy. This step does also apply provided - * command-line arguments stored in the request instance. You should now - * get it from calling $this->getRequestInstance(). - * - * @return void - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - // Get the app instance (for shortening our code) - $app = $this->getApplicationInstance(); - - // Output all lines - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - An apt-proxy connection helper'); - self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2012 Apt-Proxy Developer Team'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); - self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); - self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - } - - /** - * Add some apt-proxy-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/blocks/.htaccess b/application/hub/main/blocks/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/blocks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/blocks/class_ b/application/hub/main/blocks/class_ deleted file mode 100644 index 0053d45cc..000000000 --- a/application/hub/main/blocks/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Block extends BaseBlock implements === { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $blockInstance An instance of a === class - */ - public final static function create???Block () { - // Get new instance - $blockInstance = new ???Block(); - - // Return the prepared instance - return $blockInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/blocks/class_BaseBlock.php b/application/hub/main/blocks/class_BaseBlock.php deleted file mode 100644 index 9425bf744..000000000 --- a/application/hub/main/blocks/class_BaseBlock.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseBlock extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/blocks/miner/.htaccess b/application/hub/main/blocks/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/blocks/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/blocks/miner/class_HashBlock.php b/application/hub/main/blocks/miner/class_HashBlock.php deleted file mode 100644 index ef8e3f979..000000000 --- a/application/hub/main/blocks/miner/class_HashBlock.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HashBlock extends BaseBlock implements Minable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $blockInstance An instance of a Minable class - */ - public final static function createHashBlock () { - // Get new instance - $blockInstance = new HashBlock(); - - // Return the prepared instance - return $blockInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/chains/.htaccess b/application/hub/main/chains/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/chains/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/chains/class_PackageFilterChain.php b/application/hub/main/chains/class_PackageFilterChain.php deleted file mode 100644 index c79b62ef9..000000000 --- a/application/hub/main/chains/class_PackageFilterChain.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageFilterChain extends FilterChain { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $chainInstance An instance of this class - */ - public static final function createPackageFilterChain () { - // Get a new instance - $chainInstance = new PackageFilterChain(); - - // Return the prepared instance - return $chainInstance; - } - - /** - * Processes the given raw message content through all filters - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - * @todo This may be slow if a message with a lot tags arrived - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Get all filters and "run" them - foreach ($this->getFilters() as $filterInstance) { - // Try to process it - try { - $filterInstance->processMessage($messageData, $packageInstance); - } catch (FilterChainException $e) { - // This exception can be thrown to just skip any further processing - self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); - break; - } - } // END - foreach - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function postProcessMessage (Receivable $packageInstance) { - // Get all filters and "run" them - foreach ($this->getPostFilters() as $filterInstance) { - // Try to process it - try { - $filterInstance->postProcessMessage($packageInstance); - } catch (FilterChainException $e) { - // This exception can be thrown to just skip any further processing - self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); - break; - } - } // END - foreach - } -} - -// [EOF] -?> diff --git a/application/hub/main/chat/.htaccess b/application/hub/main/chat/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/chat/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/chat/class_ b/application/hub/main/chat/class_ deleted file mode 100644 index c25b448e3..000000000 --- a/application/hub/main/chat/class_ +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Node???Chat extends BaseNodeChat implements Chatter { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $chatInstance An instance of a Chatter class - */ - public final static function createNode???Chat () { - // Get new instance - $chatInstance = new Node???Chat(); - - // Return the prepared instance - return $chatInstance; - } - - /** - * Method to "bootstrap" the chatter. This step does also apply provided - * command-line arguments stored in the request instance. You should now - * get it from calling $this->getRequestInstance(). - * - * @return void - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - $this->partialStub('Please implement this method.'); - } - - /** - * Add some chatter-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/chat/class_BaseNodeChat.php b/application/hub/main/chat/class_BaseNodeChat.php deleted file mode 100644 index a7acc995a..000000000 --- a/application/hub/main/chat/class_BaseNodeChat.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseNodeChat extends BaseHubSystem { - /** - * Whether this Chatter is active - */ - private $isActive = FALSE; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Enables/disables the chatter (just sets a flag) - * - * @param $version Version number of this chatter - * @return void - */ - public final function enableIsActive ($isActive = TRUE) { - $this->isActive = (bool) $isActive; - } - - /** - * Determines whether the chatter is active - * - * @return $isActive Whether the chatter is active - */ - public final function isActive () { - return $this->isActive; - } -} - -// [EOF] -?> diff --git a/application/hub/main/chat/console/.htaccess b/application/hub/main/chat/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/chat/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/chat/console/class_NodeConsoleChat.php b/application/hub/main/chat/console/class_NodeConsoleChat.php deleted file mode 100644 index bdfbaec76..000000000 --- a/application/hub/main/chat/console/class_NodeConsoleChat.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeConsoleChat extends BaseNodeChat implements Chatter, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $chatInstance An instance of a Chatter class - */ - public final static function createNodeConsoleChat () { - // Get new instance - $chatInstance = new NodeConsoleChat(); - - // Return the prepared instance - return $chatInstance; - } - - /** - * Method to "bootstrap" the chatter. This step does also apply provided - * command-line arguments stored in the request instance. You should now - * get it from calling $this->getRequestInstance(). - * - * @return void - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - // Get the app instance (for shortening our code) - $app = $this->getApplicationInstance(); - - // Output all lines - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - A telnet connection helper'); - self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2012 Chat Developer Team'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); - self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); - self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - } - - /** - * Add some chatter-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/class_ b/application/hub/main/class_ deleted file mode 100644 index 2dea4bd38..000000000 --- a/application/hub/main/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ??? extends BaseFrameworkSystem implements === { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $!!!Instance An instance of a === class - */ - public final static function create??? () { - // Get new instance - $!!!Instance = new ???(); - - // Return the prepared instance - return $!!!Instance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/class_Base b/application/hub/main/class_Base deleted file mode 100644 index f8439da71..000000000 --- a/application/hub/main/class_Base +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Base??? extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/class_BaseHubSystem.php b/application/hub/main/class_BaseHubSystem.php deleted file mode 100644 index d8b886856..000000000 --- a/application/hub/main/class_BaseHubSystem.php +++ /dev/null @@ -1,515 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHubSystem extends BaseFrameworkSystem { - // Exception codes - const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x900; - const EXCEPTION_CHUNK_ALREADY_ASSEMBLED = 0x901; - const EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED = 0x902; - const EXCEPTION_INVALID_CONNECTION_TYPE = 0x903; - const EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED = 0x904; - const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4 = 0x905; - const EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING = 0x906; - const EXCEPTION_REQUEST_NOT_ACCEPTED = 0x907; - const EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED = 0x908; - const EXCEPTION_MULTIPLE_MESSAGE_SENT = 0x909; - const EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED = 0x90a; - const EXCEPTION_INVALID_UNL = 0x90b; - - // Message status codes - const MESSAGE_STATUS_CODE_OKAY = 'OKAY'; - - /** - * Separator for all bootstrap node entries - */ - const BOOTSTRAP_NODES_SEPARATOR = ';'; - - /** - * An instance of a node - */ - private $nodeInstance = NULL; - - /** - * A network package handler instance - */ - private $packageInstance = NULL; - - /** - * A Receivable instance - */ - private $receiverInstance = NULL; - - /** - * Listener pool instance - */ - private $listenerPoolInstance = NULL; - - /** - * Fragmenter instance - */ - private $fragmenterInstance = NULL; - - /** - * Assembler instance - */ - private $assemblerInstance = NULL; - - /** - * Info instance - */ - private $infoInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for node instance - * - * @return $nodeInstance An instance of a node node - */ - public final function getNodeInstance () { - return $this->nodeInstance; - } - - /** - * Setter for node instance - * - * @param $nodeInstance An instance of a node node - * @return void - */ - protected final function setNodeInstance (NodeHelper $nodeInstance) { - $this->nodeInstance = $nodeInstance; - } - - /** - * Setter for network package handler instance - * - * @param $packageInstance The network package instance we shall set - * @return void - */ - protected final function setPackageInstance (Deliverable $packageInstance) { - $this->packageInstance = $packageInstance; - } - - /** - * Getter for network package handler instance - * - * @return $packageInstance The network package handler instance we shall set - */ - protected final function getPackageInstance () { - return $this->packageInstance; - } - - /** - * Setter for receiver instance - * - * @param $receiverInstance A Receivable instance we shall set - * @return void - */ - protected final function setReceiverInstance (Receivable $receiverInstance) { - $this->receiverInstance = $receiverInstance; - } - - /** - * Getter for receiver instance - * - * @return $receiverInstance A Receivable instance we shall get - */ - protected final function getReceiverInstance () { - return $this->receiverInstance; - } - - /** - * Setter for listener pool instance - * - * @param $listenerPoolInstance The new listener pool instance - * @return void - */ - protected final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) { - $this->listenerPoolInstance = $listenerPoolInstance; - } - - /** - * Getter for listener pool instance - * - * @return $listenerPoolInstance Our current listener pool instance - */ - public final function getListenerPoolInstance () { - return $this->listenerPoolInstance; - } - - /** - * Setter for fragmenter instance - * - * @param $fragmenterInstance A Fragmentable instance - * @return void - */ - protected final function setFragmenterInstance (Fragmentable $fragmenterInstance) { - $this->fragmenterInstance = $fragmenterInstance; - } - - /** - * Getter for fragmenter instance - * - * @return $fragmenterInstance A Fragmentable instance - */ - protected final function getFragmenterInstance () { - return $this->fragmenterInstance; - } - - /** - * Setter for assembler instance - * - * @param $assemblerInstance An instance of an Assembler class - * @return void - */ - protected final function setAssemblerInstance (Assembler $assemblerInstance) { - $this->assemblerInstance = $assemblerInstance; - } - - /** - * Getter for assembler instance - * - * @return $assemblerInstance An instance of an Assembler class - */ - protected final function getAssemblerInstance () { - return $this->assemblerInstance; - } - - /** - * Setter for info instance - * - * @param $infoInstance A ShareableInfo instance - * @return void - */ - protected final function setInfoInstance (ShareableInfo $infoInstance) { - $this->infoInstance = $infoInstance; - } - - /** - * Getter for info instance - * - * @return $infoInstance An instance of a ShareableInfo class - */ - public final function getInfoInstance () { - return $this->infoInstance; - } - - /** - * Setter for node id - * - * @param $nodeId The new node id - * @return void - */ - protected final function setNodeId ($nodeId) { - // Set it config now - $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId); - } - - /** - * Getter for node id - * - * @return $nodeId Current node id - */ - public final function getNodeId () { - // Get it from config - return $this->getConfigInstance()->getConfigEntry('node_id'); - } - - /** - * Setter for private key - * - * @param $privateKey The new private key - * @return void - */ - protected final function setPrivateKey ($privateKey) { - // Set it config now - $this->getConfigInstance()->setConfigEntry('private_key', (string) $privateKey); - } - - /** - * Getter for private key - * - * @return $privateKey Current private key - */ - public final function getPrivateKey () { - // Get it from config - return $this->getConfigInstance()->getConfigEntry('private_key'); - } - - /** - * Setter for private key hash - * - * @param $privateKeyHash The new private key hash - * @return void - */ - protected final function setPrivateKeyHash ($privateKeyHash) { - // Set it config now - $this->getConfigInstance()->setConfigEntry('private_key_hash', (string) $privateKeyHash); - } - - /** - * Getter for private key hash - * - * @return $privateKeyHash Current private key hash - */ - public final function getPrivateKeyHash () { - // Get it from config - return $this->getConfigInstance()->getConfigEntry('private_key_hash'); - } - - /** - * Setter for session id - * - * @param $sessionId The new session id - * @return void - */ - protected final function setSessionId ($sessionId) { - $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId); - } - - /** - * Getter for session id - * - * @return $sessionId Current session id - */ - public final function getSessionId () { - return $this->getConfigInstance()->getConfigEntry('session_id'); - } - - /** - * Constructs a callable method name from given socket error code. If the - * method is not found, a generic one is used. - * - * @param $errorCode Error code from socket_last_error() - * @return $handlerName Call-back method name for the error handler - * @throws UnsupportedSocketErrorHandlerException If the error handler is not implemented - */ - protected function getSocketErrorHandlerFromCode ($errorCode) { - // Create a name from translated error code - $handlerName = 'socketError' . self::convertToClassName($this->translateSocketErrorCodeToName($errorCode)) . 'Handler'; - - // Is the call-back method there? - if (!method_exists($this, $handlerName)) { - // Please implement this - throw new UnsupportedSocketErrorHandlerException(array($this, $handlerName, $errorCode), self::EXCEPTION_UNSUPPORTED_ERROR_HANDLER); - } // END - if - - // Return it - return $handlerName; - } - - /** - * Handles socket error for given socket resource and peer data. This method - * validates $socketResource if it is a valid resource (see is_resource()) - * but assumes valid data in array $recipientData, except that - * count($recipientData) is always 2. - * - * @param $method Value of __METHOD__ from calling method - * @param $line Value of __LINE__ from calling method - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - * @throws InvalidSocketException If $socketResource is no socket resource - * @throws NoSocketErrorDetectedException If socket_last_error() gives zero back - */ - protected final function handleSocketError ($method, $line, $socketResource, array $unlData) { - // This method handles only socket resources - if (!is_resource($socketResource)) { - // No resource, abort here - throw new InvalidSocketException(array($this, $socketResource), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Check UNL array - //* DEBUG-DIE: */ die(__METHOD__ . ':unlData=' . print_r($unlData, TRUE)); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); - - // Get error code for first validation (0 is not an error) - $errorCode = socket_last_error($socketResource); - - // If the error code is zero, someone called this method without an error - if ($errorCode == 0) { - // No error detected (or previously cleared outside this method) - throw new NoSocketErrorDetectedException(array($this, $socketResource), BaseListener::EXCEPTION_NO_SOCKET_ERROR); - } // END - if - - // Get handler (method) name - $handlerName = $this->getSocketErrorHandlerFromCode($errorCode); - - // Call-back the error handler method - call_user_func_array(array($this, $handlerName), array($socketResource, $unlData)); - - // Finally clear the error because it has been handled - socket_clear_error($socketResource); - } - - /** - * Translates socket error codes into our own internal names which can be - * used for call-backs. - * - * @param $errorCode The error code from socket_last_error() to be translated - * @return $errorName The translated name (all lower-case, with underlines) - */ - public function translateSocketErrorCodeToName ($errorCode) { - // Nothing bad happened by default - $errorName = BaseRawDataHandler::SOCKET_CONNECTED; - - // Is the code a number, then we have to change it - switch ($errorCode) { - case 0: // Silently ignored, the socket is connected - break; - - case 11: // "Resource temporary unavailable" - $errorName = BaseRawDataHandler::SOCKET_ERROR_RESOURCE_UNAVAILABLE; - break; - - case 32: // "Broken pipe" - $errorName = BaseRawDataHandler::SOCKET_ERROR_BROKEN_PIPE; - break; - - case 104: // "Connection reset by peer" - $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_RESET_BY_PEER; - break; - - case 107: // "Transport end-point not connected" - case 134: // On some (?) systems for 'transport end-point not connected' - // @TODO On some systems it is 134, on some 107? - $errorName = BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT; - break; - - case 110: // "Connection timed out" - $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_TIMED_OUT; - break; - - case 111: // "Connection refused" - $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_REFUSED; - break; - - case 113: // "No route to host" - $errorName = BaseRawDataHandler::SOCKET_ERROR_NO_ROUTE_TO_HOST; - break; - - case 114: // "Operation already in progress" - $errorName = BaseRawDataHandler::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS; - break; - - case 115: // "Operation now in progress" - $errorName = BaseRawDataHandler::SOCKET_ERROR_OPERATION_IN_PROGRESS; - break; - - default: // Everything else <> 0 - // Unhandled error code detected, so first debug it because we may want to handle it like the others - self::createDebugInstance(__CLASS__)->debugOutput('BASE-HUB[' . __METHOD__ . ':' . __LINE__ . '] UNKNOWN ERROR CODE = ' . $errorCode . ', MESSAGE = ' . socket_strerror($errorCode)); - - // Change it only in this class - $errorName = BaseRawDataHandler::SOCKET_ERROR_UNKNOWN; - break; - } - - // Return translated name - return $errorName; - } - - /** - * Shuts down a given socket resource. This method does only ease calling - * the right visitor. - * - * @param $socketResource A valid socket resource - * @return void - */ - public function shutdownSocket ($socketResource) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM: Shutting down socket resource ' . $socketResource . ' with state ' . $this->getPrintableState() . ' ...'); - - // Set socket resource - $this->setSocketResource($socketResource); - - // Get a visitor instance - $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_socket_visitor_class'); - - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); - - // Call the visitor - $this->accept($visitorInstance); - } - - /** - * Half-shuts down a given socket resource. This method does only ease calling - * an other visitor than shutdownSocket() does. - * - * @param $socketResource A valid socket resource - * @return void - */ - public function halfShutdownSocket ($socketResource) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM: Half-shutting down socket resource ' . $socketResource . ' with state ' . $this->getPrintableState() . ' ...'); - - // Set socket resource - $this->setSocketResource($socketResource); - - // Get a visitor instance - $visitorInstance = ObjectFactory::createObjectByConfiguredName('half_shutdown_socket_visitor_class'); - - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('HUB-SYSTEM:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); - - // Call the visitor - $this->accept($visitorInstance); - } - - /** - * "Getter" for a printable state name - * - * @return $stateName Name of the node's state in a printable format - */ - public final function getPrintableState () { - // Default is 'null' - $stateName = 'null'; - - // Get the state instance - $stateInstance = $this->getStateInstance(); - - // Is it an instance of Stateable? - if ($stateInstance instanceof Stateable) { - // Then use that state name - $stateName = $stateInstance->getStateName(); - } // END - if - - // Return result - return $stateName; - } -} - -// [EOF] -?> diff --git a/application/hub/main/commands/.htaccess b/application/hub/main/commands/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/commands/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/commands/console/.htaccess b/application/hub/main/commands/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/commands/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/commands/console/class_HubConsoleAptProxyCommand.php b/application/hub/main/commands/console/class_HubConsoleAptProxyCommand.php deleted file mode 100644 index ff7c46385..000000000 --- a/application/hub/main/commands/console/class_HubConsoleAptProxyCommand.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleAptProxyCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHubConsoleAptProxyCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HubConsoleAptProxyCommand(); - - // Set the application instance - $commandInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $commandInstance; - } - - /** - * Executes the given command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Try to create a AptProxyActivationTask or so - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - /* - * ----------------------- Bootstrapping phase ------------------------ - * Try to bootstrap the node and pass the request instance to it for - * extra arguments which mostly override config entries or enable special - * features within the hub (none is ready at this development stage) - */ - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); - $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); - - // Get apt-proxy instance - $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); - - // Add some apt-proxy-specific filters - $proxyInstance->addExtraAptProxyFilters(); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); - - /* - * ----------------------------- Main loop ---------------------------- - * This is the main loop. Queried calls should come back here very fast - * so the whole application runs on nice speed. This while-loop goes - * until the apt-proxy is no longer active or all tasks are killed. - */ - while (($proxyInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { - // Handle all tasks here - $handlerInstance->handleTasks(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); - } - - /** - * Adds extra filters to the given controller instance - * - * @param $controllerInstance A controller instance - * @param $requestInstance An instance of a class with an Requestable interface - * @return void - * @todo Should we add some more filters? - */ - public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Add pre filters - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_php_requirements_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_initializer_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_welcome_teaser_filter')); - - // Add bootstrap filters - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_bootstrap_task_handler_initializer_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_bootstrap_extra_bootstrapping_filter')); - - // This is the last generic boostrap filter - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_bootstrap_generic_activation_filter')); - - // Add shutdown filters - //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_shutdown_task_handler_filter')); - - // This is the last generic shutdown filter - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('apt_proxy_shutdown_filter')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/commands/console/class_HubConsoleChatCommand.php b/application/hub/main/commands/console/class_HubConsoleChatCommand.php deleted file mode 100644 index 84776e332..000000000 --- a/application/hub/main/commands/console/class_HubConsoleChatCommand.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleChatCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHubConsoleChatCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HubConsoleChatCommand(); - - // Set the application instance - $commandInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $commandInstance; - } - - /** - * Executes the given command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Try to create a ChatActivationTask or so - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - /* - * ----------------------- Bootstrapping phase ------------------------ - * Try to bootstrap the node and pass the request instance to it for - * extra arguments which mostly override config entries or enable special - * features within the hub (none is ready at this development stage) - */ - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); - $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); - - // Get chat instance - $chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Add some chat-specific filters - $chatInstance->addExtraChatFilters(); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); - - /* - * ----------------------------- Main loop ---------------------------- - * This is the main loop. Queried calls should come back here very fast - * so the whole application runs on nice speed. This while-loop goes - * until the chat is no longer active or all tasks are killed. - */ - while (($chatInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { - // Handle all tasks here - $handlerInstance->handleTasks(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); - } - - /** - * Adds extra filters to the given controller instance - * - * @param $controllerInstance A controller instance - * @param $requestInstance An instance of a class with an Requestable interface - * @return void - * @todo Should we add some more filters? - */ - public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Add pre filters - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('chat_php_requirements_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('chat_initializer_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('chat_welcome_teaser_filter')); - - // Add bootstrap filters - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('chat_bootstrap_task_handler_initializer_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('chat_bootstrap_extra_bootstrapping_filter')); - - // This is the last generic boostrap filter - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('chat_bootstrap_generic_activation_filter')); - - // Add shutdown filters - //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('chat_shutdown_task_handler_filter')); - - // This is the last generic shutdown filter - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('chat_shutdown_filter')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/commands/console/class_HubConsoleCrawlerCommand.php b/application/hub/main/commands/console/class_HubConsoleCrawlerCommand.php deleted file mode 100644 index 1f7d1c704..000000000 --- a/application/hub/main/commands/console/class_HubConsoleCrawlerCommand.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleCrawlerCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHubConsoleCrawlerCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HubConsoleCrawlerCommand(); - - // Set the application instance - $commandInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $commandInstance; - } - - /** - * Executes the given command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Try to create a CrawlerActivationTask or so - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - /* - * ----------------------- Bootstrapping phase ------------------------ - * Try to bootstrap the node and pass the request instance to it for - * extra arguments which mostly override config entries or enable special - * features within the hub (none is ready at this development stage) - */ - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); - $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); - - // Get crawler instance - $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Add some crawler-specific filters - $crawlerInstance->addExtraCrawlerFilters(); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); - - /* - * ----------------------------- Main loop ---------------------------- - * This is the main loop. Queried calls should come back here very fast - * so the whole application runs on nice speed. This while-loop goes - * until the crawler is no longer active or all tasks are killed. - */ - while (($crawlerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { - // Handle all tasks here - $handlerInstance->handleTasks(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); - } - - /** - * Adds extra filters to the given controller instance - * - * @param $controllerInstance A controller instance - * @param $requestInstance An instance of a class with an Requestable interface - * @return void - * @todo Should we add some more filters? - */ - public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Add pre filters - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('crawler_php_requirements_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('crawler_initializer_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('crawler_welcome_teaser_filter')); - - // Add bootstrap filters - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('crawler_bootstrap_task_handler_initializer_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('crawler_bootstrap_extra_bootstrapping_filter')); - - // This is the last generic boostrap filter - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('crawler_bootstrap_generic_activation_filter')); - - // Add shutdown filters - //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('crawler_shutdown_task_handler_filter')); - - // This is the last generic shutdown filter - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('crawler_shutdown_filter')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/commands/console/class_HubConsoleCruncherCommand.php b/application/hub/main/commands/console/class_HubConsoleCruncherCommand.php deleted file mode 100644 index c1a6d0991..000000000 --- a/application/hub/main/commands/console/class_HubConsoleCruncherCommand.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleCruncherCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHubConsoleCruncherCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HubConsoleCruncherCommand(); - - // Set the application instance - $commandInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $commandInstance; - } - - /** - * Executes the given command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Try to create a CruncherActivationTask or so - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - /* - * ----------------------- Bootstrapping phase ------------------------ - * Try to bootstrap the node and pass the request instance to it for - * extra arguments which mostly override config entries or enable special - * features within the hub (none is ready at this development stage) - */ - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); - $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); - - // Get cruncher instance - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Add some cruncher-specific filters - $cruncherInstance->addExtraCruncherFilters(); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); - - /* - * ----------------------------- Main loop ---------------------------- - * This is the main loop. Queried calls should come back here very fast - * so the whole application runs on nice speed. This while-loop goes - * until the cruncher is no longer active or all tasks are killed. - */ - while (($cruncherInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { - // Handle all tasks here - $handlerInstance->handleTasks(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); - } - - /** - * Adds extra filters to the given controller instance - * - * @param $controllerInstance A controller instance - * @param $requestInstance An instance of a class with an Requestable interface - * @return void - * @todo Should we add some more filters? - */ - public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Add pre filters - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('cruncher_php_requirements_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('cruncher_initializer_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('cruncher_welcome_teaser_filter')); - - // Add bootstrap filters - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_task_handler_initializer_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_extra_bootstrapping_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_buffer_queue_initializer_filter')); - - // This is the last generic boostrap filter - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('cruncher_bootstrap_generic_activation_filter')); - - // Add shutdown filters - //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('cruncher_shutdown_task_handler_filter')); - - // This is the last generic shutdown filter - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('cruncher_shutdown_filter')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/commands/console/class_HubConsoleMainCommand.php b/application/hub/main/commands/console/class_HubConsoleMainCommand.php deleted file mode 100644 index e92324a3c..000000000 --- a/application/hub/main/commands/console/class_HubConsoleMainCommand.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleMainCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHubConsoleMainCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HubConsoleMainCommand(); - - // Set the application instance - $commandInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $commandInstance; - } - - /** - * Executes the given command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Try to create a HubActivationTask or so - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - /* - * ----------------------- Bootstrapping phase ------------------------ - * Try to bootstrap the node and pass the request instance to it for - * extra arguments which mostly override config entries or enable special - * features within the hub (none is ready at this development stage) - */ - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); - $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Add some node-specific filters, e.g. announcement - $nodeInstance->addExtraNodeFilters(); - - /* - * -------------------------- Hub activation -------------------------- - * Activates the node by doing some final preparation steps and setting - * the attribute $hubIsActive to TRUE. - */ - $nodeInstance->activateNode($requestInstance, $responseInstance); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); - - /* - * ----------------------------- Main loop ---------------------------- - * This is the main loop. Queried calls should come back here very fast - * so the whole application runs on nice speed. This while-loop goes - * until the hub is no longer active or all tasks are killed. - */ - while (($nodeInstance->isNodeActive()) && ($handlerInstance->hasTasksLeft())) { - // Handle all tasks here - $handlerInstance->handleTasks(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); - } - - /** - * Adds extra filters to the given controller instance - * - * @param $controllerInstance A controller instance - * @param $requestInstance An instance of a class with an Requestable interface - * @return void - * @todo Should we add some more filters? - */ - public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Add pre filters - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_initializer_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_welcome_teaser_filter')); - - // Add bootstrap filters - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_nodeid_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_sessionid_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_generate_private_key_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_extra_bootstrapping_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('node_bootstrap_listener_pool_filter')); - - // Add node activation filters - $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_task_handler_initializer_filter')); - - // Add shutdown filters - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_flush_node_list_filter')); - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_task_handler_filter')); - - // This is the last generic shutdown filter - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('node_shutdown_node_filter')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/commands/console/class_HubConsoleMinerCommand.php b/application/hub/main/commands/console/class_HubConsoleMinerCommand.php deleted file mode 100644 index 83aaf6369..000000000 --- a/application/hub/main/commands/console/class_HubConsoleMinerCommand.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleMinerCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHubConsoleMinerCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HubConsoleMinerCommand(); - - // Set the application instance - $commandInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $commandInstance; - } - - /** - * Executes the given command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Try to create a MinerActivationTask or so - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - /* - * ----------------------- Bootstrapping phase ------------------------ - * Try to bootstrap the node and pass the request instance to it for - * extra arguments which mostly override config entries or enable special - * features within the hub (none is ready at this development stage) - */ - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...'); - $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance); - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.'); - - // Get miner instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Add some miner-specific filters - $minerInstance->addExtraMinerFilters(); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---'); - - /* - * ----------------------------- Main loop ---------------------------- - * This is the main loop. Queried calls should come back here very fast - * so the whole application runs on nice speed. This while-loop goes - * until the miner is no longer active or all tasks are killed. - */ - while (($minerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { - // Handle all tasks here - $handlerInstance->handleTasks(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---'); - } - - /** - * Adds extra filters to the given controller instance - * - * @param $controllerInstance A controller instance - * @param $requestInstance An instance of a class with an Requestable interface - * @return void - * @todo Should we add some more filters? - */ - public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Add pre filters - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_php_requirements_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_initializer_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('miner_welcome_teaser_filter')); - - // Add bootstrap filters - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_task_handler_initializer_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_extra_bootstrapping_filter')); - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_buffer_queue_initializer_filter')); - - // This is the last generic boostrap filter - $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('miner_bootstrap_generic_activation_filter')); - - // Add shutdown filters - //$controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('miner_shutdown_task_handler_filter')); - - // This is the last generic shutdown filter - $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('miner_shutdown_filter')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/communicator/.htaccess b/application/hub/main/communicator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/communicator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/communicator/class_ b/application/hub/main/communicator/class_ deleted file mode 100644 index 4a7c8f4dd..000000000 --- a/application/hub/main/communicator/class_ +++ /dev/null @@ -1,50 +0,0 @@ -node communicator class - * - * @author Roland Haeder - * @version 0.0.0 - * @copyright Copyright (c) 2014 !!! Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???NodeCommunicator extends BaseCommunicator implements Communicator { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $communicatorInstance An instance of a Communicator class - */ - public final static function create???NodeCommunicator () { - // Get new instance - $communicatorInstance = new ???NodeCommunicator(); - - // Return the prepared instance - return $communicatorInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/communicator/class_BaseCommunicator.php b/application/hub/main/communicator/class_BaseCommunicator.php deleted file mode 100644 index 8be2c2aec..000000000 --- a/application/hub/main/communicator/class_BaseCommunicator.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCommunicator extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init state which sets the state to 'init' - $this->initState(); - } - - /** - * Initializes the communicator's state which sets it to 'init' - * - * @return void - */ - private function initState() { - // Get the state factory and create the initial state. - CommunicatorStateFactory::createCommunicatorStateInstanceByName('init', $this); - } - - /** - * Initializes the executor, whatever it does. - * - * @return void - */ - public function initExecutor (Stateable $stateInstance) { - $this->partialStub('Unfinished method with state ' . $this->getPrintableState() . '.'); - - // This communicator is now fully initialized so change the state - $stateInstance->communicatorHasInitialized(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/communicator/crawler/.htaccess b/application/hub/main/communicator/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/communicator/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/communicator/crawler/class_CrawlerNodeCommunicator.php b/application/hub/main/communicator/crawler/class_CrawlerNodeCommunicator.php deleted file mode 100644 index bfbc4c364..000000000 --- a/application/hub/main/communicator/crawler/class_CrawlerNodeCommunicator.php +++ /dev/null @@ -1,50 +0,0 @@ -node communicator class - * - * @author Roland Haeder - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerNodeCommunicator extends BaseCommunicator implements Communicator, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $communicatorInstance An instance of a Communicator class - */ - public final static function createCrawlerNodeCommunicator () { - // Get new instance - $communicatorInstance = new CrawlerNodeCommunicator(); - - // Return the prepared instance - return $communicatorInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/communicator/miner/.htaccess b/application/hub/main/communicator/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/communicator/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/communicator/miner/class_MinerNodeCommunicator.php b/application/hub/main/communicator/miner/class_MinerNodeCommunicator.php deleted file mode 100644 index 5ffb67c4c..000000000 --- a/application/hub/main/communicator/miner/class_MinerNodeCommunicator.php +++ /dev/null @@ -1,50 +0,0 @@ -node communicator class - * - * @author Roland Haeder - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerNodeCommunicator extends BaseCommunicator implements Communicator, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $communicatorInstance An instance of a Communicator class - */ - public final static function createMinerNodeCommunicator () { - // Get new instance - $communicatorInstance = new MinerNodeCommunicator(); - - // Return the prepared instance - return $communicatorInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/compressor/.htaccess b/application/hub/main/compressor/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/compressor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/compressor/decorator/.htaccess b/application/hub/main/compressor/decorator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/compressor/decorator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/compressor/decorator/class_NetworkPackageCompressorDecorator.php b/application/hub/main/compressor/decorator/class_NetworkPackageCompressorDecorator.php deleted file mode 100644 index 06957ef60..000000000 --- a/application/hub/main/compressor/decorator/class_NetworkPackageCompressorDecorator.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NetworkPackageCompressorDecorator extends BaseHubSystem implements Compressor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $innerCompressorInstance The inner Compressor class - * @return $compressorInstance An instance of a Compressor class - */ - public static final function createNetworkPackageCompressorDecorator (Compressor $innerCompressorInstance) { - // Get new instance - $compressorInstance = new NetworkPackageCompressorDecorator(); - - // Set the inner compressor class - $compressorInstance->setCompressorInstance($innerCompressorInstance); - - // Return the prepared instance - return $compressorInstance; - } - - /** - * A compression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function compressStream ($streamData) { - // Call the inner compressor class - return $this->getCompressorInstance()->compressStream($streamData); - } - - /** - * A decompression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function decompressStream ($streamData) { - // Call the inner compressor class - return $this->getCompressorInstance()->decompressStream($streamData); - } - - /** - * Getter for the file extension of this compressor - * - * @return $string The compressor's file extension - */ - public function getCompressorExtension () { - // Call the inner compressor class - return $this->getCompressorInstance()->getCompressorExtension(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/connectors/.htaccess b/application/hub/main/connectors/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/connectors/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/connectors/query/.htaccess b/application/hub/main/connectors/query/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/connectors/query/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/connectors/query/class_ b/application/hub/main/connectors/query/class_ deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/connectors/query/class_ +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/connectors/query/local/.htaccess b/application/hub/main/connectors/query/local/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/connectors/query/local/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/connectors/queues/.htaccess b/application/hub/main/connectors/queues/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/connectors/queues/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/connectors/queues/class_ b/application/hub/main/connectors/queues/class_ deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/connectors/queues/class_ +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/connectors/queues/local/.htaccess b/application/hub/main/connectors/queues/local/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/connectors/queues/local/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/controller/.htaccess b/application/hub/main/controller/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/controller/console/.htaccess b/application/hub/main/controller/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/controller/console/class_HubConsoleAptProxyController.php b/application/hub/main/controller/console/class_HubConsoleAptProxyController.php deleted file mode 100644 index 178388f13..000000000 --- a/application/hub/main/controller/console/class_HubConsoleAptProxyController.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleAptProxyController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { - $this->initFilterChain($filterChain); - } // END - foreach - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHubConsoleAptProxyController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HubConsoleAptProxyController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Add a bootstrap filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addBootstrapFilter (Filterable $filterInstance) { - $this->addFilter('bootstrap', $filterInstance); - } - - /** - * Executes all bootstrap filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('bootstrap', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/controller/console/class_HubConsoleChatController.php b/application/hub/main/controller/console/class_HubConsoleChatController.php deleted file mode 100644 index 7a92d78de..000000000 --- a/application/hub/main/controller/console/class_HubConsoleChatController.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleChatController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { - $this->initFilterChain($filterChain); - } // END - foreach - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHubConsoleChatController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HubConsoleChatController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Add a bootstrap filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addBootstrapFilter (Filterable $filterInstance) { - $this->addFilter('bootstrap', $filterInstance); - } - - /** - * Executes all bootstrap filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('bootstrap', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/controller/console/class_HubConsoleCrawlerController.php b/application/hub/main/controller/console/class_HubConsoleCrawlerController.php deleted file mode 100644 index c351e6c2e..000000000 --- a/application/hub/main/controller/console/class_HubConsoleCrawlerController.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleCrawlerController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { - $this->initFilterChain($filterChain); - } // END - foreach - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHubConsoleCrawlerController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HubConsoleCrawlerController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Add a bootstrap filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addBootstrapFilter (Filterable $filterInstance) { - $this->addFilter('bootstrap', $filterInstance); - } - - /** - * Executes all bootstrap filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('bootstrap', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/controller/console/class_HubConsoleCruncherController.php b/application/hub/main/controller/console/class_HubConsoleCruncherController.php deleted file mode 100644 index b478baa73..000000000 --- a/application/hub/main/controller/console/class_HubConsoleCruncherController.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleCruncherController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { - $this->initFilterChain($filterChain); - } // END - foreach - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHubConsoleCruncherController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HubConsoleCruncherController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Add a bootstrap filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addBootstrapFilter (Filterable $filterInstance) { - $this->addFilter('bootstrap', $filterInstance); - } - - /** - * Executes all bootstrap filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('bootstrap', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php b/application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php deleted file mode 100644 index 35c26b32c..000000000 --- a/application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleDefaultNewsController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init additional filter chains - foreach (array('bootstrap', 'activation','shutdown') as $filterChain) { - $this->initFilterChain($filterChain); - } // END - foreach - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHubConsoleDefaultNewsController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HubConsoleDefaultNewsController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add news filters to this controller - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Add a bootstrap filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addBootstrapFilter (Filterable $filterInstance) { - $this->addFilter('bootstrap', $filterInstance); - } - - /** - * Executes all bootstrap filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('bootstrap', $requestInstance, $responseInstance); - } - - /** - * Add a hub activation filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addActivationFilter (Filterable $filterInstance) { - $this->addFilter('activation', $filterInstance); - } - - /** - * Executes all hub activation filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('activation', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/controller/console/class_HubConsoleMinerController.php b/application/hub/main/controller/console/class_HubConsoleMinerController.php deleted file mode 100644 index e3e564a7f..000000000 --- a/application/hub/main/controller/console/class_HubConsoleMinerController.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleMinerController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { - $this->initFilterChain($filterChain); - } // END - foreach - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHubConsoleMinerController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HubConsoleMinerController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Add a bootstrap filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addBootstrapFilter (Filterable $filterInstance) { - $this->addFilter('bootstrap', $filterInstance); - } - - /** - * Executes all bootstrap filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('bootstrap', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/controller/html/.htaccess b/application/hub/main/controller/html/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/controller/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/crawler/.htaccess b/application/hub/main/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/crawler/class_ b/application/hub/main/crawler/class_ deleted file mode 100644 index 189379e51..000000000 --- a/application/hub/main/crawler/class_ +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Node???Crawler extends BaseNodeCrawler implements Crawler { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $crawlerInstance An instance of a Crawler class - */ - public final static function createNode???Crawler () { - // Get new instance - $crawlerInstance = new Node???Crawler(); - - // Return the prepared instance - return $crawlerInstance; - } - - /** - * Method to "bootstrap" the crawler. This step does also apply provided - * command-line arguments stored in the request instance. You should now - * get it from calling $this->getRequestInstance(). - * - * @return void - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - $this->partialStub('Please implement this method.'); - } - - /** - * Add some crawler-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/crawler/class_BaseNodeCrawler.php b/application/hub/main/crawler/class_BaseNodeCrawler.php deleted file mode 100644 index d5ce4a5d8..000000000 --- a/application/hub/main/crawler/class_BaseNodeCrawler.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseNodeCrawler extends BaseHubSystem { - /** - * Whether this Crawler is active - */ - private $isActive = FALSE; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Set this crawler instance in registry - Registry::getRegistry()->addInstance('crawler', $this); - - // Init state which sets the state to 'init' - $this->initState(); - } - - /** - * Initializes the node's state which sets it to 'init' - * - * @return void - */ - private function initState() { - // Get the state factory and create the initial state. - CrawlerStateFactory::createCrawlerStateInstanceByName('init'); - } - - /** - * Initializes this crawler instance - * - * @param $stateInstance An instance of a Stateable class - * @return void - * @todo 0% done - */ - public function initCrawler (Stateable $stateInstance) { - // Please implement - $this->partialStub('Unfinished method.'); - } - - /** - * Enables/disables the crawler (just sets a flag) - * - * @param $version Version number of this crawler - * @return void - */ - public final function enableIsActive ($isActive = TRUE) { - $this->isActive = (bool) $isActive; - } - - /** - * Determines whether the crawler is active - * - * @return $isActive Whether the crawler is active - */ - public final function isActive () { - return $this->isActive; - } -} - -// [EOF] -?> diff --git a/application/hub/main/crawler/console/.htaccess b/application/hub/main/crawler/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/crawler/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/crawler/console/class_NodeConsoleCrawler.php b/application/hub/main/crawler/console/class_NodeConsoleCrawler.php deleted file mode 100644 index d1b1cba58..000000000 --- a/application/hub/main/crawler/console/class_NodeConsoleCrawler.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeConsoleCrawler extends BaseNodeCrawler implements Crawler, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $crawlerInstance An instance of a Crawler class - */ - public final static function createNodeConsoleCrawler () { - // Get new instance - $crawlerInstance = new NodeConsoleCrawler(); - - // Return the prepared instance - return $crawlerInstance; - } - - /** - * Method to "bootstrap" the crawler. This step does also apply provided - * command-line arguments stored in the request instance. You should now - * get it from calling $this->getRequestInstance(). - * - * @return void - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - // Get the app instance (for shortening our code) - $app = $this->getApplicationInstance(); - - // Output all lines - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('Distributed Crawler v' . $app->getAppVersion()); - self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2014 Crawler Developer Team'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); - self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); - self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - } - - /** - * Add some crawler-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/cruncher/.htaccess b/application/hub/main/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/cruncher/class_ b/application/hub/main/cruncher/class_ deleted file mode 100644 index d4b0fb2c4..000000000 --- a/application/hub/main/cruncher/class_ +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Hub???Cruncher extends BaseHubCruncher implements CruncherHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set version number - $this->setVersion('x.x'); - } - - /** - * Creates an instance of this hub-cruncher class - * - * @param $requestInstance An instance of a Requestable class - * @return $cruncherInstance An instance of this hub-cruncher class - */ - public final static function createHub???Cruncher (Requestable $requestInstance) { - // Get a new instance - $cruncherInstance = new Hub???Cruncher(); - - // Set the request instance - $cruncherInstance->setRequestInstance($requestInstance); - - // Return the instance - return $cruncherInstance; - } - - /** - * Method to "bootstrap" the cruncher. This step does also apply provided - * command-line arguments stored in the request instance. The regular cruncher - * should communicate with the bootstrap-crunchers at this point. - * - * @return void - * @todo Implement this method - */ - public function doBootstrapping () { - // Call generic (parent) bootstrapping method first - parent::doGenericBootstrapping(); - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - $this->partialStub('Please implement this method.'); - } - - /** - * Add some cruncher-specific filters - * - * @return void - */ - public function addExtraHubFilters () { - // Add some filters here - } -} - -// [EOF] -?> diff --git a/application/hub/main/cruncher/class_BaseHubCruncher.php b/application/hub/main/cruncher/class_BaseHubCruncher.php deleted file mode 100644 index 76feae5d2..000000000 --- a/application/hub/main/cruncher/class_BaseHubCruncher.php +++ /dev/null @@ -1,213 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { - /** - * Version information - */ - private $version = 'x.x'; - - /** - * By default no cruncher is active - */ - private $isActive = FALSE; - - /** - * All buffer queue instances (a FIFO) - */ - private $bufferInstance = NULL; - - /** - * Stacker name for incoming queue - */ - const STACKER_NAME_IN_QUEUE = 'in_queue'; - - /** - * Stacker name for outcoming queue - */ - const STACKER_NAME_OUT_QUEUE = 'out_queue'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Set this cruncher instance in registry - Registry::getRegistry()->addInstance('cruncher', $this); - - // Init this cruncher - $this->initCruncher(); - } - - /** - * Initialize the cruncher generically - * - * @return void - */ - private function initCruncher () { - // Init the state - CruncherStateFactory::createCruncherStateInstanceByName('init'); - } - - /** - * Getter for version - * - * @return $version Version number of this cruncher - */ - protected final function getVersion () { - return $this->version; - } - - /** - * Setter for version - * - * @param $version Version number of this cruncher - * @return void - */ - protected final function setVersion ($version) { - $this->version = (string) $version; - } - - /** - * Checks whether the in-buffer queue is filled by comparing it's current - * amount of entries against a threshold. - * - * @return $isFilled Whether the in-buffer is filled - */ - protected function isInBufferQueueFilled () { - // Determine it - $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > $this->getConfigInstance()->getConfigEntry('cruncher_in_buffer_min_threshold')); - - // And return the result - return $isFilled; - } - - /** - * This method fills the in-buffer with (a) test unit(s) which are mainly - * used for development of the crunching part. They must be enabled in - * configuration, or else your cruncher runs out of WUs and waits for more - * to show up. - * - * In this method we already know that the in-buffer is going depleted so - * no need to double-check it here. - * - * @return void - */ - abstract protected function fillInBufferQueueWithTestUnits (); - - /** - * This method fills the in-buffer with (real) WUs which will be crunched - * and the result be sent back to the key producer instance. - * - * @return void - */ - abstract protected function fillInBufferQueueWithWorkUnits (); - - /** - * Enables/disables the cruncher (just sets a flag) - * - * @param $version Version number of this cruncher - * @return void - */ - public final function enableIsActive ($isActive = TRUE) { - $this->isActive = (bool) $isActive; - } - - /** - * Determines whether the cruncher is active - * - * @return $isActive Whether the cruncher is active - */ - public final function isActive () { - return $this->isActive; - } - - /** - * Initializes all buffer queues (mostly in/out). This method is demanded - * by the CruncherHelper interface. - * - * @return void - */ - public function initBufferQueues () { - /* - * Initialize both buffer queues, we can use the FIFO class here - * directly and encapsulate its method calls with protected methods. - */ - $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('cruncher_buffer_stacker_class'); - - // Initialize common stackers, like in/out - $this->bufferInstance->initStacks(array( - self::STACKER_NAME_IN_QUEUE, - self::STACKER_NAME_OUT_QUEUE - )); - - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER: All buffers are now initialized.'); - } - - /** - * This method determines if the in-buffer is going to depleted and if so, - * it fetches more WUs from the network. If no WU can be fetched from the - * network and if enabled, a random test WU is being generated. - * - * This method is demanded from the CruncherHelper interface. - * - * @return void - */ - public function doFetchWorkUnits () { - // Simply check if we have enough WUs left in the in-buffer queue (a FIFO) - if (!$this->isInBufferQueueFilled()) { - // The in-buffer queue needs filling, so head out and get some work - $this->fillInBufferQueueWithWorkUnits(); - - // Is the buffer still not filled and are test-packages allowed? - if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'Y')) { - // Then fill the in-buffer with (one) test-unit(s) - $this->fillInBufferQueueWithTestUnits(); - } // END - if - } // END - if - } - - /** - * Updates a given field with new value - * - * @param $fieldName Field to update - * @param $fieldValue New value to store - * @return void - * @throws DatabaseUpdateSupportException If this class does not support database updates - * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem - */ - public function updateDatabaseField ($fieldName, $fieldValue) { - // Unfinished - $this->partialStub('Unfinished!'); - return; - } -} - -// [EOF] -?> diff --git a/application/hub/main/cruncher/mcrypt/.htaccess b/application/hub/main/cruncher/mcrypt/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/cruncher/mcrypt/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php b/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php deleted file mode 100644 index bf684cc6e..000000000 --- a/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set version number - $this->setVersion('0.0.0'); - } - - /** - * Creates an instance of this hub-cruncher class - * - * @return $cruncherInstance An instance of this hub-cruncher class - */ - public final static function createHubMcryptCruncher () { - // Get a new instance - $cruncherInstance = new HubMcryptCruncher(); - - // Return the instance - return $cruncherInstance; - } - - /** - * This method fills the in-buffer with (a) test unit(s) which are mainly - * used for development of the crunching part. They must be enabled in - * configuration, or else your cruncher runs out of WUs and waits for more - * to show up. - * - * In this method we already know that the in-buffer is going depleted so - * no need to double-check it here. - * - * @return void - */ - protected function fillInBufferQueueWithTestUnits () { - // Are test units enabled? - if ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'N') { - // They are disabled, so skip any further steps - return; - } elseif ($this->getStateInstance()->isCruncherStateVirgin()) { - // No virgin crunchers please, because they usually have no test units ready for crunching - return; - } - - // Get a test-unit generator instance - $generatorInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_generator_class'); - - // We don't need an iterator here because we just need to generate some test units - for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('cruncher_max_text_unit_amount'); $idx++) { - // Get a test unit from it - $unitInstance = $generatorInstance->generateNextUnitInstance(); - - // ... and finally queue it to the in-buffer queue - $this->queueUnitInstanceToInBuffer($unitInstance); - } // END - for - } - - /** - * This method fills the in-buffer with (real) WUs which will be crunched - * and the result be sent back to the key producer instance. - * - * @return void - */ - protected function fillInBufferQueueWithWorkUnits () { - // This cruncher's state must not be one of these: 'virgin' - if ($this->getStateInstance()->isCruncherStateVirgin()) { - // We can silently skip here, until the generation is finished - return; - } // END - if - - // @TODO Implement this method - $this->partialStub('Please implement this method.'); - } - - /** - * Method to "bootstrap" the cruncher. This step does also apply provided - * command-line arguments stored in the request instance. No buffer queue - * will be initialized here, we only do "general" things here. - * - * @return void - * @todo Implement this method - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - // Output all lines - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('MCrypt Cruncher v' . $this->getVersion() . ' is starting ...'); - self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2011 - 2014 Cruncher Developer Team'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); - self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); - self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - } - - /** - * Add some cruncher-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - * @todo 0% done - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - // Add some filters here - $this->partialStub('Please add some cruncher-specific filters, if required.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/database/.htaccess b/application/hub/main/database/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/database/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/database/frontend/.htaccess b/application/hub/main/database/frontend/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/database/frontend/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/database/frontend/cruncher/.htaccess b/application/hub/main/database/frontend/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/database/frontend/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php b/application/hub/main/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php deleted file mode 100644 index 9beb90018..000000000 --- a/application/hub/main/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherUnitDatabaseWrapper extends BaseDatabaseWrapper implements UnitDatabaseWrapper, Registerable { - // Constants for database table names - const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units'; - - // Constants for database column names - const DB_COLUMN_UNIT_TYPE = 'unit_type'; - const DB_COLUMN_UNIT_STATUS = 'unit_status'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createCruncherUnitDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new CruncherUnitDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_CRUNCHER_UNITS); - - // Return the instance - return $wrapperInstance; - } - - /** - * Checks whether a test unit has been produced - * - * @return $isProduced Whether a test unit has already been produced - */ - public function isTestUnitProduced () { - // Now get a search instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add criteria for looking up already created and available test units - $searchInstance->addCriteria(self::DB_COLUMN_UNIT_TYPE , BaseUnitProducer::UNIT_TYPE_TEST_UNIT); - $searchInstance->addCriteria(self::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE); - $searchInstance->setConfiguredLimit('cruncher_test_unit_max_count'); - - // Search for our units - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Do we have some entries? - $isProduced = $resultInstance->next(); - - // Return it - return $isProduced; - } -} - -// [EOF] -?> diff --git a/application/hub/main/database/frontend/node/.htaccess b/application/hub/main/database/frontend/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/database/frontend/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/main/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php deleted file mode 100644 index 12b8038bd..000000000 --- a/application/hub/main/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ /dev/null @@ -1,682 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implements NodeDhtWrapper, Registerable { - /** - * "Cached" results for dabase for looking for unpublished entries - */ - private $unpublishedEntriesInstance = NULL; - - // Constants for database table names - const DB_TABLE_NODE_DHT = 'node_dht'; - - // Constants for database column names - const DB_COLUMN_NODE_ID = 'node_id'; - const DB_COLUMN_SESSION_ID = 'session_id'; - const DB_COLUMN_EXTERNAL_ADDRESS = 'external_address'; - const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash'; - const DB_COLUMN_NODE_MODE = 'node_mode'; - const DB_COLUMN_ACCEPTED_OBJECTS = 'accepted_object_types'; - const DB_COLUMN_NODE_LIST = 'node_list'; - const DB_COLUMN_PUBLICATION_STATUS = 'publication_status'; - const DB_COLUMN_ANSWER_STATUS = 'answer_status'; - const DB_COLUMN_ACCEPT_BOOTSTRAP = 'accept_bootstrap'; - - // Publication status' - const PUBLICATION_STATUS_PENDING = 'PENDING'; - - // Exception codes - const EXCEPTION_NODE_ALREADY_REGISTERED = 0x800; - const EXCEPTION_NODE_NOT_REGISTERED = 0x801; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createNodeDistributedHashTableDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new NodeDistributedHashTableDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_NODE_DHT); - - // Return the instance - return $wrapperInstance; - } - - /** - * Static getter for an array of all DHT database entries - * - * @return $elements All elements for the DHT dabase - */ - public static final function getAllElements () { - // Create array and ... - $elements = array( - self::DB_COLUMN_NODE_ID, - self::DB_COLUMN_SESSION_ID, - self::DB_COLUMN_EXTERNAL_ADDRESS, - self::DB_COLUMN_PRIVATE_KEY_HASH, - self::DB_COLUMN_NODE_MODE, - self::DB_COLUMN_ACCEPTED_OBJECTS, - self::DB_COLUMN_NODE_LIST - ); - - // ... return it - return $elements; - } - - /** - * Prepares a search instance for given node data - * - * @param $nodeData An array with valid node data - * @return $searchInstance An instance of a SearchCriteria class - */ - private function prepareSearchInstance (array $nodeData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Assert on array elements - assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); - - // Get instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Search for node id and limit it to one entry - $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $nodeData[self::DB_COLUMN_NODE_ID]); - $searchInstance->setLimit(1); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - - // Return it - return $searchInstance; - } - - /** - * Getter for result instance for unpublished entries - * - * @return $unpublishedEntriesInstance Result instance - */ - public final function getUnpublishedEntriesInstance () { - return $this->unpublishedEntriesInstance; - } - - /** - * Prepares a "local" instance of a StoreableCriteria class with all node - * data for insert/update queries. This data set contains data from *this* - * (local) node. - * - * @return $dataSetInstance An instance of a StoreableCriteria class - */ - private function prepareLocalDataSetInstance () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Get node/request instances - $nodeInstance = NodeObjectFactory::createNodeInstance(); - $requestInstance = ApplicationHelper::getSelfInstance()->getRequestInstance(); - - // Get a dataset instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); - - // Get Universal Node Locator and "explode" it - $unlInstance = $nodeInstance->determineUniversalNodeLocator(); - - // Get UNL data from it - $unlData = $unlInstance->getUnlData(); - - // Make sure both is valid - // @TODO Bad check on UNL, better use a proper validator - assert(isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL])); - assert($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] !== 'invalid'); - - // Get an array of all accepted object types - $objectList = $nodeInstance->getListFromAcceptedObjectTypes(); - - // Make sure this is an array - assert(is_array($objectList)); - - // Add public node data - $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_MODE , $requestInstance->getRequestElement('mode')); - $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]); - $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_ID , $nodeInstance->getNodeId()); - $dataSetInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId()); - $dataSetInstance->addCriteria(self::DB_COLUMN_PRIVATE_KEY_HASH, $nodeInstance->getPrivateKeyHash()); - $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList)); - $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($nodeInstance->isAcceptingDhtBootstrap())); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - - // Return it - return $dataSetInstance; - } - - /** - * Checks whether the local (*this*) node is registered in the DHT by - * checking if the external address is found. - * - * @return $isRegistered Whether *this* node is registered in the DHT - */ - public function isLocalNodeRegistered () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Get a search criteria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Get Universal Node Locator and "explode" it - $unlData = $nodeInstance->getUniversalNodeLocatorArray(); - - // Make sure the external address is set and not invalid - // @TODO Bad check on UNL, better use a proper validator - assert(isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL])); - assert($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] != 'invalid'); - - // Add Universal Node Locator/node id as criteria - $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]); - $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID , $nodeInstance->getNodeId()); - $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId()); - $searchInstance->setLimit(1); - - // Query database and get a result instance back - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Cache result of if there is an entry, valid() will tell us if an entry is there - $isRegistered = $resultInstance->valid(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!'); - - // Return result - return $isRegistered; - } - - /** - * Registeres the local (*this*) node with its data in the DHT. - * - * @return void - */ - public function registerLocalNode () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Assert to make sure this method is called with no record in DB (the actual backend of the DHT) - assert(!$this->isLocalNodeRegistered()); - - // Get prepared data set instance - $dataSetInstance = $this->prepareLocalDataSetInstance(); - - // "Insert" this dataset instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Updates local (*this*) node's data in DHT, this is but not limited to the - * session id, ip number (and/or hostname) and port number. - * - * @return void - */ - public function updateLocalNode () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Assert to make sure this method is called with one record in DB (the actual backend of the DHT) - assert($this->isLocalNodeRegistered()); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Get search criteria - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Search for node id and limit it to one entry - $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $nodeInstance->getNodeId()); - $searchInstance->setLimit(1); - - // Get a prepared dataset instance - $dataSetInstance = $this->prepareLocalDataSetInstance(); - - // Set search instance - $dataSetInstance->setSearchInstance($searchInstance); - - // Update DHT database record - $this->queryUpdateDataSet($dataSetInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Finds a node locally by given session id - * - * @param $sessionId Session id to lookup - * @return $nodeData Node data array - */ - public function findNodeLocalBySessionId ($sessionId) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: sessionId=' . $sessionId . ' - CALLED!'); - - // Get search criteria - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Search for session id and limit it to one entry - $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID, $sessionId); - $searchInstance->setLimit(1); - - // Query database and get a result instance back - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!'); - - // Return result instance - return $resultInstance; - } - - /** - * Registeres a node by given message data. - * - * @param $messageData An array of all message data - * @param $handlerInstance An instance of a HandleableDataSet class - * @return void - */ - public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!'); - - // Get a data set instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); - - // Set primary key (session id) - $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); - - // Add all array elements - $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData); - - // Remove 'node_list' - $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); - - // Run the "INSERT" query - $this->queryInsertDataSet($dataSetInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . '] - EXIT!'); - } - - /** - * Updates an existing entry in node list - * - * @param $messageData An array of all message data - * @param $handlerInstance An instance of a HandleableDataSet class - * @param $searchInstance An instance of LocalSearchCriteria class - * @return void - */ - public function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Get a data set instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); - - // Add search instance - $dataSetInstance->setSearchInstance($searchInstance); - - // Set primary key (session id) - $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); - - // Add all array elements - $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData); - - // Remove 'node_list' - $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); - - // Run the "UPDATE" query - $this->queryUpdateDataSet($dataSetInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Determines whether the given node data is already inserted in the DHT - * - * @param $nodeData An array with valid node data - * @return $isRegistered Whether the given node data is already inserted - */ - public function isNodeRegistered (array $nodeData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Assert on array elements - assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]); - - // Get search criteria - $searchInstance = $this->prepareSearchInstance($nodeData); - - // Query database and get a result instance back - $resultInstance = $this->doSelectByCriteria( - // Search instance - $searchInstance, - // Only look for these array elements ("keys") - array( - self::DB_COLUMN_NODE_ID => TRUE, - self::DB_COLUMN_EXTERNAL_ADDRESS => TRUE - ) - ); - - // Check if there is an entry - $isRegistered = $resultInstance->valid(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!'); - - // Return registration status - return $isRegistered; - } - - /** - * Registers a node with given data in the DHT. If the node is already - * registered this method shall throw an exception. - * - * @param $nodeData An array with valid node data - * @return void - * @throws NodeAlreadyRegisteredException If the node is already registered - */ - public function registerNode (array $nodeData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Assert on array elements - assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); - - // Is the node registered? - if ($this->isNodeRegistered($nodeData)) { - // Throw an exception - throw new NodeAlreadyRegisteredException(array($this, $nodeData), self::EXCEPTION_NODE_ALREADY_REGISTERED); - } // END - if - - // @TODO Unimplemented part - $this->partialStub('nodeData=' . print_r($nodeData, TRUE)); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Updates a node's entry in the DHT with given data. This will enrich or - * just update already exsiting data. If the node is not found this method - * shall throw an exception. - * - * @param $nodeData An array with valid node data - * @return void - * @throws NodeDataMissingException If the node's data is missing - */ - public function updateNode (array $nodeData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Assert on array elements - assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...'); - - // Is the node registered? - if (!$this->isNodeRegistered($nodeData)) { - // No, then throw an exception - throw new NodeDataMissingException(array($this, $nodeData), self::EXCEPTION_NODE_NOT_REGISTERED); - } // END - if - - // Get a search instance - $searchInstance = $this->prepareSearchInstance($nodeData); - - // Get a data set instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); - - // Add search instance - $dataSetInstance->setSearchInstance($searchInstance); - - // Set primary key (session id) - $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: nodeData=' . print_r($nodeData, TRUE)); - - // Add all array elements - $nodeInstance->addArrayToDataSet($dataSetInstance, $nodeData); - - // Remove 'node_list' - $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); - - // Run the "UPDATE" query - $this->queryUpdateDataSet($dataSetInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Checks whether there are unpublished entries - * - * @return $hasUnpublished Whether there are unpublished entries - * @todo Add minimum/maximum age limitations - */ - public function hasUnpublishedEntries () { - // Get search instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add exclusion key which is the publish status - $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PUBLICATION_STATUS, NodeDistributedHashTableDatabaseWrapper::PUBLICATION_STATUS_PENDING); - - // Remember search instance - $this->setSearchInstance($searchInstance); - - // Run the query - $this->unpublishedEntriesInstance = $this->doSelectByCriteria($searchInstance); - - // Check pending entries - $hasUnpublished = $this->unpublishedEntriesInstance->valid(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - - // Return it - return $hasUnpublished; - } - - /** - * Initializes publication of DHT entries. This does only prepare - * publication. The next step is to pickup such prepared entries and publish - * them by uploading to other (recently appeared) DHT members. - * - * @return void - * @todo Add timestamp to dataset instance - */ - public function initEntryPublication () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - /* - * Make sure that hasUnpublishedEntries() has been called first by - * asserting on the "cached" object instance. This "caching" saves some - * needless queries as this method shall be called immediately after - * hasUnpublishedEntries() returns TRUE. - */ - assert($this->unpublishedEntriesInstance instanceof SearchableResult); - - // Result is still okay? - assert($this->unpublishedEntriesInstance->valid()); - - // Remove 'publication_status' - $this->getSearchInstance()->unsetCriteria(self::DB_COLUMN_PUBLICATION_STATUS); - - // Make sure all entries are marked as pending, first get a dataset instance. - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); - - // Add search instance - $dataSetInstance->setSearchInstance($this->getSearchInstance()); - - // Set primary key (node id) - $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); - - // Add criteria (that should be set) - $dataSetInstance->addCriteria(self::DB_COLUMN_PUBLICATION_STATUS, self::PUBLICATION_STATUS_PENDING); - - // Run the "UPDATE" query - $this->queryUpdateDataSet($dataSetInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public function removeNonPublicDataFromArray(array $data) { - // Currently call only inner method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); - $data = parent::removeNonPublicDataFromArray($data); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: data[]=' . gettype($data)); - - // Return cleaned data - return $data; - } - - /** - * Find recipients for given package data and exclude the sender - * - * @param $packageData An array of valid package data - * @return $recipients An indexed array with DHT recipients - */ - public function getResultFromExcludedSender (array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Assert on required array field - assert(isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER])); - - // Get max recipients - $maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients'); - - // First creata a search instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Then exclude 'sender' field as the sender is the current (*this*) node - $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); - - // Set limit to maximum DHT recipients - $searchInstance->setLimit($maxRecipients); - - // Get a result instance back from DHT database wrapper. - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - - // Return result instance - return $resultInstance; - } - - /** - * Find recopients by given key/value pair. First look for the key and if it - * matches, compare the value. - * - * @param $key Key to look for - * @param $value Value to compare if key matches - * @return $recipients An indexed array with DHT recipients - */ - public function getResultFromKeyValue ($key, $value) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Get max recipients - $maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients'); - - // First creata a search instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Find the key/value pair - $searchInstance->addCriteria($key, $value); - - // Get a result instance back from DHT database wrapper. - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - - // Return result instance - return $resultInstance; - } - - /** - * Enable DHT bootstrap request acceptance for local node - * - * @return void - */ - public function enableAcceptDhtBootstrap () { - // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Enabling DHT bootstrap requests ...'); - - // Is the node already registered? - if ($this->isLocalNodeRegistered()) { - // Just update our record - $this->updateLocalNode(); - } else { - // Register it - $this->registerLocalNode(); - } - } -} - -// [EOF] -?> diff --git a/application/hub/main/database/frontend/node/class_NodeInformationDatabaseWrapper.php b/application/hub/main/database/frontend/node/class_NodeInformationDatabaseWrapper.php deleted file mode 100644 index a4c002022..000000000 --- a/application/hub/main/database/frontend/node/class_NodeInformationDatabaseWrapper.php +++ /dev/null @@ -1,186 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements NodeInformationWrapper, Registerable { - // Constants for database table names - const DB_TABLE_NODE_INFORMATION = 'node_data'; - - // Constants for database column names - const DB_COLUMN_NODE_NR = 'node_nr'; - const DB_COLUMN_NODE_ID = 'node_id'; - const DB_COLUMN_SESSION_ID = 'session_id'; - const DB_COLUMN_PRIVATE_KEY = 'private_key'; - const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash'; - const DB_COLUMN_NODE_MODE = 'node_mode'; - const DB_COLUMN_INTERNAL_UNL = 'internal_unl'; - const DB_COLUMN_EXTERNAL_UNL = 'external_unl'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createNodeInformationDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new NodeInformationDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_NODE_INFORMATION); - - // Return the instance - return $wrapperInstance; - } - - /** - * Checks whether there is an entry for given node instance - * - * @param $nodeInstance An instance of a NodeHelper class - * @return $isFound Whether a node id has been found for this node - */ - public function ifNodeDataIsFound (NodeHelper $nodeInstance) { - // Is there cache? - if (!isset($GLOBALS[__METHOD__])) { - // Now get a search criteria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Search for the node number one which is hard-coded the default - $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1); - $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $nodeInstance->getRequestInstance()->getRequestElement('mode')); - $searchInstance->setLimit(1); - - // Get a result back - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Set result instance in node instance - $nodeInstance->setResultInstance($resultInstance); - - // Is it valid? - $GLOBALS[__METHOD__] = $resultInstance->next(); - } // END - if - - // Return it - return $GLOBALS[__METHOD__]; - } - - /** - * 'Registers' a new node id along with data provided in the node instance. - * This may sound confusing but avoids double code very nicely... - * - * @param $nodeInstance A node instance - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public function registerNodeId (BaseHubNode $nodeInstance, Requestable $requestInstance) { - // Get a dataset instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); - - // Add registration elements to the dataset - $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); - - // "Insert" this dataset instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - } - - /** - * 'Registers' a new session id along with data provided in the node instance. - * This may sound confusing but avoids double code very nicely... - * - * @param $nodeInstance An instance of a BaseHubNode class - * @param $requestInstance An instance of a Requestable class - * @param $searchInstance An instance of a LocalSearchCriteria class - * @return void - */ - public function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) { - // Get a dataset instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); - - // Set search instance - $dataSetInstance->setSearchInstance($searchInstance); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); - - // Add registration elements to the dataset - $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); - - // Update database record - $this->queryUpdateDataSet($dataSetInstance); - } - - /** - * 'Registers' a private key along with data provided in the node instance. - * This may sound confusing but avoids double code very nicely... - * - * @param $nodeInstance An instance of a BaseHubNode class - * @param $requestInstance An instance of a Requestable class - * @param $searchInstance An instance of a LocalSearchCriteria class - * @return void - */ - public function registerPrivateKey (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) { - // Get a dataset instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); - - // Set search instance - $dataSetInstance->setSearchInstance($searchInstance); - - // Add registration elements to the dataset - $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); - - // Update database record - $this->queryUpdateDataSet($dataSetInstance); - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public function removeNonPublicDataFromArray(array $data) { - // Currently call only inner method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); - $data = parent::removeNonPublicDataFromArray($data); - - // Return cleaned data - return $data; - } -} - -// [EOF] -?> diff --git a/application/hub/main/database/frontend/states/.htaccess b/application/hub/main/database/frontend/states/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/database/frontend/states/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php b/application/hub/main/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php deleted file mode 100644 index 64d9f9df8..000000000 --- a/application/hub/main/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php +++ /dev/null @@ -1,274 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements LookupablePeerState { - // Exception constants - const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300; - - // Constants for database table names - const DB_TABLE_PEER_LOOKUP = 'peer_states'; - - // Constants for database column names - const DB_COLUMN_PEER_IP = 'peer_ip'; - const DB_COLUMN_PEER_PORT = 'peer_port'; - const DB_COLUMN_PEER_SESSION_ID = 'peer_session_id'; - const DB_COLUMN_PEER_STATE = 'peer_state'; - const DB_COLUMN_SOCKET_ERROR_CODE = 'socket_error_code'; - const DB_COLUMN_SOCKET_ERROR_MSG = 'socket_error_msg'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createPeerStateLookupDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new PeerStateLookupDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_PEER_LOOKUP); - - // Return the instance - return $wrapperInstance; - } - - /** - * "Getter" for a LocalSearchCriteria from given package data's sender - * - * @param $packageData Valid raw package data array - * @return $searchInstance An instance of a LocalSearchCriteria class - */ - private function getSenderSearchInstanceFromPackageData (array $packageData) { - // Get the instance - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: Searching for sender ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add 'sender' as the peer's IP address - $searchInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); - $searchInstance->setLimit(1); - - // Return the instance - return $searchInstance; - } - - /** - * Checks whether given 'sender' is a new peer - * - * @param $packageData Raw package data - * @param $dataSetInstance An optional instance of a StoreableCriteria class - * @return $isNewPeer Whether 'sender' is a new peer to this peer - */ - public function isSenderNewPeer (array $packageData, StoreableCriteria $dataSetInstance = NULL) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: ' . __FUNCTION__ . ' called with packageData()=' . count($packageData) . ' - CALLED!'); - - // Is the package valid? - if (!isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER])) { - // Invalid package found, please report this - $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE)); - } // END - if - - // Get a search criteria instance from package data - $searchInstance = $this->getSenderSearchInstanceFromPackageData($packageData); - - // Is the dataset instance set? - if ($dataSetInstance instanceof StoreableCriteria) { - // Then remember the search instance in it - $dataSetInstance->setSearchInstance($searchInstance); - } // END - if - - // Count the query - $entries = $this->doSelectCountByCriteria($searchInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); - - // Is it there? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: entries=' . $entries); - $isNewPeer = ($entries != 1); - - // Return the result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!'); - return $isNewPeer; - } - - /** - * Registers a new peer with given package data. We use the session id from it. - * - * @param $packageData Raw package data - * @param $socketResource A valid socket resource - * @return void - * @throws PeerAlreadyRegisteredException If a peer is already registered - */ - public function registerPeerByPackageData (array $packageData, $socketResource) { - // Make sure only new peers can be registered with package data - if (!$this->isSenderNewPeer($packageData)) { - // Throw an exception because this should normally not happen - throw new PeerAlreadyRegisteredException(array($this, $packageData), self::EXCEPTION_PEER_ALREADY_REGISTERED); - } // END - if - - // Generate a dataset instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP)); - - // Session ids must be unique - $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID); - - // Add session id - $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); - - // Get peer name - if (!@socket_getpeername($socketResource, $peerName, $peerPort)) { - // Get last error - $lastError = socket_last_error($socketResource); - - // ... and cleartext message from it and put both into criteria - $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_CODE, $lastError); - $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_MSG , socket_strerror($lastError)); - } // END - if - - // Add ip address and port - $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP , $peerName); - $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $peerPort); - - // "Insert" the data set - $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER] . ' has been registered.'); - } - - /** - * Registers the given peer state and raw package data - * - * @param $stateInstance A PeerStateable class instance - * @param $packageData Valid package data array - * @return void - * @throws PeerAlreadyRegisteredException If a peer is already registered - * @todo Unfinished area - */ - public function registerPeerState (PeerStateable $stateInstance, array $packageData) { - // Generate a dataset instance - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP)); - - // Session ids must be unique - $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID); - - // Add session id - $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]); - $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_STATE , $stateInstance->getStateName()); - - // Try to resolve sender's session id - $senderData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_SENDER])); - - // Just make sure that 'invalid:invalid' is not being processed - assert(($senderData[0] != 'invalid') && ($senderData[1] != 'invalid') && ($senderData[2] != 'invalid')); - - // Add ip address and port - $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP , $senderData[0]); - $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $senderData[1]); - - // Is this a new peer? - if ($this->isSenderNewPeer($packageData, $dataSetInstance)) { - // "Insert" the data set - $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); - } else { - // Update the data set - $this->queryUpdateDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER] . ' has been registered/updated with state ' . $stateInstance->getStateName()); - } - - /** - * Purges old entries of given socket resource. We use the IP address from that resource. - * - * @param $socketResource A valid socket resource - * @return void - * @throws InvalidSocketException If the socket resource was invalid - * @todo Unfinished area - */ - public function purgeOldEntriesBySocketResource ($socketResource) { - // Get peer name - if (!@socket_getpeername($socketResource, $peerName, $peerPort)) { - // Get last error - $lastError = socket_last_error($socketResource); - - // Doesn't work! - throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: peerName=' . $peerName . ',peerPort=' . $peerPort . ' - UNFINISHED!'); - } - - /** - * Checks whether a given peer state (in helper instance) is same as stored - * in database compared with the one from $helperInstance. - * - * @param $helperInstance An instance of a ConnectionHelper class - * @param $packageData Valid package data array - * @return $isSamePeerState Whether the peer's state is the same - */ - public function isSamePeerState (ConnectionHelper $helperInstance, array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...'); - - // Now get the search instance from given package data - $searchInstance = $this->getSenderSearchInstanceFromPackageData($packageData); - - // With this search instance query the database for the peer and get a result instance - $resultInstance = $this->doSelectByCriteria($searchInstance); - - // Do we have an entry? This should always the case - assert($resultInstance->next()); - - // Yes, so get the current (=first) entry from it - $rowData = $resultInstance->current(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE)); - - // Assert on important elements - assert(isset($rowData[self::DB_COLUMN_PEER_STATE])); - - // Now just compare it with given state from helper instance - $isSamePeerState = ($rowData[self::DB_COLUMN_PEER_STATE] == $helperInstance->getPrintableState()); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState)); - - // Return it - return $isSamePeerState; - } -} - -// [EOF] -?> diff --git a/application/hub/main/decoder/.htaccess b/application/hub/main/decoder/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/decoder/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/decoder/class_ b/application/hub/main/decoder/class_ deleted file mode 100644 index a9d980b8b..000000000 --- a/application/hub/main/decoder/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Decoder extends BaseDecoder implements Decodeable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $decoderInstance An instance of a Decodeable class - */ - public final static function create???Decoder () { - // Get new instance - $decoderInstance = new ???Decoder(); - - // Return the prepared instance - return $decoderInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/decoder/class_BaseDecoder.php b/application/hub/main/decoder/class_BaseDecoder.php deleted file mode 100644 index ba2a1e43d..000000000 --- a/application/hub/main/decoder/class_BaseDecoder.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseDecoder extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/decoder/package/.htaccess b/application/hub/main/decoder/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/decoder/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/decoder/package/class_PackageDecoder.php b/application/hub/main/decoder/package/class_PackageDecoder.php deleted file mode 100644 index 49ba434c5..000000000 --- a/application/hub/main/decoder/package/class_PackageDecoder.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { - /** - * Name for stacker for received packages - */ - const STACKER_NAME_DECODED_PACKAGE = 'decoded_package'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $handlerInstance An instance of a HandleableChunks class - * @return $decoderInstance An instance of a Decodeable class - */ - public final static function createPackageDecoder (HandleableChunks $handlerInstance) { - // Get new instance - $decoderInstance = new PackageDecoder(); - - // Init stacker for received packages - $handlerInstance->getStackInstance()->initStack(self::STACKER_NAME_DECODED_PACKAGE); - - // Set the handler instance here - $decoderInstance->setHandlerInstance($handlerInstance); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // And set it in this decoder - $decoderInstance->setPackageInstance($packageInstance); - - // Return the prepared instance - return $decoderInstance; - } - - /** - * Checks whether the assoziated stacker for raw package data has some entries left - * - * @return $unhandledDataLeft Whether some unhandled raw package data is left - */ - public function ifUnhandledRawPackageDataLeft () { - // Check it - $unhandledDataLeft = (!$this->getHandlerInstance()->getStackInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA)); - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: unhandledDataLeft=' . intval($unhandledDataLeft)); - return $unhandledDataLeft; - } - - /** - * Handles raw package data by decoding it - * - * @return void - */ - public function handleRawPackageData () { - // Assert on it to make sure the next popNamed() call won't throw an exception - assert($this->ifUnhandledRawPackageDataLeft()); - - // "Pop" the next raw package content - $rawPackageContent = $this->getHandlerInstance()->getStackInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...'); - - // "Decode" the raw package content by using the NetworkPackage instance - $decodedData = $this->getPackageInstance()->decodeRawContent($rawPackageContent); - - // Some checks - assert( - (is_array($decodedData)) && - (isset($decodedData[NetworkPackage::PACKAGE_DATA_SENDER])) && - (isset($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && - (isset($decodedData[NetworkPackage::PACKAGE_DATA_CONTENT])) && - (isset($decodedData[NetworkPackage::PACKAGE_DATA_STATUS])) - ); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); - - // Next get a recipient-discovery instance - $discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance(); - - // ... then disover all recipient (might be only one), this package may shall be forwarded - $discoveryInstance->discoverRawRecipients($decodedData); - - // Check for 'recipient' field (the 'sender' field and others are ignored here) - if ($discoveryInstance->isRecipientListEmpty()) { - // The recipient is this node so next stack it on 'decoded_package' - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...'); - $this->getHandlerInstance()->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData); - } else { - // Forward the package to the next node - $this->getPackageInstance()->forwardRawPackage($decodedData); - } - } - - /** - * Checks whether decoded packages have arrived (for this peer) - * - * @return $ifRawPackagesLeft Whether decoded packages have arrived - */ - public function ifDeocedPackagesLeft () { - // Check it ... - $ifRawPackagesLeft = (!$this->getHandlerInstance()->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE)); - - // ... return it - return $ifRawPackagesLeft; - } - - /** - * Handles received decoded packages internally (recipient is this node) - * - * @return void - */ - public function handleDecodedPackage () { - // Assert on amount - assert($this->ifDeocedPackagesLeft()); - - // Get the next entry (assoziative array) - $decodedData = $this->getHandlerInstance()->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE); - - // Handle it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); - $this->getPackageInstance()->handleRawData($decodedData); - } -} - -// [EOF] -?> diff --git a/application/hub/main/dht/.htaccess b/application/hub/main/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/dht/class_ b/application/hub/main/dht/class_ deleted file mode 100644 index 92d40c8f5..000000000 --- a/application/hub/main/dht/class_ +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???DhtFacade extends BaseDht implements Distributable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $dhtInstance An instance of a Distributable class - */ - public final static function create??? () { - // Get new instance - $dhtInstance = new ???DhtFacade(); - - // Return the prepared instance - return $dhtInstance; - } - - /** - * Registers/updates an entry in the DHT with given data from $dhtData - * array. Different DHT implemtations may handle this differently as they - * may enrich the data with more meta data. - * - * @param $dhtData A valid array with DHT-related data (e.g. node/peer data) - * @return void - * @todo 0% done - */ - protected function insertDataIntoDht (array $dhtData) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/dht/class_BaseDht.php b/application/hub/main/dht/class_BaseDht.php deleted file mode 100644 index 5452bc00e..000000000 --- a/application/hub/main/dht/class_BaseDht.php +++ /dev/null @@ -1,262 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseDht extends BaseHubSystem implements Distributable { - /** - * "Cached" instance of a publish helper - */ - private $publishHelperInstance = NULL; - - /** - * Stacker name for "INSERT" node data - */ - const STACKER_NAME_INSERT_NODE = 'dht_insert_node'; - const STACKER_NAME_PENDING_PUBLISHING = 'dht_pending_publish'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Get a stacker instance for this DHT - $stackInstance = ObjectFactory::createObjectByConfiguredName('dht_stacker_class'); - - // Set it in this class - $this->setStackInstance($stackInstance); - - // Init all stackers - $this->initStacks(); - - // Get the state factory and create the initial state. - DhtStateFactory::createDhtStateInstanceByName('init', $this); - } - - /** - * Initializes all stackers - * - * @return void - */ - private function initStacks () { - // Initialize all stacker - $this->getStackInstance()->initStacks(array( - self::STACKER_NAME_INSERT_NODE, - self::STACKER_NAME_PENDING_PUBLISHING, - )); - } - - /** - * Registers/updates an entry in the DHT with given data from $dhtData - * array. Different DHT implemtations may handle this differently as they - * may enrich the data with more meta data. - * - * @param $dhtData A valid array with DHT-related data (e.g. node/peer data) - * @return void - */ - protected abstract function insertDataIntoDht (array $dhtData); - - /** - * Updates/refreshes DHT data (e.g. status). - * - * @return void - * @todo Find more to do here - */ - public function updateDhtData () { - // Set some dummy configuration entries, e.g. dht_status - $this->getConfigInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName()); - } - - /** - * Checks whether there are entries in "INSERT" node data stack - * - * @return $isPending Whether there are pending entries - */ - public function ifInsertNodeDataPending () { - // Determine it if it is not empty - $isPending = ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_INSERT_NODE) === FALSE); - - // Return status - return $isPending; - } - - /** - * Inserts a single entry of node data into the DHT - * - * @return void - */ - public function insertSingleNodeData () { - // Get next node data from stack - $nodeData = $this->getStackInstance()->popNamed(self::STACKER_NAME_INSERT_NODE); - - // Make sure $nodeData is really an array and has at least one entry - assert((is_array($nodeData)) && (count($nodeData) > 0)); - - // Insert the data - $this->insertDataIntoDht($nodeData); - } - - /** - * Checks whether there are unpublished entries - * - * @return $hasUnpublished Whether there are unpublished entries - * @todo Add minimum/maximum age limitations - */ - public function hasUnpublishedEntries () { - // Call method on database wrapper - $hasUnpublished = $this->getWrapperInstance()->hasUnpublishedEntries(); - - // Return it - return $hasUnpublished; - } - - /** - * Initializes publication of DHT entries. This does only prepare - * publication. The next step is to pickup such prepared entries and publish - * them by uploading to other (recently appeared) DHT members. - * - * @return void - */ - public function initEntryPublication () { - // Call method on database wrapper - $this->getWrapperInstance()->initEntryPublication(); - - // Get result instance - $resultInstance = $this->getWrapperInstance()->getUnpublishedEntriesInstance(); - - // Make sure the result instance is valid - assert($resultInstance instanceof SearchableResult); - assert($resultInstance->valid()); - - // "Walk" through all entries - while ($resultInstance->next()) { - // Get current entry - $current = $resultInstance->current(); - - // Make sure only valid entries pass - // @TODO Maybe add more small checks? - assert(is_array($current)); - - // ... and push it to the next stack - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] Pushing entry with ' . count($current) . ' elements to stack ' . self::STACKER_NAME_PENDING_PUBLISHING . ' ...'); - $this->getStackInstance()->pushNamed(self::STACKER_NAME_PENDING_PUBLISHING, $current); - } // END - while - } - - /** - * Checks whether there are entries pending publication - * - * @return $isPending Whether there are entries pending publication - */ - public function hasEntriesPendingPublication () { - // Determine it if it is not empty - $isPending = ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PENDING_PUBLISHING) === FALSE); - - // Return status - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] isPending=' . intval($isPending)); - return $isPending; - } - - /** - * Whether this DHT's state is 'booting' - * - * @return $isBooting Whether this DHT is currently booting - */ - public function ifDhtIsBooting () { - // Call state instance - $isBooting = $this->getStateInstance()->ifDhtIsBooting(); - - // Return status - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] isBooting=' . intval($isBooting)); - return $isBooting; - } - - /** - * Publishes next entry found in stack. This method shall also update the - * corresponding dabase entry. - * - * @return void - * @todo Find out if loadDescriptorXml() can be called only once to avoid a lot methods working. - */ - public function publishEntry () { - // This test must not fail - assert($this->hasEntriesPendingPublication()); - - // Is there an instance? - if (!$this->publishHelperInstance instanceof HelpableDht) { - // Get a helper instance - $this->publishHelperInstance = ObjectFactory::createObjectByConfiguredName('dht_publish_entry_helper_class'); - } // END - if - - // Load the announcement descriptor - $this->publishHelperInstance->loadDescriptorXml($this); - - // "Pop" next entry - $entry = $this->getStackInstance()->popNamed(self::STACKER_NAME_PENDING_PUBLISHING); - - // Some sanity-checks - assert(is_array($entry)); - - // Remove any non-public data the database layer desires - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT[' . __METHOD__ . ':' . __LINE__ . ']: Calling this->getWrapperInstance()->removeNonPublicDataFromArray(data) ...'); - $entry = $this->getWrapperInstance()->removeNonPublicDataFromArray($entry); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT[' . __METHOD__ . ':' . __LINE__ . ']: entry[]=' . gettype($entry)); - - // Some sanity-checks again - assert(is_array($entry)); - - // Assign multiple variables - $this->publishHelperInstance->getTemplateInstance()->assignMultipleVariables($entry); - - // "Publish" the descriptor by sending it to the bootstrap/list nodes - $this->publishHelperInstance->sendPackage($this); - } - - /** - * Whether the DHT has fully bootstrapped (after state 'booting') - * - * @return $isFullyBooted Whether the DHT is fully booted - * @todo 0% done - */ - public function hasFullyBootstrapped () { - // Get state and check it - $this->partialStub('Please implement this method.'); - } - - /** - * Enable DHT bootstrap request acceptance for local node - * - * @return void - * @todo Switch flag 'accept_bootstrap' - */ - public function enableAcceptDhtBootstrap () { - // Call method on database wrapper - $this->getWrapperInstance()->enableAcceptDhtBootstrap(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/dht/node/.htaccess b/application/hub/main/dht/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/dht/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/dht/node/class_NodeDhtFacade.php b/application/hub/main/dht/node/class_NodeDhtFacade.php deleted file mode 100644 index 18d9addbd..000000000 --- a/application/hub/main/dht/node/class_NodeDhtFacade.php +++ /dev/null @@ -1,386 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $dhtInstance An instance of a Distributable class - */ - public final static function createNodeDhtFacade () { - // Get new instance - $dhtInstance = new NodeDhtFacade(); - - // Get a database wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_dht_db_wrapper_class'); - - // Set it in this class - $dhtInstance->setWrapperInstance($wrapperInstance); - - // Return the prepared instance - return $dhtInstance; - } - - /** - * Registers/updates an entry in the DHT with given data from $dhtData - * array. Different DHT implemtations may handle this differently as they - * may enrich the data with more meta data. - * - * @param $dhtData A valid array with DHT-related data (e.g. node/peer data) - * @return void - * @todo Does this data need to be enriched with more meta data? - */ - protected function insertDataIntoDht (array $dhtData) { - // Check if there is already an entry for given node_id - if ($this->getWrapperInstance()->isNodeRegistered($dhtData)) { - /* - * Update existing record. Please note that this step is not secure - * (e.g. DHT poisoning) it would be good to implement some checks if - * the both node owner trust each other (see sub-project 'DSHT'). - */ - $this->getWrapperInstance()->updateNode($dhtData); - } else { - /* - * Inserts given node data into the DHT. As above, this step does - * currently not perform any security checks. - */ - $this->getWrapperInstance()->registerNode($dhtData); - } - } - - /** - * Initializes the distributed hash table (DHT) - * - * @return void - */ - public function initDht () { - // Is the local node registered? - if ($this->getWrapperInstance()->isLocalNodeRegistered()) { - // Then only update session id - $this->getWrapperInstance()->updateLocalNode(); - } else { - // No, so register it - $this->getWrapperInstance()->registerLocalNode(); - } - - // Change state - $this->getStateInstance()->dhtHasInitialized(); - } - - /** - * Bootstraps the DHT by sending out a message to all available nodes - * (including itself). This step helps the node to get to know more nodes - * which can be queried later for object distribution. - * - * @return void - */ - public function bootstrapDht () { - // Get a helper instance - $helperInstance = ObjectFactory::createObjectByConfiguredName('dht_bootstrap_helper_class'); - - // Load the announcement descriptor - $helperInstance->loadDescriptorXml($this); - - // Compile all variables - $helperInstance->getTemplateInstance()->compileConfigInVariables(); - - // "Publish" the descriptor by sending it to the bootstrap/list nodes - $helperInstance->sendPackage($this); - - // Change state - $this->getStateInstance()->dhtIsBooting(); - } - - /** - * Finds a node locally by given session id - * - * @param $sessionId Session id to lookup - * @return $nodeData Node-data array - */ - public function findNodeLocalBySessionId ($sessionId) { - // Default is empty data array - $nodeData = array(); - - /* - * Call the wrapper to do the job and get back a result instance. There - * will come back zero or one entry from the wrapper. - */ - $resultInstance = $this->getWrapperInstance()->findNodeLocalBySessionId($sessionId); - - // Make sure the result instance is valid - assert($resultInstance instanceof SearchableResult); - - // Is the next entry valid? - if (($resultInstance->valid()) && ($resultInstance->next())) { - /* - * Then load the first entry (more entries are being ignored and - * should not happen). - */ - $nodeData = $resultInstance->current(); - } // END - if - - // Return node data - return $nodeData; - } - - /** - * Registers an other node with this node by given message data. The - * following data must always be present: - * - * - session-id (for finding the node's record together with below data) - * - external-address (hostname or IP number) - * - listen-port (TCP/UDP listen port for inbound connections) - * - * @param $messageArray An array with all minimum message data - * @param $handlerInstance An instance of a HandleableDataSet class - * @param $forceUpdate Optionally force update, don't register (default: register if not found) - * @return void - * @throws NodeSessionIdVerficationException If the node was not found and update is forced - */ - public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, $forceUpdate = FALSE) { - // Get a search criteria class - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, TRUE) . ',handlerInstance=' . $handlerInstance->__toString() . ',forceUpdate=' . intval($forceUpdate) . ',count(getSearchData())=' . count($handlerInstance->getSearchData())); - - // Search for the node's session id and external address/hostname + TCP/UDP listen port - foreach ($handlerInstance->getSearchData() as $key) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',key=' . $key); - - // Is it there? - assert(isset($messageData[$key])); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData[' . $key . ']=' . $messageData[$key]); - - // Add criteria - $searchInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); - } // END - foreach - - // Only one entry is fine - $searchInstance->setLimit(1); - - // Run the query - $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance); - - // Make sure the result instance is valid - assert($resultInstance instanceof SearchableResult); - - // Is there already an entry? - if ($resultInstance->valid()) { - // Entry found, so update it - $this->getWrapperInstance()->updateNodeByMessageData($messageData, $handlerInstance, $searchInstance); - } elseif ($forceUpdate === FALSE) { - // Nothing found, so register it - $this->getWrapperInstance()->registerNodeByMessageData($messageData, $handlerInstance); - } else { - /* - * Do not register non-existent nodes here. This is maybe fatal, - * caused by "stolen" session id and/or not matching address. - */ - throw new NodeSessionIdVerficationException(array($this, $messageData), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING); - } - - // Save last exception - $handlerInstance->setLastException($this->getWrapperInstance()->getLastException()); - } - - /** - * Queries the local DHT data(base) for a node list with all supported - * object types except the node by given session id. - * - * @param $messageData An array with message data from a node_list request - * @param $handlerInstance An instance of a HandleableDataSet class - * @param $excludeKey Array key which should be excluded - * @param $andKey Array of $separator-separated list of elements which all must match - * @param $separator Sepator char (1st parameter for explode() call) - * @return $nodeList An array with all found nodes - */ - public function queryLocalNodeListExceptByMessageData (array $messageData, HandleableDataSet $handlerInstance, $excludeKey, $andKey, $separator) { - // Make sure both keys are there - assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey]))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, TRUE)); - - // Get a search criteria class - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add all keys - foreach (explode($separator, $messageData[$andKey]) as $criteria) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: andKey=' . $andKey . ',criteria=' . $criteria); - - // Add it and leave any 'my-' prefix out - $searchInstance->addChoiceCriteria(str_replace('my-', '', $andKey), $criteria); - } // END - foreach - - // Add exclusion key - $searchInstance->addExcludeCriteria(str_replace('my-', '', $excludeKey), $messageData[$excludeKey]); - - // Only X entries are fine - $searchInstance->setLimit($this->getConfigInstance()->getConfigEntry('node_dht_list_limit')); - - // Run the query - $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance); - - // Make sure the result instance is valid - assert($resultInstance instanceof SearchableResult); - assert($resultInstance->valid()); - - // Init array - $nodeList = array(); - - // Get node list - while ($resultInstance->next()) { - // Get current element (it should be an array, and have at least 1 entry) - $current = $resultInstance->current(); - assert(is_array($current)); - assert(count($current) > 0); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: current(' . count($current) . ')[' . gettype($current) . ']=' . print_r($current, TRUE)); - - /* - * Remove some keys as they should not be published. - */ - unset($current[$this->getWrapperInstance()->getIndexKey()]); - - // Add this entry - array_push($nodeList, $current); - } // END - while - - // Save last exception - $handlerInstance->setLastException($this->getWrapperInstance()->getLastException()); - - // Return node list (array) - return $nodeList; - } - - /** - * Inserts given node list array (from earlier database result produced by - * an other node) into the DHT. This array origins from above method - * queryLocalNodeListExceptByMessageData(). - * - * @param $nodeList An array from an earlier database result instance - * @return void - */ - public function insertNodeList (array $nodeList) { - // If no node is in the list (array), skip the rest of this method - if (count($nodeList) == 0) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: No node record has been returned.'); - - // Abort here - return; - } // END - if - - // Put them all into a stack - foreach ($nodeList as $nodeData) { - // Insert all entries - $this->getStackInstance()->pushNamed(self::STACKER_NAME_INSERT_NODE, $nodeData); - } // END - foreach - } - - /** - * Find recipients for given package data - * - * @param $packageData An array of valid package data - * @return $recipients An indexed array with DHT recipients - */ - public function findRecipientsByPackageData (array $packageData) { - // Query get a result instance back from DHT database wrapper. - $resultInstance = $this->getWrapperInstance()->getResultFromExcludedSender($packageData); - - // Make sure the result instance is valid - assert($resultInstance instanceof SearchableResult); - - // No entries found? - if (!$resultInstance->valid()) { - // Then skip below loop - return array(); - } // END - if - - // Init array - $recipients = array(); - - // Search for all recipients - while ($resultInstance->next()) { - // Get current entry - $current = $resultInstance->current(); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: current=' . print_r($current, TRUE)); - - // Add instance to recipient list - array_push($recipients, $current); - } // END - while - - // Return filled array - return $recipients; - } - - /** - * Finds DHT recipients by given key/value pair - * - * @param $key Key to search for - * @param $value Value to check on found key - * @return $recipiens Array with DHT recipients from given key/value pair - */ - public function findRecipientsByKey ($key, $value) { - // Look for all suitable nodes - $resultInstance = $this->getWrapperInstance()->getResultFromKeyValue($key, $value); - - // Make sure the result instance is valid - assert($resultInstance instanceof SearchableResult); - assert($resultInstance->valid()); - - // Init array - $recipients = array(); - - // "Walk" through all entries - while ($resultInstance->next()) { - // Get current entry - $current = $resultInstance->current(); - - // Add instance to recipient list - array_push($recipients, $current); - } // END - while - - // Return filled array - return $recipients; - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/.htaccess b/application/hub/main/discovery/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/discovery/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/discovery/class_ b/application/hub/main/discovery/class_ deleted file mode 100644 index fc0d85a69..000000000 --- a/application/hub/main/discovery/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class !!!Discovery extends BaseNodeDiscovery implements Discoverable,,,, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public static final function create!!!Discovery () { - // Get an instance of this class - $discoveryInstance = new !!!Discovery(); - - // Return the prepared instance - return $discoveryInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/class_BaseNodeDiscovery.php b/application/hub/main/discovery/class_BaseNodeDiscovery.php deleted file mode 100644 index 72c2dd8e2..000000000 --- a/application/hub/main/discovery/class_BaseNodeDiscovery.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseNodeDiscovery extends BaseDiscovery implements Discoverable { - /** - * Protected constructor - * - * @param $className Real class name - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/node/.htaccess b/application/hub/main/discovery/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/discovery/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php b/application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php deleted file mode 100644 index 0501bdabc..000000000 --- a/application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UniversalNodeLocatorDiscovery extends BaseNodeDiscovery implements DiscoverableUniversalNodeLocator, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public static final function createUniversalNodeLocatorDiscovery () { - // Get an instance of this class - $discoveryInstance = new UniversalNodeLocatorDiscovery(); - - // Return the prepared instance - return $discoveryInstance; - } - - /** - * "Discovers" an instance of a LocateableNode class for given NodeHelper class - * - * @param $nodeInstance An instance of a NodeHelper class - * @return $unlInstance An instance of a LocateableNode class - */ - public function discoverUniversalNodeLocatorByNode (NodeHelper $nodeInstance) { - /* - * First get an instance from the configured hub communication protocol - * type (which is mostly TCP, so you get a TcpProtocolResolver here). - */ - $resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol(); - - // Then resolve the node instance into an UNL instance - $unlInstance = $resolverInstance->resolveUniversalNodeLocatorFromNodeHelper($nodeInstance); - - // ... and return it - return $unlInstance; - } - - /** - * "Discovers" the full universal node locator for given configuration entry - * which should represent the address part of the UNL. In case of an IP - * address, this *must not* include the port number as this is being found - * out for you. - * - * Valid values for $configKey: internal,external - * - * @param $configKey Key for address to get (valid: internal,external) - * @return $unl Universal node locator - */ - public function discoverUniversalNodeLocatorByConfiguredAddress ($configKey) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UNL-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']:configKey=' . $configKey . ' - CALLED!'); - - // Is there cache? - if (!isset($GLOBALS[__METHOD__][$configKey])) { - // Validate config key - assert(($configKey == 'internal') || ($configKey == 'external')); - - /* - * First get an instance from the configured hub communication protocol - * type (which is mostly TCP, so you get a TcpProtocolResolver here). - */ - $resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol(); - - // Get back the full UNL - $GLOBALS[__METHOD__][$configKey] = $resolverInstance->resolveUniversalNodeLocatorFromConfigKey($configKey); - } // END - if - - // Return cached value - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UNL-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']:configKey=' . $configKey . ',unl=' . $GLOBALS[__METHOD__][$configKey] . ' - EXIT!'); - return $GLOBALS[__METHOD__][$configKey]; - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/protocol/.htaccess b/application/hub/main/discovery/protocol/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/discovery/protocol/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/discovery/protocol/class_ProtocolDiscovery.php b/application/hub/main/discovery/protocol/class_ProtocolDiscovery.php deleted file mode 100644 index 82ac8c693..000000000 --- a/application/hub/main/discovery/protocol/class_ProtocolDiscovery.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ProtocolDiscovery extends BaseNodeDiscovery implements DiscoverableProtocol, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public static final function createProtocolDiscovery () { - // Get an instance of this class - $discoveryInstance = new ProtocolDiscovery(); - - // Return the prepared instance - return $discoveryInstance; - } - - /** - * Determines the protoctol name - * - * @param $packageData Valid package data - * @return $protocolInstance An instance of a HandleableProtocol class - */ - public static final function determineProtocolByPackageData (array $packageData) { - // First we need a tags instance - $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); - - /* - * We need to decide here which socket (TCP or UDP) should be used for - * the actual data transmission. In this process we will find out if - * the recipient of this package has already a known (registered) socket - * and if so we can re-use it. If there is no socket registered, we try - * to make a new connection to the given Universal Node Locator. - */ - $protocolInstance = $tagsInstance->chooseProtocolFromPackageData($packageData); - - // Return it - return $protocolInstance; - } - - /** - * "Discovers" the protocol type from given raw package data. This is done - * by looking at the 'recipient' field and extract the first part from it. - * - * @param $packageData Raw package data - * @return $protocolType Type of protocol, e.g. 'tcp' for TCP/IPv4 connections - */ - public static final function discoverProtocolByPackageData (array $packageData) { - //* DEBUG: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE)); - - /* - * "Explode" the 'recipient' array element into a new one, giving at - * least two entries: protocol://address - */ - $recipient = explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); - - // At least 2 entries must be found - assert(count($recipient) >= 2); - - // Now get the first part (protocol type) and make all lower-case - $protocolType = strtolower($recipient[0]); - - // Return it - // @TODO Add some validation here??? - return $protocolType; - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/recipient/.htaccess b/application/hub/main/discovery/recipient/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/discovery/recipient/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/discovery/recipient/class_ b/application/hub/main/discovery/recipient/class_ deleted file mode 100644 index 6a792f53f..000000000 --- a/application/hub/main/discovery/recipient/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class !!!RecipientDiscovery extends BaseRecipientDiscovery implements Discoverable,,,Recipient, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public static final function create!!!Discovery () { - // Get an instance of this class - $discoveryInstance = new !!!Discovery(); - - // Return the prepared instance - return $discoveryInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/recipient/class_BaseRecipientDiscovery.php b/application/hub/main/discovery/recipient/class_BaseRecipientDiscovery.php deleted file mode 100644 index 9ad0f612e..000000000 --- a/application/hub/main/discovery/recipient/class_BaseRecipientDiscovery.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseRecipientDiscovery extends BaseNodeDiscovery implements DiscoverableRecipient { - /** - * Protected constructor - * - * @param $className Real class name - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - /* - * Get recipients list instance and set it here for all discovery - * implementations. - */ - $listInstance = RecipientListFactory::createRecipientListInstance(); - $this->setListInstance($listInstance); - } - - /** - * "Getter" for recipient iterator - * - * @return$iteratorInstance An instance of a Iterateable object - */ - public final function getIterator () { - // Get iterator from it - $iteratorInstance = $this->getListInstance()->getIterator(); - - // Return it - return $iteratorInstance; - } - - /** - * Clears all recipients for e.g. another package to deliver. This method - * simply clears the inner list instance. - * - * @return void - */ - public final function clearRecipients () { - // Clear the list - $this->getListInstance()->clearList(); - } - - /** - * Checks whether the recipient list is empty - * - * @return $isEmpty Whether the recipient list is empty - */ - public final function isRecipientListEmpty () { - // Check it ... - $isEmpty = ($this->getListInstance()->count() == 0); - - // Return it - return $isEmpty; - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/recipient/dht/.htaccess b/application/hub/main/discovery/recipient/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/discovery/recipient/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/discovery/recipient/dht/class_DhtRecipientDiscovery.php b/application/hub/main/discovery/recipient/dht/class_DhtRecipientDiscovery.php deleted file mode 100644 index f090f1d30..000000000 --- a/application/hub/main/discovery/recipient/dht/class_DhtRecipientDiscovery.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtRecipientDiscovery extends BaseRecipientDiscovery implements DiscoverableDhtRecipient, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public static final function createDhtRecipientDiscovery () { - // Get an instance of this class - $discoveryInstance = new DhtRecipientDiscovery(); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set it here - $discoveryInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $discoveryInstance; - } - - /** - * Resolves one or more recipients for a DHT transfer by given package data. - * - * @param $packageData Valid package data array - * @return $recipients An indexed array with DHT recipients - */ - public function resolveRecipientsByPackageData (array $packageData) { - // Use facade to get recipients back - $recipients = $this->getDhtInstance()->findRecipientsByPackageData($packageData); - - // Return it - return $recipients; - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/recipient/package/.htaccess b/application/hub/main/discovery/recipient/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/discovery/recipient/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/discovery/recipient/package/class_PackageRecipientDiscovery.php b/application/hub/main/discovery/recipient/package/class_PackageRecipientDiscovery.php deleted file mode 100644 index 72e879400..000000000 --- a/application/hub/main/discovery/recipient/package/class_PackageRecipientDiscovery.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageRecipientDiscovery extends BaseRecipientDiscovery implements DiscoverableNodeRecipient, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public static final function createPackageRecipientDiscovery () { - // Get an instance of this class - $discoveryInstance = new PackageRecipientDiscovery(); - - // Return the prepared instance - return $discoveryInstance; - } - - /** - * Tries to discover all recipients for given package data - * - * @param $packageData Raw package data array - * @return void - */ - public function discoverRecipients (array $packageData) { - // This must be available - //* DEBUG: */ print $this->__toString() . ': packageData=' . print_r($packageData, TRUE); - assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); - - // First try out the direct recipient (session id) - try { - // Get instance (should not break) - $recipientInstance = ObjectFactory::createObjectByConfiguredName('direct_recipient_class'); - - // Try to solve it - $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData); - } catch (FrameworkException $e) { - // Didn't work, so try the non-generic, depending recipient field itself (this may fail) - try { - // Try to find the right class - $recipientInstance = ObjectFactory::createObjectByConfiguredName(strtolower($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) . '_recipient_class'); - - // And try to solve again - $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData); - } catch (FrameworkException $e) { - // Could not find class, what ever failed - $this->debugInstance($e->getMessage()); - } - } - } - - /** - * Tries to discover all recipients by given decoded package data. - * - * @param $decodedData Raw raw package data array - * @return void - * @todo Add some validation of recipient field, e.g. an Universal Node Locator is found - * @todo Enrich both messages with recipient data - */ - public function discoverRawRecipients (array $decodedData) { - // This must be available - assert(isset($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); - - // First clear all recipients - $this->clearRecipients(); - - // Get a protocol handler back from decoded data - $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($decodedData); - - // Is the 'recipient' field same as this peer's IP? - if ($handlerInstance->isOwnAddress($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) { - /* - * Is same as own external address + TCP/UDP listen port or - * internal address, don't do anything here so other classes found - * an empty recipient list for internal (own) handling of the - * original content. - */ - - // Debug output (may flood) - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' matches own ip (external=' . HubTools::determineOwnExternalAddress() . ' or internal=' . HubTools::determineOwnInternalAddress() . ')'); - } else { - // Debug output (may flood) - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' is different than own external address (' . HubTools::determineOwnExternalAddress() . ') nor internal address (' . HubTools::determineOwnInternalAddress() . '), need to forward (not yet implemented)!'); - - // This package is to be delivered to someone else, so add it - // @TODO Unfinished: $this->getListInstance()->addEntry('unl', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); - } - } -} - -// [EOF] -?> diff --git a/application/hub/main/discovery/recipient/socket/.htaccess b/application/hub/main/discovery/recipient/socket/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/discovery/recipient/socket/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/main/discovery/recipient/socket/class_PackageSocketDiscovery.php deleted file mode 100644 index 698c44cb1..000000000 --- a/application/hub/main/discovery/recipient/socket/class_PackageSocketDiscovery.php +++ /dev/null @@ -1,206 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageSocketDiscovery extends BaseRecipientDiscovery implements DiscoverableSocket, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public static final function createPackageSocketDiscovery () { - // Get an instance of this class - $discoveryInstance = new PackageSocketDiscovery(); - - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Initialized.'); - - // Return the prepared instance - return $discoveryInstance; - } - - /** - * Tries to dicover the right listener instance - * - * @param $protocolInstance An instance of a HandleableProtocol class - * @param $packageData Raw package data - * @return $listenerInstance An instance of a Listenable instance or null - */ - public function discoverListenerInstance (HandleableProtocol $protocolInstance, array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolInstance=' . $protocolInstance->__toString() . ' - CALLED!'); - - /* - * Get the listener pool instance, we need to lookup the matching - * listener->poolInstance chain there. - */ - $poolInstance = NodeObjectFactory::createNodeInstance()->getListenerPoolInstance(); - - // Init listener instance - $listenerInstance = NULL; - - // Get handler name - $protocolName = $protocolInstance->getProtocolName(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',poolEntriesInstance=' . $poolInstance->getPoolEntriesInstance()->__toString()); - - /* - * Now we need to choose again. It is whether we are speaking with a hub - * or with a client. So just handle it over to all listeners in this - * pool. - */ - foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromList($protocolName) as $listenerInstance) { - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance[' . gettype($listenerInstance) . ']=' . $listenerInstance); - - // Make sure the instance is valid - assert($listenerInstance instanceof Listenable); - - // Does the listener want that package? - if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) { - // This listener likes our package data, so abort here - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is accepting package data.'); - break; - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is NOT accepting package data.'); - } // END - foreach - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: listenerInstance=' . $listenerInstance->__toString()); - - // Return it - return $listenerInstance; - } - - /** - * Tries to discover the right socket for given package data and returns a - * matching socket resource for that protocol. - * - * @param $packageData Raw package data array - * @param $connectionType Type of connection, can be 'incoming' or 'outgoing', *NEVER* 'server'! - * @return $socketResource A valid socket resource or FALSE if an error occured - * @throws NoListGroupException If the procol group is not found in peer list - * @throws NullPointerException If listenerInstance is NULL - * @throws InvalidUnlException If the provided UNL cannot be validated by the protocol handler - */ - public function discoverSocket (array $packageData, $connectionType) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: connectionType=' . $connectionType . ' - CALLED!'); - - // Assert on type and recipient - assert($connectionType != BaseConnectionHelper::CONNECTION_TYPE_SERVER); - assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); - - // Determine protocol instance - $protocolInstance = ProtocolDiscovery::determineProtocolByPackageData($packageData); - - // Is it valid? - assert($protocolInstance instanceof HandleableProtocol); - - // Does the UNL validate? - if (!$protocolInstance->isValidUniversalNodeLocatorByPackageData($packageData)) { - // Not valid, throw exception - throw new InvalidUnlException(array($this, $protocolInstance, $packageData), BaseHubSystem::EXCEPTION_INVALID_UNL); - } // END - if - - // Get the listener instance - $listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageData); - - // If there is no listener who wants to have that package, we simply drop it here - if (is_null($listenerInstance)) { - // Abort with no resource - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('protocolInstance=' . $protocolInstance . ',packageData=' . print_r($packageData, TRUE)); - - /* - * Now we have the listener instance, we can determine the right - * resource to continue. The first step is to get the attached pool - * instance and pass over the whole package data to get the right - * socket. - */ - $socketResource = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData, $connectionType); - - // Debug message - // @TODO FIXME: I don't like these abuse of variables, better strict types - if (is_resource($socketResource)) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',error=' . socket_strerror(socket_last_error($socketResource)) . ',packageData=' . print_r($packageData, TRUE)); - } else { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',packageData=' . print_r($packageData, TRUE)); - } - - // Is it FALSE, the recipient isn't known to us and we have no connection to it - if (($socketResource === FALSE) || (!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) { - // Try to create a new socket resource - try { - // Possibly noisy debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to establish a ' . strtoupper($protocolInstance) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...'); - - // Get a socket resource from our factory (if succeeded) - $socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolInstance); - } catch (SocketConnectionException $e) { - // The connection fails of being established, so log it away - self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage()); - } - } // END - if - - // Try to resolve the socket resource - try { - // Get the helper instance from registry - $helperInstance = Registry::getRegistry()->getInstance('connection'); - - // Possibly noisy debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Going to resolve socket from peer state and given package data ...'); - - // Resolve the peer's state (but ignore return value) - PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketResource); - } catch (InvalidSocketException $e) { - // This cannot be fixed, so log it away - self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage()); - - // Make any failed attempts to 'FALSE' - $socketResource = FALSE; - } - - // And return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, TRUE)); - return $socketResource; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/.htaccess b/application/hub/main/factories/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/chain/.htaccess b/application/hub/main/factories/chain/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/chain/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/chain/class_PackageFilterChainFactory.php b/application/hub/main/factories/chain/class_PackageFilterChainFactory.php deleted file mode 100644 index 9cd32b50e..000000000 --- a/application/hub/main/factories/chain/class_PackageFilterChainFactory.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageFilterChainFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a filter chain by given tags array. - * - * @param $tags An array with tags from a package - * @return $chainInstance An instance of a filter chain class - */ - public static final function createChainByTagsArray (array $tags) { - // Get a registry key from tags array, this does mostly call implode() - $registryKey = Registry::getRegistryKeyFromArray('package_filter_chain', $tags); - - // Is the registry key there? - if (Registry::getRegistry()->instanceExists($registryKey)) { - // Yes, then use that instance - $chainInstance = Registry::getRegistry()->getInstance($registryKey); - } else { - // Initialize a filter chain class - $chainInstance = self::createObjectByConfiguredName('package_filter_chain_class'); - - // "Walk" through all tags entries - foreach ($tags as $tag) { - /* - * Now create a filter instance of this tag. This way all tags - * got rudymentary verified, if an exception is coming here, it - * simply means the tag is not valid. This however should be - * handled some calls before this method is called. - */ - $filterInstance = self::createObjectByConfiguredName('package_tag_' . $tag . '_filter'); - - // Add this filter to the chain - $chainInstance->addFilter($filterInstance); - } // END - foreach - - // Add the finished chain to the registry - Registry::getRegistry()->addInstance($registryKey, $chainInstance); - } - - // Return the chain instance - return $chainInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/chunks/.htaccess b/application/hub/main/factories/chunks/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/chunks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/chunks/class_ChunkHandlerFactory.php b/application/hub/main/factories/chunks/class_ChunkHandlerFactory.php deleted file mode 100644 index 3cda26f3d..000000000 --- a/application/hub/main/factories/chunks/class_ChunkHandlerFactory.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChunkHandlerFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) chunk handler instance - * - * @return $handlerInstance An instance of a chunk handler class - */ - public static final function createChunkHandlerInstance () { - // If there is no handler? - if (Registry::getRegistry()->instanceExists('chunk_handler')) { - // Get handler from registry - $handlerInstance = Registry::getRegistry()->getInstance('chunk_handler'); - } else { - // Get the handler instance - $handlerInstance = self::createObjectByConfiguredName('chunk_handler_class'); - - // Add it to the registry - Registry::getRegistry()->addInstance('chunk_handler', $handlerInstance); - } - - // Return the instance - return $handlerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/class_ b/application/hub/main/factories/class_ deleted file mode 100644 index d23d9641f..000000000 --- a/application/hub/main/factories/class_ +++ /dev/null @@ -1,59 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Factory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) !!! instance - * - * @return $%%%Instance An instance of a !!! class - */ - public static final function create???Instance () { - // If there is no handler? - if (Registry::getRegistry()->instanceExists('|||')) { - // Get handler from registry - $%%%Instance = Registry::getRegistry()->getInstance('|||'); - } else { - // Get the handler instance - $%%%Instance = self::createObjectByConfiguredName('|||_class'); - - // Add it to the registry - Registry::getRegistry()->addInstance('|||', $%%%Instance); - } - - // Return the instance - return $%%%Instance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/communicator/.htaccess b/application/hub/main/factories/communicator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/communicator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/communicator/class_CommunicatorFactory.php b/application/hub/main/factories/communicator/class_CommunicatorFactory.php deleted file mode 100644 index 8a7ba8aa7..000000000 --- a/application/hub/main/factories/communicator/class_CommunicatorFactory.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014, 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CommunicatorFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton communicator instance. If no instance is found, it fill - * be generated and stored in registry, else the communicator from the - * registry will be returned. - * - * @param $configEntry A configuration entry naming the real class' name - * @parasm $communicatorType Type of the communicator, can currently be 'node' - * @return $communicatorInstance A communicator instance - */ - public static final function createCommunicatorInstance ($configEntry, $communicatorType) { - // If there is no communicator? - if (Registry::getRegistry()->instanceExists($communicatorType . '_communicator')) { - // Get communicator from registry - $communicatorInstance = Registry::getRegistry()->getInstance($communicatorType . '_communicator'); - } else { - // Get the communicator instance - $communicatorInstance = self::createObjectByConfiguredName($configEntry); - - // Add it to the registry - Registry::getRegistry()->addInstance($communicatorType . '_communicator', $communicatorInstance); - } - - // Return the instance - return $communicatorInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/decoder/.htaccess b/application/hub/main/factories/decoder/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/decoder/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/decoder/class_DecoderFactory.php b/application/hub/main/factories/decoder/class_DecoderFactory.php deleted file mode 100644 index 7125c6a9f..000000000 --- a/application/hub/main/factories/decoder/class_DecoderFactory.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DecoderFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) Decodeable instance - * - * @return $decoderInstance An instance of a Decodeable class - */ - public static final function createPackageDecoderInstance () { - // If there is no handler? - if (Registry::getRegistry()->instanceExists('package_decoder')) { - // Get handler from registry - $decoderInstance = Registry::getRegistry()->getInstance('package_decoder'); - } else { - // Get a chunk handler instance - $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); - - // Get the handler instance - $decoderInstance = self::createObjectByConfiguredName('package_decoder_class', array($handlerInstance)); - - // Add it to the registry - Registry::getRegistry()->addInstance('package_decoder', $decoderInstance); - } - - // Return the instance - return $decoderInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/dht/.htaccess b/application/hub/main/factories/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/dht/class_DhtObjectFactory.php b/application/hub/main/factories/dht/class_DhtObjectFactory.php deleted file mode 100644 index 6555908a6..000000000 --- a/application/hub/main/factories/dht/class_DhtObjectFactory.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtObjectFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) DHT object instance - * - * @param $prefix Prefix for DHT class name and registry key - * @return $dhtInstance An instance of a DHT object class - */ - public static final function createDhtInstance ($prefix) { - // Set instance name - $name = $prefix . '_dht'; - - // If there is no handler? - if (Registry::getRegistry()->instanceExists($name)) { - // Get handler from registry - $dhtInstance = Registry::getRegistry()->getInstance($name); - } else { - // Get the handler instance - $dhtInstance = self::createObjectByConfiguredName($name . '_class'); - - // Add it to the registry - Registry::getRegistry()->addInstance($name, $dhtInstance); - } - - // Return the instance - return $dhtInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/discovery/.htaccess b/application/hub/main/factories/discovery/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/discovery/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/discovery/class_PackageDiscoveryFactory.php b/application/hub/main/factories/discovery/class_PackageDiscoveryFactory.php deleted file mode 100644 index ef5725663..000000000 --- a/application/hub/main/factories/discovery/class_PackageDiscoveryFactory.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageDiscoveryFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton network package instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $discoveryInstance A package discovery instance - */ - public static final function createPackageDiscoveryInstance () { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists('package_discovery')) { - // Then use this instance - $discoveryInstance = Registry::getRegistry()->getInstance('package_discovery'); - } else { - // Create a new instance - $discoveryInstance = self::createObjectByConfiguredName('package_recipient_discovery_class'); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance('package_discovery', $discoveryInstance); - } - - // Return the instance - return $discoveryInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/discovery/class_SocketDiscoveryFactory.php b/application/hub/main/factories/discovery/class_SocketDiscoveryFactory.php deleted file mode 100644 index 6991c7fa5..000000000 --- a/application/hub/main/factories/discovery/class_SocketDiscoveryFactory.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketDiscoveryFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton network socket instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $discoveryInstance A socket discovery instance - */ - public static final function createSocketDiscoveryInstance () { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists('socket_discovery')) { - // Then use this instance - $discoveryInstance = Registry::getRegistry()->getInstance('socket_discovery'); - } else { - // Create a new instance - $discoveryInstance = self::createObjectByConfiguredName('socket_discovery_class'); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance('socket_discovery', $discoveryInstance); - } - - // Return the instance - return $discoveryInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/fragmenter/.htaccess b/application/hub/main/factories/fragmenter/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/fragmenter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/handler/.htaccess b/application/hub/main/factories/handler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/handler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/handler/class_MessageTypeHandlerFactory.php b/application/hub/main/factories/handler/class_MessageTypeHandlerFactory.php deleted file mode 100644 index ce750231f..000000000 --- a/application/hub/main/factories/handler/class_MessageTypeHandlerFactory.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MessageTypeHandlerFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton message type handler instance. If an instance is - * found in registry, it will be returned, else a new instance is created - * and stored in the same registry entry. - * - * @param $messageType Message type to create an object from - * @return $handlerInstance A message type handler instance - */ - public static final function createMessageTypeHandlerInstance ($messageType) { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists('message_type_' . $messageType . '_handler')) { - // Then use this instance - $handlerInstance = Registry::getRegistry()->getInstance('message_type_' . $messageType . '_handler'); - } else { - // Now prepare the tags instance - $handlerInstance = self::createObjectByConfiguredName('message_type_' . $messageType . '_handler_class'); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance('message_type_' . $messageType . '_handler', $handlerInstance); - } - - // Return the instance - return $handlerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/handler/class_ProtocolHandlerFactory.php b/application/hub/main/factories/handler/class_ProtocolHandlerFactory.php deleted file mode 100644 index 880f889bf..000000000 --- a/application/hub/main/factories/handler/class_ProtocolHandlerFactory.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Unfinished stuff - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ProtocolHandlerFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a protocol handler based on given protocol type. This is mostly 'tcp'. - * - * @param $protocolType Protocol type to create/return a protocol handler instance for - * @return $handlerInstance A protocol handler instance - */ - private static function createProtocolHandlerByType ($protocolType) { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists($protocolType . '_protocol_handler')) { - // Then use this instance - $handlerInstance = Registry::getRegistry()->getInstance($protocolType . '_protocol_handler'); - } else { - // Now prepare the tags instance - $handlerInstance = self::createObjectByConfiguredName($protocolType . '_protocol_handler_class'); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance($protocolType . '_protocol_handler', $handlerInstance); - } - - // Return the instance - return $handlerInstance; - } - - /** - * Returns a singleton protocol handler instance from given HubHelper - * instance. If an instance is found in registry, it will be returned, else - * a new instance is created and stored in the same registry entry. - * - * @param $helperInstance An instance of a HubHelper class - * @return $handlerInstance A protocol handler instance - */ - public static final function createProtocolHandlerFromRecipientHelper (HubHelper $helperInstance) { - // Get the protocol type from given helper instance - $protocolType = $helperInstance->determineProtocolType(); - - // Call super factory method - return self::createProtocolHandlerByType($protocolType); - } - - /** - * Creates an instance of a protocol handler from given (raw) package data - * - * @param $packageData An array with raw package data - * @return $handlerInstance A protocol handler instance - */ - public static final function createProtocolHandlerFromPackageData (array $packageData) { - // "Discover" the protocol type - $protocolType = ProtocolDiscovery::discoverProtocolByPackageData($packageData); - - // Call super factory method - return self::createProtocolHandlerByType($protocolType); - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/info/.htaccess b/application/hub/main/factories/info/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/info/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/info/class_ConnectionInfoFactory.php b/application/hub/main/factories/info/class_ConnectionInfoFactory.php deleted file mode 100644 index fde9a37df..000000000 --- a/application/hub/main/factories/info/class_ConnectionInfoFactory.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConnectionInfoFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) ShareableInfo instance - * - * @param $protocolName Name of protocol (e.g. 'tcp') - * @param $type Connection type ('listener' or 'helper') - * @return $infoInstance An instance of a ShareableInfo class - */ - public static final function createConnectionInfoInstance ($protocolName, $type) { - // Generate key - $key = 'connection_info_' . $protocolName . '_' . $type; - - // If there is no info? - if (Registry::getRegistry()->instanceExists($key)) { - // Get info from registry - $infoInstance = Registry::getRegistry()->getInstance($key); - } else { - // Get the info instance - $infoInstance = self::createObjectByConfiguredName('connection_info_class'); - - // Add it to the registry - Registry::getRegistry()->addInstance($key, $infoInstance); - } - - // Return the instance - return $infoInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/lists/.htaccess b/application/hub/main/factories/lists/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/lists/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/lists/class_RecipientListFactory.php b/application/hub/main/factories/lists/class_RecipientListFactory.php deleted file mode 100644 index c94b18c83..000000000 --- a/application/hub/main/factories/lists/class_RecipientListFactory.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RecipientListFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton network package instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $listInstance A recipient list instance - */ - public static final function createRecipientListInstance () { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists('recipient_list')) { - // Then use this instance - $listInstance = Registry::getRegistry()->getInstance('recipient_list'); - } else { - // Create a new instance - $listInstance = self::createObjectByConfiguredName('recipient_list_class'); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance('recipient_list', $listInstance); - } - - // Return the instance - return $listInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/node/.htaccess b/application/hub/main/factories/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/node/class_NodeObjectFactory.php b/application/hub/main/factories/node/class_NodeObjectFactory.php deleted file mode 100644 index 39baf65e9..000000000 --- a/application/hub/main/factories/node/class_NodeObjectFactory.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeObjectFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) NodeHelper instance - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return $nodeInstance An instance of a NodeHelper class - * @throws FactoryRequiredParameterException If not all parameters are set and no instance 'node' is set. - */ - public static final function createNodeInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) { - // Get new factory instance - $factoryInstance = new NodeObjectFactory(); - - // If there is no handler? - if (Registry::getRegistry()->instanceExists('node')) { - // Get handler from registry - $nodeInstance = Registry::getRegistry()->getInstance('node'); - } elseif (($requestInstance instanceof Requestable) && ($responseInstance instanceof Responseable)) { - // The default node-mode is from our configuration - $nodeMode = $factoryInstance->getConfigInstance()->getConfigEntry('node_default_mode'); - - // Is the node 'mode' parameter set? - if ($requestInstance->isRequestElementSet('mode')) { - // Then use this which overrides the config entry temporarily - $nodeMode = $requestInstance->getRequestElement('mode'); - } else { - // Set it for easier re-usage - $requestInstance->setRequestElement('mode', $nodeMode); - } - - // Now convert the node-mode in a class name - $className = 'Hub' . $factoryInstance->convertToClassName($nodeMode) . 'Node'; - - // Get the node instance - $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); - - // Get a registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Set the app instance - $nodeInstance->setApplicationInstance($applicationInstance); - - // Add node-specific filters - $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - - // Add it to the registry - Registry::getRegistry()->addInstance('node', $nodeInstance); - } else { - // Throw an exception here - throw new FactoryRequiredParameterException($factoryInstance, self::EXCEPTION_FACTORY_REQUIRE_PARAMETER); - } - - // Return the instance - return $nodeInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/package/.htaccess b/application/hub/main/factories/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/package/assembler/.htaccess b/application/hub/main/factories/package/assembler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/package/assembler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/package/assembler/class_PackageAssemblerFactory.php b/application/hub/main/factories/package/assembler/class_PackageAssemblerFactory.php deleted file mode 100644 index 43bccf466..000000000 --- a/application/hub/main/factories/package/assembler/class_PackageAssemblerFactory.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageAssemblerFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton assembler instance. If no instance is found, it fill - * be generated and stored in registry, else the assembler from the - * registry will be returned. - * - * @param $packageInstance An instance of a Receivable instance - * @return $assemblerInstance An instance of a Assembler instance - */ - public static final function createAssemblerInstance (Receivable $packageInstance) { - // If there is no assembler? - if (Registry::getRegistry()->instanceExists('package_assembler')) { - // Get assembler from registry - $assemblerInstance = Registry::getRegistry()->getInstance('package_assembler'); - } else { - // Get the assembler instance - $assemblerInstance = self::createObjectByConfiguredName('package_assembler_class', array($packageInstance)); - - // Add it to the registry - Registry::getRegistry()->addInstance('package_assembler', $assemblerInstance); - } - - // Return the instance - return $assemblerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/package/class_NetworkPackageFactory.php b/application/hub/main/factories/package/class_NetworkPackageFactory.php deleted file mode 100644 index 725c6768b..000000000 --- a/application/hub/main/factories/package/class_NetworkPackageFactory.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NetworkPackageFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton network package instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $packageInstance A network package instance - */ - public static final function createNetworkPackageInstance () { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists('network_package')) { - // Then use this instance - $packageInstance = Registry::getRegistry()->getInstance('network_package'); - } else { - /* - * Prepare the compressor for our package, ZLIB should be fine but we - * keep it open here so you can experiment with the settings and don't - * need to touch this code. - */ - $compressorInstance = self::createObjectByConfiguredName('raw_package_compressor_class'); - - // Prepare the decorator compressor (for later flawless and easy updates) - $compressorInstance = self::createObjectByConfiguredName('deco_package_compressor_class', array($compressorInstance)); - - /* - * Now prepare the network package for delivery so only need to do this - * once just before the "big announcement loop". - */ - $packageInstance = self::createObjectByConfiguredName('network_package_class', array($compressorInstance)); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance('network_package', $packageInstance); - } - - // Return the instance - return $packageInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/package/fragmenter/.htaccess b/application/hub/main/factories/package/fragmenter/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/package/fragmenter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/package/fragmenter/class_FragmenterFactory.php b/application/hub/main/factories/package/fragmenter/class_FragmenterFactory.php deleted file mode 100644 index 53ccc271a..000000000 --- a/application/hub/main/factories/package/fragmenter/class_FragmenterFactory.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FragmenterFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton fragmenter instance. If no instance is found, it fill - * be generated and stored in registry, else the fragmenter from the - * registry will be returned. - * - * @param $fragmenterType The fragmenter's type - * @return $fragmenterInstance A fragmenter instance - */ - public static final function createFragmenterInstance ($fragmenterType) { - // If there is no fragmenter? - if (Registry::getRegistry()->instanceExists($fragmenterType . '_fragmenter')) { - // Get fragmenter from registry - $fragmenterInstance = Registry::getRegistry()->getInstance($fragmenterType . '_fragmenter'); - } else { - // Get the fragmenter instance - $fragmenterInstance = self::createObjectByConfiguredName($fragmenterType . '_fragmenter_class'); - - // Add it to the registry - Registry::getRegistry()->addInstance($fragmenterType . '_fragmenter', $fragmenterInstance); - } - - // Return the instance - return $fragmenterInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/producer/.htaccess b/application/hub/main/factories/producer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/producer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/producer/class_ProducerFactory.php b/application/hub/main/factories/producer/class_ProducerFactory.php deleted file mode 100644 index 91a6f9b1e..000000000 --- a/application/hub/main/factories/producer/class_ProducerFactory.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ProducerFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton producer instance. If no instance is found, it fill - * be generated and stored in registry, else the producer from the - * registry will be returned. - * - * @param $configEntry A configuration entry naming the real class' name - * @parasm $producerType Type of the producer, can be 'key', 'test_unit', etc. - * @return $producerInstance A producer instance - */ - public static final function createProducerInstance ($configEntry, $producerType) { - // If there is no producer? - if (Registry::getRegistry()->instanceExists($producerType . '_producer')) { - // Get producer from registry - $producerInstance = Registry::getRegistry()->getInstance($producerType . '_producer'); - } else { - // Get the producer instance - $producerInstance = self::createObjectByConfiguredName($configEntry); - - // Add it to the registry - Registry::getRegistry()->addInstance($producerType . '_producer', $producerInstance); - } - - // Return the instance - return $producerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/registry/.htaccess b/application/hub/main/factories/registry/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/registry/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/registry/class_ObjectTypeRegistryFactory.php b/application/hub/main/factories/registry/class_ObjectTypeRegistryFactory.php deleted file mode 100644 index 23dae6b51..000000000 --- a/application/hub/main/factories/registry/class_ObjectTypeRegistryFactory.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ObjectTypeRegistryFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton object type regsitry. - * - * @return $registryInstance A registry for object types - */ - public static final function createObjectTypeRegistryInstance () { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists('object_type_registry')) { - // Then use this instance - $registryInstance = Registry::getRegistry()->getInstance('object_type_registry'); - } else { - // Now prepare the tags instance - $registryInstance = self::createObjectByConfiguredName('node_object_type_registry_class'); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance('object_type_registry', $registryInstance); - } - - // Return the instance - return $registryInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/resolver/.htaccess b/application/hub/main/factories/resolver/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/resolver/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/resolver/class_ProtocolResolverFactory.php b/application/hub/main/factories/resolver/class_ProtocolResolverFactory.php deleted file mode 100644 index c2e4fe424..000000000 --- a/application/hub/main/factories/resolver/class_ProtocolResolverFactory.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ProtocolResolverFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) ProtocolResolver instance - * - * @return $resolverInstance An instance of a ProtocolResolver class - */ - public static final function createResolverFromConfiguredProtocol () { - // Get the configured protocol - $protocolName = FrameworkConfiguration::getSelfInstance()->getConfigEntry('hub_communication_protocol_type'); - - // If there is no handler? - if (Registry::getRegistry()->instanceExists($protocolName . '_protocol_resolver')) { - // Get handler from registry - $resolverInstance = Registry::getRegistry()->getInstance($protocolName . '_protocol_resolver'); - } else { - // Get the handler instance - $resolverInstance = self::createObjectByConfiguredName($protocolName . '_protocol_resolver_class'); - - // Add it to the registry - Registry::getRegistry()->addInstance($protocolName . '_protocol_resolver', $resolverInstance); - } - - // Return the instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/scanner/.htaccess b/application/hub/main/factories/scanner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/scanner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/scanner/class_ScannerObjectFactory.php b/application/hub/main/factories/scanner/class_ScannerObjectFactory.php deleted file mode 100644 index d6f0129f2..000000000 --- a/application/hub/main/factories/scanner/class_ScannerObjectFactory.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ScannerObjectFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) Scanner instance - * - * @param $taskInstance An instance of a class with an Taskable interface - * @return $sourceInstance An instance of a Scanner class - */ - public static final function createScannerInstance (Taskable $taskInstance) { - // Get new factory instance - $factoryInstance = new ScannerObjectFactory(); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Get scanner type for given task instance by searching it in task handler - $scannerType = $handlerInstance->searchTask($taskInstance); - - // Only let registered tasks pass - assert(!empty($scannerType)); - - // If there is no handler? - if (Registry::getRegistry()->instanceExists('scanner_' . $scannerType)) { - // Get handler from registry - $scannerInstance = Registry::getRegistry()->getInstance('scanner_' . $scannerType); - } else { - // Get the scanner instance - $scannerInstance = ObjectFactory::createObjectByConfiguredName($scannerType); - - // Add it to the registry - Registry::getRegistry()->addInstance('scanner_' . $scannerType, $scannerInstance); - } - - // Return the instance - return $scannerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/socket/.htaccess b/application/hub/main/factories/socket/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/socket/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/socket/class_SocketFactory.php b/application/hub/main/factories/socket/class_SocketFactory.php deleted file mode 100644 index 42e7a7af6..000000000 --- a/application/hub/main/factories/socket/class_SocketFactory.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates a valid socket resource from given packae data and protocol - * - * @param $packageData Raw package data - * @param $protocolInstance An instance of a HandleableProtocol class - * @return $socketResource Socket resource - */ - public static function createSocketFromPackageData (array $packageData, HandleableProtocol $protocolInstance) { - // Get an instance - $factoryInstance = new SocketFactory(); - - // Construct registry key - $registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]; - - // Debug message - //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to find a socket with registryKey=' . $registryKey); - - // Is the key there? - if (Registry::getRegistry()->instanceExists($registryKey)) { - // Get container instance - $containerInstance = Registry::getRegistry()->getInstance($registryKey); - - // Get socket back - $socketResource = $containerInstance->getSocketResource(); - - // Debug message - //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.'); - } else { - // Construct configuration entry for object factory and get it - $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolInstance->getProtocolName() . '_connection_helper_class'); - - // Debug message - //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Going to use class ' . $className . ' for creating a socket resource ...'); - - // And call the static method - $socketResource = call_user_func($className . '::createConnectionFromPackageData', $packageData); - - // Debug message - //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Created socket ' . $socketResource . '(' . gettype($socketResource) . ') from class ' . $className . '.'); - - // Construct container class, this won't be reached if an exception is thrown - $containerInstance = self::CreateObjectByConfiguredName('socket_container_class', array($socketResource, NULL, $packageData)); - - // Register it with the registry - Registry::getRegistry()->addInstance($registryKey, $containerInstance); - - // Debug message - //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Socket is now registered in registry.'); - } - - // Return the resource - return $socketResource; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/source/.htaccess b/application/hub/main/factories/source/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/source/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/source/units/.htaccess b/application/hub/main/factories/source/units/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/source/units/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/source/units/class_UnitSourceFactory.php b/application/hub/main/factories/source/units/class_UnitSourceFactory.php deleted file mode 100644 index dcb967c1b..000000000 --- a/application/hub/main/factories/source/units/class_UnitSourceFactory.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnitSourceFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a configurable and singleton unit source - * - * @param $unitType Type of the unit source - * @return $sourceInstance A UnitSource class instance - */ - public static final function createUnitSourceInstance ($unitType) { - // Do we have cache? - if (!Registry::getRegistry()->instanceExists($unitType . '_unit_source')) { - // Then construct the class' configuraton entry - $className = '' . $unitType . '_unit_source_class'; - - // Get a class from that configuration entry - $sourceInstance = self::createObjectByConfiguredName($className); - - // Add it to the registry - Registry::getRegistry()->addInstance($unitType . '_unit_source', $sourceInstance); - } else { - // Get it from registry - $sourceInstance = Registry::getRegistry()->getInstance($unitType . '_unit_source'); - } - - // For any purposes, return the source instance - return $sourceInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/source/url/.htaccess b/application/hub/main/factories/source/url/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/source/url/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/source/url/class_UrlSourceObjectFactory.php b/application/hub/main/factories/source/url/class_UrlSourceObjectFactory.php deleted file mode 100644 index fe2025fab..000000000 --- a/application/hub/main/factories/source/url/class_UrlSourceObjectFactory.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UrlSourceObjectFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) UrlSource instance - * - * @param $taskInstance An instance of a class with an Taskable interface - * @return $sourceInstance An instance of a UrlSource class - */ - public static final function createUrlSourceInstance (Taskable $taskInstance) { - // Get new factory instance - $factoryInstance = new UrlSourceObjectFactory(); - - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Get source type by looking for given task instance in task handler - $sourceType = $handlerInstance->searchTask($taskInstance); - - // Only let registered tasks pass - assert(!empty($sourceType)); - - // If there is no handler? - if (Registry::getRegistry()->instanceExists('source_' . $sourceType)) { - // Get handler from registry - $sourceInstance = Registry::getRegistry()->getInstance('source_' . $sourceType); - } else { - // Get the source instance - $sourceInstance = ObjectFactory::createObjectByConfiguredName($sourceType . '_class'); - - // Add it to the registry - Registry::getRegistry()->addInstance('source_' . $sourceType, $sourceInstance); - } - - // Return the instance - return $sourceInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/states/.htaccess b/application/hub/main/factories/states/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/communicator/.htaccess b/application/hub/main/factories/states/communicator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/communicator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/communicator/class_CommunicatorStateFactory.php b/application/hub/main/factories/states/communicator/class_CommunicatorStateFactory.php deleted file mode 100644 index d0fbf8342..000000000 --- a/application/hub/main/factories/states/communicator/class_CommunicatorStateFactory.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014, 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CommunicatorStateFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a configurable communicator state and sets it in the - * given communicator instance. - * - * @param $stateName Name of the state - * @param $communicatorInstance A Communicator class instance - * @return $stateInstance A Stateable class instance - */ - public static final function createCommunicatorStateInstanceByName ($stateName, Communicator $communicatorInstance) { - // Then construct the class' configuraton entry - $className = 'communicator_' . $stateName . '_state_class'; - - // Get a class from that configuration entry - $stateInstance = self::createObjectByConfiguredName($className, array($communicatorInstance)); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Communicator state has changed from ' . $communicatorInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Once we have that state, set it in the communicator instance - $communicatorInstance->setStateInstance($stateInstance); - - // Update communicator data - $communicatorInstance->updateCommunicatorData(); - - // For any purposes, return the state instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/states/crawler/.htaccess b/application/hub/main/factories/states/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/crawler/class_CrawlerStateFactory.php b/application/hub/main/factories/states/crawler/class_CrawlerStateFactory.php deleted file mode 100644 index 4b0eb52fb..000000000 --- a/application/hub/main/factories/states/crawler/class_CrawlerStateFactory.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014, 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerStateFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a configurable crawler state and sets it in the - * given crawler instance. - * - * @param $stateName Name of the state - * @return $stateInstance A Stateable class instance - */ - public static final function createCrawlerStateInstanceByName ($stateName) { - // Then construct the class' configuraton entry - $className = 'crawler_' . $stateName . '_state_class'; - - // Get a class from that configuration entry - $stateInstance = self::createObjectByConfiguredName($className); - - // Get crawler instance - $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Crawler state has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Once we have that state, set it in the crawler instance - $crawlerInstance->setStateInstance($stateInstance); - - // Update crawler data - $crawlerInstance->updateCrawlerData(); - - // For any purposes, return the state instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/states/cruncher/.htaccess b/application/hub/main/factories/states/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php b/application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php deleted file mode 100644 index 8701aa589..000000000 --- a/application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherStateFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a configurable cruncher state and sets it in the - * given cruncher instance. - * - * @param $stateName Name of the state - * @param $cruncherInstance A CruncherHelper class instance - * @return $stateInstance A Stateable class instance - */ - public static final function createCruncherStateInstanceByName ($stateName) { - // Then construct the class' configuraton entry - $className = 'cruncher_' . $stateName . '_state_class'; - - // Get cruncher instance from registry - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Get a class from that configuration entry - $stateInstance = self::createObjectByConfiguredName($className); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Cruncher state has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Once we have that state, set it in the cruncher instance - $cruncherInstance->setStateInstance($stateInstance); - - // For any purposes, return the state instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/states/dht/.htaccess b/application/hub/main/factories/states/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/dht/class_DhtStateFactory.php b/application/hub/main/factories/states/dht/class_DhtStateFactory.php deleted file mode 100644 index dfa1eade3..000000000 --- a/application/hub/main/factories/states/dht/class_DhtStateFactory.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtStateFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a configurable DHT state and sets it in the - * given DHT instance. - * - * @param $stateName Name of the state - * @param $dhtInstance A Distributable class instance - * @return $stateInstance A Stateable class instance - */ - public static final function createDhtStateInstanceByName ($stateName, Distributable $dhtInstance) { - // Then construct the class' configuraton entry - $className = 'dht_' . $stateName . '_state_class'; - - // Get a class from that configuration entry - $stateInstance = self::createObjectByConfiguredName($className, array($dhtInstance)); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: DHT state has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Once we have that state, set it in the DHT instance - $dhtInstance->setStateInstance($stateInstance); - - // Update DHT data - $dhtInstance->updateDhtData(); - - // For any purposes, return the state instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/states/miner/.htaccess b/application/hub/main/factories/states/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/miner/class_MinerStateFactory.php b/application/hub/main/factories/states/miner/class_MinerStateFactory.php deleted file mode 100644 index 2b2a7e02f..000000000 --- a/application/hub/main/factories/states/miner/class_MinerStateFactory.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerStateFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a configurable miner state and sets it in the - * given miner instance. - * - * @param $stateName Name of the state - * @return $stateInstance A Stateable class instance - */ - public static final function createMinerStateInstanceByName ($stateName) { - // Then construct the class' configuraton entry - $className = 'miner_' . $stateName . '_state_class'; - - // Get miner instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Get a class from that configuration entry - $stateInstance = self::createObjectByConfiguredName($className); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Miner state has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Once we have that state, set it in the miner instance - $minerInstance->setStateInstance($stateInstance); - - // For any purposes, return the state instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/states/node/.htaccess b/application/hub/main/factories/states/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/node/class_NodeStateFactory.php b/application/hub/main/factories/states/node/class_NodeStateFactory.php deleted file mode 100644 index 46212da4f..000000000 --- a/application/hub/main/factories/states/node/class_NodeStateFactory.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeStateFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a configurable node state and sets it in the - * given node instance. - * - * @param $stateName Name of the state - * @param $nodeInstance An instance of a NodeHelper class (optional) - * @return $stateInstance A Stateable class instance - */ - public static final function createNodeStateInstanceByName ($stateName, NodeHelper $nodeInstance = NULL) { - // Then construct the class' configuraton entry - $className = 'node_' . $stateName . '_state_class'; - - // Is the node instance set? - if (is_null($nodeInstance)) { - // Get node instance from registry - $nodeInstance = NodeObjectFactory::createNodeInstance(); - } // END - if - - // Get a class from that configuration entry - $stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance)); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('NODE-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Node state has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Once we have that state, set it in the node instance - $nodeInstance->setStateInstance($stateInstance); - - // Update node data - $nodeInstance->updateNodeData(); - - // For any purposes, return the state instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/states/peer/.htaccess b/application/hub/main/factories/states/peer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/states/peer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/states/peer/class_PeerStateFactory.php b/application/hub/main/factories/states/peer/class_PeerStateFactory.php deleted file mode 100644 index dea14b8ed..000000000 --- a/application/hub/main/factories/states/peer/class_PeerStateFactory.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PeerStateFactory extends ObjectFactory { - /** - * Static lookup table instance - */ - private static $tableInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Singleton getter for lookup table instances, kept public if we need this - * table somewhere else. - * - * @return $tableInstance An instance of a lookup table - */ - public static final function getTableInstance () { - // Is the instance null? - if (is_null(self::$tableInstance)) { - // Get a new one - self::$tableInstance = self::createObjectByConfiguredName('peer_state_lookup_db_wrapper_class'); - } // END - if - - // Return it - return self::$tableInstance; - } - - /** - * Creates a peer state instance based on errorCode if no entry is found in the lookup table - * for the peer given in $packageData 'sender' element or it changes the state if it differs - * from current state. - * - * @param $helperInstance An instance of a ConnectionHelper class - * @param $packageData Raw package data - * @param $socketResource A valid socket resource - * @param $errorCode The last error code - * @return $stateInstance A Stateable class instance - */ - public static final function createPeerStateInstanceBySocketStatusCode (ConnectionHelper $helperInstance, array $packageData, $socketResource, $errorCode) { - // Init state instance, this is better coding practice - $stateInstance = NULL; - - // So first we need our lookup table - $tableInstance = self::getTableInstance(); - - /* - * Now try to purge old entries before looking an entry up. This shall - * make it sure that only accurate entries can be found. - */ - try { - // Purge old entries - $tableInstance->purgeOldEntriesBySocketResource($socketResource); - } catch (InvalidSocketException $e) { - // Just log all errors - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Purging of old entries failed. Message from exception: ' . $e->getMessage()); - } - - // Do we have an entry? - if ($tableInstance->isSenderNewPeer($packageData)) { - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] errorCode=' . $errorCode); - - // Register the new peer with its session id - $tableInstance->registerPeerByPackageData($packageData, $socketResource); - - /* - * It is a new peer so create the state instance based on error - * code and get an instance from it. - */ - $stateInstance = self::createObjectByConfiguredName('peer_' . $errorCode . '_state_class'); - - // And register it with the lookup table - $tableInstance->registerPeerState($stateInstance, $packageData); - } elseif ($tableInstance->isSamePeerState($helperInstance, $packageData)) { - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state unchanged, re-generating old state ...'); - - /* - * The peer's state has noot changed, still we have to return a - * state instance, so generate it here. - */ - $stateInstance = self::createPeerStateInstanceByName($helperInstance->getPrintableState(), $helperInstance); - } else { - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Updating peer state ...'); - - /* - * It is an already known peer but with a changed state. So first - * get an instance of the state. - */ - $stateInstance = self::createObjectByConfiguredName('peer_' . $errorCode . '_state_class'); - - // The peer's state has changed, update database now - $tableInstance->registerPeerState($stateInstance, $packageData); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); - - // Set the state in the helper - $helperInstance->setStateInstance($stateInstance); - - // For any purposes, return the state instance - return $stateInstance; - } - - /** - * Creates an instance of a configurable peer state and sets it in the - * given peer instance. - * - * @param $stateName Name of the state - * @param $helperInstance A ConnectionHelper class instance - * @return $stateInstance A Stateable class instance - */ - public static final function createPeerStateInstanceByName ($stateName, ConnectionHelper $helperInstance) { - // Get a class from a configuration entry - $stateInstance = self::createObjectByConfiguredName('peer_' . $stateName . '_state_class', array($helperInstance)); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); - - // Once we have that state, set it in the peer instance - $helperInstance->setStateInstance($stateInstance); - - // For any purposes, return the state instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/factories/tags/.htaccess b/application/hub/main/factories/tags/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/factories/tags/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/factories/tags/class_PackageTagsFactory.php b/application/hub/main/factories/tags/class_PackageTagsFactory.php deleted file mode 100644 index 1fde988bf..000000000 --- a/application/hub/main/factories/tags/class_PackageTagsFactory.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageTagsFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton network package instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $packageInstance A network package instance - */ - public static final function createPackageTagsInstance () { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists('package_tags')) { - // Then use this instance - $packageInstance = Registry::getRegistry()->getInstance('package_tags'); - } else { - // Now prepare the tags instance - $packageInstance = self::createObjectByConfiguredName('package_tags_class'); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance('package_tags', $packageInstance); - } - - // Return the instance - return $packageInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/feature/.htaccess b/application/hub/main/feature/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/feature/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/feature/hubcoin_reward/.htaccess b/application/hub/main/feature/hubcoin_reward/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/feature/hubcoin_reward/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/feature/hubcoin_reward/class_HubcoinRewardFeature.php b/application/hub/main/feature/hubcoin_reward/class_HubcoinRewardFeature.php deleted file mode 100644 index f868dd949..000000000 --- a/application/hub/main/feature/hubcoin_reward/class_HubcoinRewardFeature.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubcoinRewardFeature extends BaseFeature implements Feature { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Feature class and prepares it for usage - * - * @return $featureInstance An instance of this Feature class - */ - public final static function createHubcoinRewardFeature () { - // Get a new instance - $featureInstance = new HubcoinRewardFeature(); - - // Return the prepared instance - return $featureInstance; - } - - /** - * Checks whether this feature can be made available to other classes. - * - * @return $isAvailable Whether this feature is available - */ - public function isFeatureAvailable () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); - - // Testing this feature is pretty simple: - $isAvailable = (($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === TRUE) && (extension_loaded('scrypt')) && (is_callable('scrypt'))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable))); - - // Return status - return $isAvailable; - } - - /** - * Feature method 'generateHash' - * - * @param $data Data to hash - * @return $hash Finished hash - */ - public function featureMethodGenerateHash ($data) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: data()=%d - CALLED!', __METHOD__, __LINE__, strlen($data))); - - // Make sure the feature is available - assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); - - // Call inner class - $hash = Scrypt::hashScrypt($data); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: hash=%s - EXIT!', __METHOD__, __LINE__, $hash)); - - // Return generated hash - return $hash; - } - - /** - * Feature method 'checkHash' - * - * @param $data Data to check hash for - * @param $hash Previously generated hash for valdiation - * @return $isValid Whether the given hash matches a new one from given data - */ - public function featureMethodCheckHash ($data, $hash) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: data()=%d,hash=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $hash)); - - // Make sure the feature is available - assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); - - // Determine it - $isValid = Scrypt::checkScrypt($data, $hash); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: isValid=%d - EXIT!', __METHOD__, __LINE__, intval($isValid))); - - // Return status - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/.htaccess b/application/hub/main/filter/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/activation/.htaccess b/application/hub/main/filter/activation/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/activation/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/activation/node/.htaccess b/application/hub/main/filter/activation/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/activation/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/activation/node/class_NodeActivation b/application/hub/main/filter/activation/node/class_NodeActivation deleted file mode 100644 index f64d0ab07..000000000 --- a/application/hub/main/filter/activation/node/class_NodeActivation +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubActivation???Filter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createHubActivation???Filter () { - // Get a new instance - $filterInstance = new HubActivation???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = Registry::getRegistry()->getInstance('node'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/activation/node/class_NodeActivationAnnouncementFilter.php b/application/hub/main/filter/activation/node/class_NodeActivationAnnouncementFilter.php deleted file mode 100644 index 60b90d1a8..000000000 --- a/application/hub/main/filter/activation/node/class_NodeActivationAnnouncementFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeActivationAnnouncementFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeActivationAnnouncementFilter () { - // Get a new instance - $filterInstance = new NodeActivationAnnouncementFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Prepare a self-test task for the listeners - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_announcement_task_class'); - - // Register it - $handlerInstance->registerTask('announcement', $taskInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/apt-proxy/.htaccess b/application/hub/main/filter/apt-proxy/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/apt-proxy/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/apt-proxy/class_AptProxyInitializationFilter.php b/application/hub/main/filter/apt-proxy/class_AptProxyInitializationFilter.php deleted file mode 100644 index 4337e190d..000000000 --- a/application/hub/main/filter/apt-proxy/class_AptProxyInitializationFilter.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyInitializationFilter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createAptProxyInitializationFilter () { - // Get a new instance - $filterInstance = new AptProxyInitializationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get an instance - $proxyInstance = ObjectFactory::createObjectByConfiguredName('node_console_apt_proxy_class'); - - // Get a registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Set the app instance - $proxyInstance->setApplicationInstance($applicationInstance); - - // Add apt-proxy-specific filters - $proxyInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - - // Set the apt_proxy instance in registry - Registry::getRegistry()->addInstance('apt_proxy', $proxyInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php b/application/hub/main/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php deleted file mode 100644 index 816a31a01..000000000 --- a/application/hub/main/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyPhpRequirementsFilter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createAptProxyPhpRequirementsFilter () { - // Get a new instance - $filterInstance = new AptProxyPhpRequirementsFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If a required PHP function is not available - * @todo Add more test and try to add an extra message to the thrown exception - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // By default, the requirement check is passed and zero checks are failed - $checkPassed = TRUE; - $checksFailed = 0; - - // Socket support is essential... - if (!function_exists('socket_create')) { - // Test failed - $checkPassed = FALSE; - $checksFailed++; - } // END -if - - // Are all tests passed? - if ($checkPassed === FALSE) { - // Throw an exception - throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/apt-proxy/class_AptProxyWelcomeTeaserFilter.php b/application/hub/main/filter/apt-proxy/class_AptProxyWelcomeTeaserFilter.php deleted file mode 100644 index 2e9d815ff..000000000 --- a/application/hub/main/filter/apt-proxy/class_AptProxyWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyWelcomeTeaserFilter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createAptProxyWelcomeTeaserFilter () { - // Get a new instance - $filterInstance = new AptProxyWelcomeTeaserFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo Handle over the $responseInstance to outputConsoleTeaser() - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); - - // Now output the teaser - $proxyInstance->outputConsoleTeaser(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/.htaccess b/application/hub/main/filter/bootstrap/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/bootstrap/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/bootstrap/apt-proxy/.htaccess b/application/hub/main/filter/bootstrap/apt-proxy/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/bootstrap/apt-proxy/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrap b/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrap deleted file mode 100644 index 008987a8f..000000000 --- a/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrap +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyBootstrap???Filter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createAptProxyBootstrap???Filter () { - // Get a new instance - $filterInstance = new AptProxyBootstrap???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get apt-proxy instance - $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrapExtraBootstrappingFilter.php b/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrapExtraBootstrappingFilter.php deleted file mode 100644 index 9fa0b9a80..000000000 --- a/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrapExtraBootstrappingFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyBootstrapExtraBootstrappingFilter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createAptProxyBootstrapExtraBootstrappingFilter () { - // Get a new instance - $filterInstance = new AptProxyBootstrapExtraBootstrappingFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $proxyInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get apt-proxy instance - $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); - - // Do some extra bootstrapping steps - $proxyInstance->doBootstrapping(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrapGenericActivationFilter.php b/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrapGenericActivationFilter.php deleted file mode 100644 index 34021a606..000000000 --- a/application/hub/main/filter/bootstrap/apt-proxy/class_AptProxyBootstrapGenericActivationFilter.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyBootstrapGenericActivationFilter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createAptProxyBootstrapGenericActivationFilter () { - // Get a new instance - $filterInstance = new AptProxyBootstrapGenericActivationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Maybe we want to do somthing more here? - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a apt-proxy instance - $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); - - // Set the flag - $proxyInstance->enableIsActive(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: apt-proxy has been activated.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/chat/.htaccess b/application/hub/main/filter/bootstrap/chat/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/bootstrap/chat/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/bootstrap/chat/class_ChatBootstrap b/application/hub/main/filter/bootstrap/chat/class_ChatBootstrap deleted file mode 100644 index 9047bdcbb..000000000 --- a/application/hub/main/filter/bootstrap/chat/class_ChatBootstrap +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatBootstrap???Filter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createChatBootstrap???Filter () { - // Get a new instance - $filterInstance = new ChatBootstrap???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get chat instance - $chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/chat/class_ChatBootstrapExtraBootstrappingFilter.php b/application/hub/main/filter/bootstrap/chat/class_ChatBootstrapExtraBootstrappingFilter.php deleted file mode 100644 index cc7865c57..000000000 --- a/application/hub/main/filter/bootstrap/chat/class_ChatBootstrapExtraBootstrappingFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatBootstrapExtraBootstrappingFilter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createChatBootstrapExtraBootstrappingFilter () { - // Get a new instance - $filterInstance = new ChatBootstrapExtraBootstrappingFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $chatInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get chat instance - $chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Do some extra bootstrapping steps - $chatInstance->doBootstrapping(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php b/application/hub/main/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php deleted file mode 100644 index afe2bd455..000000000 --- a/application/hub/main/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatBootstrapGenericActivationFilter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createChatBootstrapGenericActivationFilter () { - // Get a new instance - $filterInstance = new ChatBootstrapGenericActivationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Maybe we want to do somthing more here? - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a chat instance - $chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Set the flag - $chatInstance->enableIsActive(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The chat console has been activated.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/class_HubBootstrap b/application/hub/main/filter/bootstrap/class_HubBootstrap deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/filter/bootstrap/class_HubBootstrap +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/filter/bootstrap/crawler/.htaccess b/application/hub/main/filter/bootstrap/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/bootstrap/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrap b/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrap deleted file mode 100644 index f0c3fcf4c..000000000 --- a/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrap +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerBootstrap???Filter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createCrawlerBootstrap???Filter () { - // Get a new instance - $filterInstance = new CrawlerBootstrap???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get crawler instance - $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrapExtraBootstrappingFilter.php b/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrapExtraBootstrappingFilter.php deleted file mode 100644 index b4c6d8cac..000000000 --- a/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrapExtraBootstrappingFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerBootstrapExtraBootstrappingFilter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCrawlerBootstrapExtraBootstrappingFilter () { - // Get a new instance - $filterInstance = new CrawlerBootstrapExtraBootstrappingFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $crawlerInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get crawler instance - $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Do some extra bootstrapping steps - $crawlerInstance->doBootstrapping(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrapGenericActivationFilter.php b/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrapGenericActivationFilter.php deleted file mode 100644 index cfe1b0d20..000000000 --- a/application/hub/main/filter/bootstrap/crawler/class_CrawlerBootstrapGenericActivationFilter.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerBootstrapGenericActivationFilter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createCrawlerBootstrapGenericActivationFilter () { - // Get a new instance - $filterInstance = new CrawlerBootstrapGenericActivationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Maybe we want to do somthing more here? - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a crawler instance - $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Set the flag - $crawlerInstance->enableIsActive(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The crawler has been activated.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/cruncher/.htaccess b/application/hub/main/filter/bootstrap/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/bootstrap/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrap b/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrap deleted file mode 100644 index 312c64940..000000000 --- a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrap +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherBootstrap???Filter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createCruncherBootstrap???Filter () { - // Get a new instance - $filterInstance = new CruncherBootstrap???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get cruncher instance - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php b/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php deleted file mode 100644 index 2f7286d87..000000000 --- a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherBootstrapBufferQueueInitializerFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createCruncherBootstrapBufferQueueInitializerFilter () { - // Get a new instance - $filterInstance = new CruncherBootstrapBufferQueueInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get cruncher instance - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Init all buffer queues - $cruncherInstance->initBufferQueues(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapExtraBootstrappingFilter.php b/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapExtraBootstrappingFilter.php deleted file mode 100644 index 1d35f5c2c..000000000 --- a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapExtraBootstrappingFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherBootstrapExtraBootstrappingFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCruncherBootstrapExtraBootstrappingFilter () { - // Get a new instance - $filterInstance = new CruncherBootstrapExtraBootstrappingFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $cruncherInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get cruncher instance - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Do some extra bootstrapping steps - $cruncherInstance->doBootstrapping(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php b/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php deleted file mode 100644 index 72a995949..000000000 --- a/application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherBootstrapGenericActivationFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createCruncherBootstrapGenericActivationFilter () { - // Get a new instance - $filterInstance = new CruncherBootstrapGenericActivationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Maybe we want to do somthing more here? - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a cruncher instance - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Set the flag - $cruncherInstance->enableIsActive(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The cruncher has been activated.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/miner/.htaccess b/application/hub/main/filter/bootstrap/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/bootstrap/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrap b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrap deleted file mode 100644 index b80cc4de2..000000000 --- a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrap +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerBootstrap???Filter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createMinerBootstrap???Filter () { - // Get a new instance - $filterInstance = new MinerBootstrap???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get miner instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php deleted file mode 100644 index 3998123b8..000000000 --- a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapBufferQueueInitializerFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerBootstrapBufferQueueInitializerFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createMinerBootstrapBufferQueueInitializerFilter () { - // Get a new instance - $filterInstance = new MinerBootstrapBufferQueueInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get miner instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Init all buffer queues - $minerInstance->initBufferQueues(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php deleted file mode 100644 index 7919af35b..000000000 --- a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapExtraBootstrappingFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerBootstrapExtraBootstrappingFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createMinerBootstrapExtraBootstrappingFilter () { - // Get a new instance - $filterInstance = new MinerBootstrapExtraBootstrappingFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $minerInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get miner instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Do some extra bootstrapping steps - $minerInstance->doBootstrapping(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php b/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php deleted file mode 100644 index 08d0c7cb0..000000000 --- a/application/hub/main/filter/bootstrap/miner/class_MinerBootstrapGenericActivationFilter.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerBootstrapGenericActivationFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createMinerBootstrapGenericActivationFilter () { - // Get a new instance - $filterInstance = new MinerBootstrapGenericActivationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo Maybe we want to do somthing more here? - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a miner instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Set the flag - $minerInstance->enableIsActive(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: The miner has been activated.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/node/.htaccess b/application/hub/main/filter/bootstrap/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/bootstrap/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/bootstrap/node/class_NodeBootstrap b/application/hub/main/filter/bootstrap/node/class_NodeBootstrap deleted file mode 100644 index 5371b8ae7..000000000 --- a/application/hub/main/filter/bootstrap/node/class_NodeBootstrap +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeBootstrap???Filter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createNodeBootstrap???Filter () { - // Get a new instance - $filterInstance = new NodeBootstrap???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = Registry::getRegistry()->getInstance('node'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php b/application/hub/main/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php deleted file mode 100644 index 5ddc68ca6..000000000 --- a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapExtraBootstrappingFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeBootstrapExtraBootstrappingFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeBootstrapExtraBootstrappingFilter () { - // Get a new instance - $filterInstance = new NodeBootstrapExtraBootstrappingFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Do some extra bootstrapping steps - $nodeInstance->doBootstrapping(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php b/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php deleted file mode 100644 index 5c31c17ba..000000000 --- a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateNodeIdFilter.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeBootstrapGenerateNodeIdFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeBootstrapGenerateNodeIdFilter () { - // Get a new instance - $filterInstance = new NodeBootstrapGenerateNodeIdFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - /* - * Acquire a hub-id. This step generates on first launch a new one and - * on any later launches it will restore the hub-id from the database. - * A passed 'nickname=xxx' argument will be used to add some - * 'personality' to the hub. - */ - $nodeInstance->bootstrapAcquireNodeId($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php b/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php deleted file mode 100644 index f7f3c392d..000000000 --- a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGeneratePrivateKeyFilter.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeBootstrapGeneratePrivateKeyFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createNodeBootstrapGeneratePrivateKeyFilter () { - // Get a new instance - $filterInstance = new NodeBootstrapGeneratePrivateKeyFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - /* - * Generate the private key. This will be stored along with the other - * node data. - */ - $nodeInstance->bootstrapGeneratePrivateKey(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php b/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php deleted file mode 100644 index 63a4ed98d..000000000 --- a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapGenerateSessionIdFilter.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeBootstrapGenerateSessionIdFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeBootstrapGenerateSessionIdFilter () { - // Get a new instance - $filterInstance = new NodeBootstrapGenerateSessionIdFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - /* - * Generate the session id which will only be stored in RAM and kept for - * the whole "session". - */ - $nodeInstance->bootstrapGenerateSessionId(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php b/application/hub/main/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php deleted file mode 100644 index a6a81669f..000000000 --- a/application/hub/main/filter/bootstrap/node/class_NodeBootstrapListenerPoolFilter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Node Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeBootstrapListenerPoolFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeBootstrapListenerPoolFilter () { - // Get a new instance - $filterInstance = new NodeBootstrapListenerPoolFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Now do something - $nodeInstance->initializeListenerPool(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/chat/.htaccess b/application/hub/main/filter/chat/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/chat/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/chat/class_ChatInitializationFilter.php b/application/hub/main/filter/chat/class_ChatInitializationFilter.php deleted file mode 100644 index e47efbbc8..000000000 --- a/application/hub/main/filter/chat/class_ChatInitializationFilter.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatInitializationFilter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createChatInitializationFilter () { - // Get a new instance - $filterInstance = new ChatInitializationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get an instance - $chatInstance = ObjectFactory::createObjectByConfiguredName('node_console_chat_class'); - - // Get a registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Set the app instance - $chatInstance->setApplicationInstance($applicationInstance); - - // Add chat-specific filters - $chatInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - - // Set the chat instance in registry - Registry::getRegistry()->addInstance('chat', $chatInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/chat/class_ChatPhpRequirementsFilter.php b/application/hub/main/filter/chat/class_ChatPhpRequirementsFilter.php deleted file mode 100644 index e794a6635..000000000 --- a/application/hub/main/filter/chat/class_ChatPhpRequirementsFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Teama - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatPhpRequirementsFilter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createChatPhpRequirementsFilter () { - // Get a new instance - $filterInstance = new ChatPhpRequirementsFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If a required PHP function is not available - * @todo Add more test and try to add an extra message to the thrown exception - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // By default, the requirement check is passed and zero checks are failed - $checkPassed = TRUE; - $checksFailed = 0; - - // Socket support is essential... - if (!function_exists('socket_create')) { - // Test failed - $checkPassed = FALSE; - $checksFailed++; - } // END -if - - // Are all tests passed? - if ($checkPassed === FALSE) { - // Throw an exception - throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/chat/class_ChatWelcomeTeaserFilter.php b/application/hub/main/filter/chat/class_ChatWelcomeTeaserFilter.php deleted file mode 100644 index c724ec9d1..000000000 --- a/application/hub/main/filter/chat/class_ChatWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatWelcomeTeaserFilter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createChatWelcomeTeaserFilter () { - // Get a new instance - $filterInstance = new ChatWelcomeTeaserFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo Handle over the $responseInstance to outputConsoleTeaser() - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Now output the teaser - $chatInstance->outputConsoleTeaser(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_ b/application/hub/main/filter/class_ deleted file mode 100644 index a3605aa8c..000000000 --- a/application/hub/main/filter/class_ +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Hub!!!???Filter extends BaseHubFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createHub!!!???Filter () { - // Get a new instance - $filterInstance = new Hub!!!???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = Registry::getRegistry()->getInstance('node'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_BaseAptProxyFilter.php b/application/hub/main/filter/class_BaseAptProxyFilter.php deleted file mode 100644 index 90056ed28..000000000 --- a/application/hub/main/filter/class_BaseAptProxyFilter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseAptProxyFilter extends BaseHubFilter { - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_BaseChatFilter.php b/application/hub/main/filter/class_BaseChatFilter.php deleted file mode 100644 index 3b29df085..000000000 --- a/application/hub/main/filter/class_BaseChatFilter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseChatFilter extends BaseHubFilter { - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_BaseCrawlerFilter.php b/application/hub/main/filter/class_BaseCrawlerFilter.php deleted file mode 100644 index 3a964eefc..000000000 --- a/application/hub/main/filter/class_BaseCrawlerFilter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCrawlerFilter extends BaseHubFilter { - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_BaseCruncherFilter.php b/application/hub/main/filter/class_BaseCruncherFilter.php deleted file mode 100644 index bba974144..000000000 --- a/application/hub/main/filter/class_BaseCruncherFilter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCruncherFilter extends BaseHubFilter { - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_BaseHubFilter.php b/application/hub/main/filter/class_BaseHubFilter.php deleted file mode 100644 index 6346a60ec..000000000 --- a/application/hub/main/filter/class_BaseHubFilter.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHubFilter extends BaseFilter { - /** - * Array with all data XML nodes (which hold the actual data) and their values - */ - protected $dataXmlNodes = array(); - - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * InvalidXmlNodeException - If an invalid XML node has been found (e.g. - * wrong/out-dated template used) - * XmlNodeMismatchException - Again might be caused by invalid XML node - * usage - * XmlParserException - If the XML message is damaged or not - * well-formed - * - * @param $messageType Type of message - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - * @todo Exceptions from renderXmlContent() are currently unhandled - */ - protected function genericProcessMessage ($messageType, array $messageData, Receivable $packageInstance) { - // Make sure the wanted element is there - assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_MESSAGE])); - assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_SENDER])); - assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_HASH])); - assert(isset($messageData[NetworkPackage::PACKAGE_CONTENT_TAGS])); - - // Get a template instance from the factory - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_' . $messageType . '_template_class'); - - // Get message content - $messageContent = $messageData[NetworkPackage::PACKAGE_CONTENT_MESSAGE]; - - // And render the XML content (aka message) - $templateInstance->renderXmlContent($messageContent); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent); - - /* - * The template system now stores all required data as 'general' - * variables, so simply get them. If there is an invalid XML node - * inside the message, the above method call will cause exceptions. - */ - foreach ($this->dataXmlNodes as $key => $dummy) { - // Call it - $value = $templateInstance->readXmlData($key); - - /* - * If value is NULL, a variable hasn't been found. This could mean - * that *this* node is running an out-dated software or the other - * peer is using an out-dated $messageType.xml template. - */ - if (is_null($value)) { - // Output a warning - self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.'); - - // Skip this part, don't write NULLs to the array - continue; - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value); - - // Set it now - $this->dataXmlNodes[$key] = $value; - } // END - foreach - - // Construct an array for pushing it on next stack - $messageArray = array( - // Message data itself - NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes, - // Message type (which is $messageType) - NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType, - // Message sender - NetworkPackage::MESSAGE_ARRAY_SENDER => $messageData[NetworkPackage::PACKAGE_CONTENT_SENDER], - // Package hash - NetworkPackage::MESSAGE_ARRAY_HASH => $messageData[NetworkPackage::PACKAGE_CONTENT_HASH], - // Package tags - NetworkPackage::MESSAGE_ARRAY_TAGS => $messageData[NetworkPackage::PACKAGE_CONTENT_TAGS], - ); - - // Push the processed message back on stack - $packageInstance->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_BaseMinerFilter.php b/application/hub/main/filter/class_BaseMinerFilter.php deleted file mode 100644 index bfad26404..000000000 --- a/application/hub/main/filter/class_BaseMinerFilter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseMinerFilter extends BaseHubFilter { - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/class_BaseNodeFilter.php b/application/hub/main/filter/class_BaseNodeFilter.php deleted file mode 100644 index 2fbb3f836..000000000 --- a/application/hub/main/filter/class_BaseNodeFilter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseNodeFilter extends BaseHubFilter { - /** - * Protected constructor - * - * @param $className Real name of class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/console/.htaccess b/application/hub/main/filter/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/console/class_Console b/application/hub/main/filter/console/class_Console deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/filter/console/class_Console +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/filter/crawler/.htaccess b/application/hub/main/filter/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/crawler/class_CrawlerInitializationFilter.php b/application/hub/main/filter/crawler/class_CrawlerInitializationFilter.php deleted file mode 100644 index 570346eec..000000000 --- a/application/hub/main/filter/crawler/class_CrawlerInitializationFilter.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerInitializationFilter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCrawlerInitializationFilter () { - // Get a new instance - $filterInstance = new CrawlerInitializationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get an instance - $crawlerInstance = ObjectFactory::createObjectByConfiguredName('node_console_crawler_class'); - - // Get a registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Set the app instance - $crawlerInstance->setApplicationInstance($applicationInstance); - - // Add crawler-specific filters - $crawlerInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/crawler/class_CrawlerPhpRequirementsFilter.php b/application/hub/main/filter/crawler/class_CrawlerPhpRequirementsFilter.php deleted file mode 100644 index f144b03e8..000000000 --- a/application/hub/main/filter/crawler/class_CrawlerPhpRequirementsFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Teama - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerPhpRequirementsFilter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCrawlerPhpRequirementsFilter () { - // Get a new instance - $filterInstance = new CrawlerPhpRequirementsFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If a required PHP function is not available - * @todo Add more test and try to add an extra message to the thrown exception - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // By default, the requirement check is passed and zero checks are failed - $checkPassed = TRUE; - $checksFailed = 0; - - // Socket support is essential... - if (!function_exists('socket_create')) { - // Test failed - $checkPassed = FALSE; - $checksFailed++; - } // END -if - - // Are all tests passed? - if ($checkPassed === FALSE) { - // Throw an exception - throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/crawler/class_CrawlerWelcomeTeaserFilter.php b/application/hub/main/filter/crawler/class_CrawlerWelcomeTeaserFilter.php deleted file mode 100644 index 51579ddf9..000000000 --- a/application/hub/main/filter/crawler/class_CrawlerWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerWelcomeTeaserFilter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCrawlerWelcomeTeaserFilter () { - // Get a new instance - $filterInstance = new CrawlerWelcomeTeaserFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo Handle over the $responseInstance to outputConsoleTeaser() - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Now output the teaser - $crawlerInstance->outputConsoleTeaser(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/cruncher/.htaccess b/application/hub/main/filter/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/cruncher/class_Cruncher b/application/hub/main/filter/cruncher/class_Cruncher deleted file mode 100644 index 77aca806b..000000000 --- a/application/hub/main/filter/cruncher/class_Cruncher +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Cruncher???Filter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createCruncher???Filter () { - // Get a new instance - $filterInstance = new Cruncher???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Implement this! - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php b/application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php deleted file mode 100644 index 7311542db..000000000 --- a/application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherInitializationFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCruncherInitializationFilter () { - // Get a new instance - $filterInstance = new CruncherInitializationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // The default cruncher-mode is from our configuration - $cruncherMode = $this->getConfigInstance()->getConfigEntry('cruncher_default_mode'); - - // Is the cruncher 'mode' parameter set? - if ($requestInstance->isRequestElementSet('mode')) { - // Then use this which overrides the config entry temporarily - $cruncherMode = $requestInstance->getRequestElement('mode'); - } else { - // Set it for easier re-usage - $requestInstance->setRequestElement('mode', $cruncherMode); - } - - // Now convert the cruncher-mode in a class name - $className = 'Hub' . self::convertToClassName($cruncherMode) . 'Cruncher'; - - // And try to instance it - try { - // Get an instance - $cruncherInstance = ObjectFactory::createObjectByName($className); - - // Get a registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Set the app instance - $cruncherInstance->setApplicationInstance($applicationInstance); - - // Add cruncher-specific filters - $cruncherInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - } catch (ClassNotFoundException $e) { - // This exception means, the cruncher mode is invalid. - // @TODO Can we rewrite this to app_exit() ? - $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: cruncher mode ' . $cruncherMode . ' is invalid.'); - } - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/cruncher/class_CruncherPhpRequirementsFilter.php b/application/hub/main/filter/cruncher/class_CruncherPhpRequirementsFilter.php deleted file mode 100644 index db4103372..000000000 --- a/application/hub/main/filter/cruncher/class_CruncherPhpRequirementsFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherPhpRequirementsFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCruncherPhpRequirementsFilter () { - // Get a new instance - $filterInstance = new CruncherPhpRequirementsFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If a required PHP function is not available - * @todo Add more test and try to add an extra message to the thrown exception - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // By default, the requirement check is passed and zero checks are failed - $checkPassed = TRUE; - $checksFailed = 0; - - // Socket support is essential... - if (!function_exists('socket_create')) { - // Test failed - $checkPassed = FALSE; - $checksFailed++; - } // END -if - - // Are all tests passed? - if ($checkPassed === FALSE) { - // Throw an exception - throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/cruncher/class_CruncherWelcomeTeaserFilter.php b/application/hub/main/filter/cruncher/class_CruncherWelcomeTeaserFilter.php deleted file mode 100644 index b30d47fb8..000000000 --- a/application/hub/main/filter/cruncher/class_CruncherWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherWelcomeTeaserFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCruncherWelcomeTeaserFilter () { - // Get a new instance - $filterInstance = new CruncherWelcomeTeaserFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo Handle over the $responseInstance to outputConsoleTeaser() - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Now output the teaser - $cruncherInstance->outputConsoleTeaser(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/miner/.htaccess b/application/hub/main/filter/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/miner/class_Miner b/application/hub/main/filter/miner/class_Miner deleted file mode 100644 index 0cf9ced60..000000000 --- a/application/hub/main/filter/miner/class_Miner +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Miner???Filter extends BaseminerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createMiner???Filter () { - // Get a new instance - $filterInstance = new Miner???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Implement this! - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/miner/class_MinerInitializationFilter.php b/application/hub/main/filter/miner/class_MinerInitializationFilter.php deleted file mode 100644 index dec2e891d..000000000 --- a/application/hub/main/filter/miner/class_MinerInitializationFilter.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerInitializationFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createMinerInitializationFilter () { - // Get a new instance - $filterInstance = new MinerInitializationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // The default miner-mode is from our configuration - $minerMode = $this->getConfigInstance()->getConfigEntry('miner_default_mode'); - - // Is the miner 'mode' parameter set? - if ($requestInstance->isRequestElementSet('mode')) { - // Then use this which overrides the config entry temporarily - $minerMode = $requestInstance->getRequestElement('mode'); - } else { - // Set it for easier re-usage - $requestInstance->setRequestElement('mode', $minerMode); - } - - // Now convert the miner-mode in a class name - $className = 'Hub' . self::convertToClassName($minerMode) . 'Miner'; - - // And try to instance it - try { - // Get an instance - $minerInstance = ObjectFactory::createObjectByName($className); - - // Get a registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Set the app instance - $minerInstance->setApplicationInstance($applicationInstance); - - // Add miner-specific filters - $minerInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance); - } catch (ClassNotFoundException $e) { - // This exception means, the miner mode is invalid. - // @TODO Can we rewrite this to app_exit() ? - $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: miner mode ' . $minerMode . ' is invalid.'); - } - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/miner/class_MinerPhpRequirementsFilter.php b/application/hub/main/filter/miner/class_MinerPhpRequirementsFilter.php deleted file mode 100644 index 918568833..000000000 --- a/application/hub/main/filter/miner/class_MinerPhpRequirementsFilter.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerPhpRequirementsFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createMinerPhpRequirementsFilter () { - // Get a new instance - $filterInstance = new MinerPhpRequirementsFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If a required PHP function is not available - * @todo Add more test and try to add an extra message to the thrown exception - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // By default, the requirement check is passed and zero checks are failed - $checkPassed = TRUE; - $checksFailed = 0; - - // Socket support is essential... - if (!function_exists('socket_create')) { - // Test failed - $checkPassed = FALSE; - $checksFailed++; - } // END -if - - // If scrypt() is not found (ext-scrypt) then the "Hubcoins reward" is not working - if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) { - // Mark it as working - self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt and a callable scrypt() function found. "Hubcoin reward" feature possible.'); - $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); - } else { - // Not working (not all have ext-scrypt installed - self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt not found or scrypt() function not found. "Hubcoin reward" feature disabled.'); - } - - // Are all tests passed? - if ($checkPassed === FALSE) { - // Throw an exception - throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/miner/class_MinerWelcomeTeaserFilter.php b/application/hub/main/filter/miner/class_MinerWelcomeTeaserFilter.php deleted file mode 100644 index e671de20a..000000000 --- a/application/hub/main/filter/miner/class_MinerWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerWelcomeTeaserFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createMinerWelcomeTeaserFilter () { - // Get a new instance - $filterInstance = new MinerWelcomeTeaserFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo Handle over the $responseInstance to outputConsoleTeaser() - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Now output the teaser - $minerInstance->outputConsoleTeaser(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/node/.htaccess b/application/hub/main/filter/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/node/class_Node b/application/hub/main/filter/node/class_Node deleted file mode 100644 index 149bd2723..000000000 --- a/application/hub/main/filter/node/class_Node +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Node???Filter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createNode???Filter () { - // Get a new instance - $filterInstance = new Node???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Implement this! - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/node/class_NodeInitializationFilter.php b/application/hub/main/filter/node/class_NodeInitializationFilter.php deleted file mode 100644 index f15806bfa..000000000 --- a/application/hub/main/filter/node/class_NodeInitializationFilter.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeInitializationFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeInitializationFilter () { - // Get a new instance - $filterInstance = new NodeInitializationFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Try to instance it by using a factory - try { - // Get an instance - $nodeInstance = NodeObjectFactory::createNodeInstance($requestInstance, $responseInstance); - } catch (ClassNotFoundException $e) { - // This exception means, the node mode is invalid. - // @TODO Can we rewrite this to app_exit() ? - $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: node mode ' . $nodeMode . ' is invalid.'); - } - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: Node ' . $nodeMode . ' has been added to registry.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/node/class_NodePhpRequirementsFilter.php b/application/hub/main/filter/node/class_NodePhpRequirementsFilter.php deleted file mode 100644 index 7cba2b5ca..000000000 --- a/application/hub/main/filter/node/class_NodePhpRequirementsFilter.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodePhpRequirementsFilter () { - // Get a new instance - $filterInstance = new NodePhpRequirementsFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If a required PHP function is not available - * @todo Add more test and try to add an extra message to the thrown exception - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // By default, the requirement check is passed and zero checks are failed - $checkPassed = TRUE; - $checksFailed = 0; - - // Socket support is essential... - if (!function_exists('socket_create')) { - // Test failed - $checkPassed = FALSE; - $checksFailed++; - } // END - if - - // If scrypt() is not found (ext-scrypt) then the "Hubcoins reward" is not working - if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) { - // Mark it as working - self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt and a callable scrypt() function found. "Hubcoin reward" feature possible.'); - $this->getConfigInstance()->setConfigEntry('extension_scrypt_loaded', TRUE); - } else { - // Not working (not all have ext-scrypt installed - self::createDebugInstance(__CLASS__)->debugOutput('FILTER[' . __METHOD__ . ':' . __LINE__ . '] ext-scrypt not found or scrypt() function not found. "Hubcoin reward" feature disabled.'); - } - - // Are all tests passed? - if ($checkPassed === FALSE) { - // Throw an exception - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/node/class_NodeWelcomeTeaserFilter.php b/application/hub/main/filter/node/class_NodeWelcomeTeaserFilter.php deleted file mode 100644 index fe3d4551c..000000000 --- a/application/hub/main/filter/node/class_NodeWelcomeTeaserFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeWelcomeTeaserFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeWelcomeTeaserFilter () { - // Get a new instance - $filterInstance = new NodeWelcomeTeaserFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo Handle over the $responseInstance to outputConsoleTeaser() - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Now output the teaser - $nodeInstance->outputConsoleTeaser(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/.htaccess b/application/hub/main/filter/shutdown/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/shutdown/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/shutdown/apt-proxy/.htaccess b/application/hub/main/filter/shutdown/apt-proxy/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/shutdown/apt-proxy/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/shutdown/apt-proxy/class_AptProxyShutdownFilter.php b/application/hub/main/filter/shutdown/apt-proxy/class_AptProxyShutdownFilter.php deleted file mode 100644 index 2887c191f..000000000 --- a/application/hub/main/filter/shutdown/apt-proxy/class_AptProxyShutdownFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyShutdownFilter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createAptProxyShutdownFilter () { - // Get a new instance - $filterInstance = new AptProxyShutdownFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $proxyInstance = Registry::getRegistry()->getInstance('apt_proxy'); - - // Shutdown the apt-proxy. This should be the last line - $proxyInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/chat/.htaccess b/application/hub/main/filter/shutdown/chat/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/shutdown/chat/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/shutdown/chat/class_ChatShutdownFilter.php b/application/hub/main/filter/shutdown/chat/class_ChatShutdownFilter.php deleted file mode 100644 index 04a397aed..000000000 --- a/application/hub/main/filter/shutdown/chat/class_ChatShutdownFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatShutdownFilter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createChatShutdownFilter () { - // Get a new instance - $filterInstance = new ChatShutdownFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Shutdown the chat. This should be the last line - $chatInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/class_HubShutdown b/application/hub/main/filter/shutdown/class_HubShutdown deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/filter/shutdown/class_HubShutdown +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/filter/shutdown/crawler/.htaccess b/application/hub/main/filter/shutdown/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/shutdown/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/shutdown/crawler/class_CrawlerShutdownFilter.php b/application/hub/main/filter/shutdown/crawler/class_CrawlerShutdownFilter.php deleted file mode 100644 index 97f48da7a..000000000 --- a/application/hub/main/filter/shutdown/crawler/class_CrawlerShutdownFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerShutdownFilter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCrawlerShutdownFilter () { - // Get a new instance - $filterInstance = new CrawlerShutdownFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Shutdown the crawler. This should be the last line - $crawlerInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/cruncher/.htaccess b/application/hub/main/filter/shutdown/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/shutdown/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/shutdown/cruncher/class_CruncherShutdownFilter.php b/application/hub/main/filter/shutdown/cruncher/class_CruncherShutdownFilter.php deleted file mode 100644 index e116d09c1..000000000 --- a/application/hub/main/filter/shutdown/cruncher/class_CruncherShutdownFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherShutdownFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCruncherShutdownFilter () { - // Get a new instance - $filterInstance = new CruncherShutdownFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Shutdown the cruncher. This should be the last line - $cruncherInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/miner/.htaccess b/application/hub/main/filter/shutdown/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/shutdown/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/shutdown/miner/class_MinerShutdownFilter.php b/application/hub/main/filter/shutdown/miner/class_MinerShutdownFilter.php deleted file mode 100644 index 8481f1dd6..000000000 --- a/application/hub/main/filter/shutdown/miner/class_MinerShutdownFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerShutdownFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createMinerShutdownFilter () { - // Get a new instance - $filterInstance = new MinerShutdownFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Shutdown the miner. This should be the last line - $minerInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/node/.htaccess b/application/hub/main/filter/shutdown/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/shutdown/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/shutdown/node/class_NodeShutdown b/application/hub/main/filter/shutdown/node/class_NodeShutdown deleted file mode 100644 index 85398da88..000000000 --- a/application/hub/main/filter/shutdown/node/class_NodeShutdown +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubShutdown???Filter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createHubShutdown???Filter () { - // Get a new instance - $filterInstance = new HubShutdown???Filter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = Registry::getRegistry()->getInstance('node'); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php b/application/hub/main/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php deleted file mode 100644 index 9f6f3e6a1..000000000 --- a/application/hub/main/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeShutdownFlushNodeListFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeShutdownFlushNodeListFilter () { - // Get a new instance - $filterInstance = new NodeShutdownFlushNodeListFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Now do something - $this->partialStub('Please implement this step.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/node/class_NodeShutdownNodeFilter.php b/application/hub/main/filter/shutdown/node/class_NodeShutdownNodeFilter.php deleted file mode 100644 index be151db10..000000000 --- a/application/hub/main/filter/shutdown/node/class_NodeShutdownNodeFilter.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeShutdownNodeFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeShutdownNodeFilter () { - // Get a new instance - $filterInstance = new NodeShutdownNodeFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException please) - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Shutdown the node. This should be the last line - $nodeInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php b/application/hub/main/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php deleted file mode 100644 index 48d47edfd..000000000 --- a/application/hub/main/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeShutdownTaskHandlerFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeShutdownTaskHandlerFilter () { - // Get a new instance - $filterInstance = new NodeShutdownTaskHandlerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get task handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Shutdown the task manager and all its registered tasks - $handlerInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/tags/.htaccess b/application/hub/main/filter/tags/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/tags/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/tags/answer/.htaccess b/application/hub/main/filter/tags/answer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/tags/answer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php b/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php deleted file mode 100644 index 3c9129bfb..000000000 --- a/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageAnnouncementAnswerTagFilter extends BaseNodeFilter implements FilterablePackage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->dataXmlNodes = array( - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => '', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID => '', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => '', - BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '', - ); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createPackageAnnouncementAnswerTagFilter () { - // Get a new instance - $filterInstance = new PackageAnnouncementAnswerTagFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Process message in generic way - $this->genericProcessMessage('announcement_answer', $messageData, $packageInstance); - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function postProcessMessage (Receivable $packageInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php b/application/hub/main/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php deleted file mode 100644 index 2b5c4dd75..000000000 --- a/application/hub/main/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageDhtBootstrapAnswerTagFilter extends BaseNodeFilter implements FilterablePackage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->dataXmlNodes = array( - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => '', - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_LIST => '', - BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '', - ); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createPackageDhtBootstrapAnswerTagFilter () { - // Get a new instance - $filterInstance = new PackageDhtBootstrapAnswerTagFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Process message in generic way - $this->genericProcessMessage('dht_bootstrap_answer', $messageData, $packageInstance); - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function postProcessMessage (Receivable $packageInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php b/application/hub/main/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php deleted file mode 100644 index 33d643fac..000000000 --- a/application/hub/main/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageRequestNodeListAnswerTagFilter extends BaseNodeFilter implements FilterablePackage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->dataXmlNodes = array( - XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID => '', - XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST => '', - BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '', - ); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createPackageRequestNodeListAnswerTagFilter () { - // Get a new instance - $filterInstance = new PackageRequestNodeListAnswerTagFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Process message in generic way - $this->genericProcessMessage('request_node_list_answer', $messageData, $packageInstance); - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function postProcessMessage (Receivable $packageInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php b/application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php deleted file mode 100644 index 7b992b654..000000000 --- a/application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageAnnouncementTagFilter extends BaseNodeFilter implements FilterablePackage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->dataXmlNodes = array( - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => '', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE => '', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID => '', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => '', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => '', - ); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createPackageAnnouncementTagFilter () { - // Get a new instance - $filterInstance = new PackageAnnouncementTagFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * InvalidXmlNodeException - If an invalid XML node has been found (e.g. - * wrong/out-dated template used) - * XmlNodeMismatchException - Again might be caused by invalid XML node - * usage - * XmlParserException - If the XML message is damaged or not - * well-formed - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Process message generic - $this->genericProcessMessage('announcement', $messageData, $packageInstance); - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function postProcessMessage (Receivable $packageInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php b/application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php deleted file mode 100644 index c40c2c9e8..000000000 --- a/application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageDhtBootstrapTagFilter extends BaseNodeFilter implements FilterablePackage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->dataXmlNodes = array( - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => '', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => '', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => '', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE => '', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => '', - ); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createPackageDhtBootstrapTagFilter () { - // Get a new instance - $filterInstance = new PackageDhtBootstrapTagFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * InvalidXmlNodeException - If an invalid XML node has been found (e.g. - * wrong/out-dated template used) - * XmlNodeMismatchException - Again might be caused by invalid XML node - * usage - * XmlParserException - If the XML message is damaged or not - * well-formed - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Process message generic - $this->genericProcessMessage('dht_bootstrap', $messageData, $packageInstance); - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function postProcessMessage (Receivable $packageInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/tags/class_PackageRequestNodeListTagFilter.php b/application/hub/main/filter/tags/class_PackageRequestNodeListTagFilter.php deleted file mode 100644 index 71c45c448..000000000 --- a/application/hub/main/filter/tags/class_PackageRequestNodeListTagFilter.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageRequestNodeListTagFilter extends BaseNodeFilter implements FilterablePackage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init XML nodes array which contains the required data - $this->dataXmlNodes = array( - XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES => '', - XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID => '', - ); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createPackageRequestNodeListTagFilter () { - // Get a new instance - $filterInstance = new PackageRequestNodeListTagFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Processes the given raw message content. - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Process messasge generic - $this->genericProcessMessage('request_node_list', $messageData, $packageInstance); - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function postProcessMessage (Receivable $packageInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/tags/class_PackageSelfConnectTagFilter.php b/application/hub/main/filter/tags/class_PackageSelfConnectTagFilter.php deleted file mode 100644 index bd75e4505..000000000 --- a/application/hub/main/filter/tags/class_PackageSelfConnectTagFilter.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageSelfConnectTagFilter extends BaseNodeFilter implements FilterablePackage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->dataXmlNodes = array( - XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID => '', - XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID => '', - ); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function createPackageSelfConnectTagFilter () { - // Get a new instance - $filterInstance = new PackageSelfConnectTagFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Processes the given raw message content. The method renderXmlContent - * may throw (not the method itself) several exceptions: - * - * InvalidXmlNodeException - If an invalid XML node has been found (e.g. - * wrong/out-dated template used) - * XmlNodeMismatchException - Again might be caused by invalid XML node - * usage - * XmlParserException - If the XML message is damaged or not - * well-formed - * - * @param $messageData Raw message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function processMessage (array $messageData, Receivable $packageInstance) { - // Process generic - $this->genericProcessMessage('self_connect', $messageData, $packageInstance); - } - - /** - * Post-processes the stacked message. Do not call popNamed() as then no - * other class can process the message. - * - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws UnsupportedOperationException If this method is called, please use processMessage() instead! - */ - public function postProcessMessage (Receivable $packageInstance) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/task/.htaccess b/application/hub/main/filter/task/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/task/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/task/apt-proxy/.htaccess b/application/hub/main/filter/task/apt-proxy/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/task/apt-proxy/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/task/apt-proxy/class_AptProxyTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/apt-proxy/class_AptProxyTaskHandlerInitializerFilter.php deleted file mode 100644 index 17e808a62..000000000 --- a/application/hub/main/filter/task/apt-proxy/class_AptProxyTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 apt-proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyTaskHandlerInitializerFilter extends BaseAptProxyFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createAptProxyTaskHandlerInitializerFilter () { - // Get a new instance - $filterInstance = new AptProxyTaskHandlerInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If the filter chain needs to be interrupted - * @todo 5% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get apt-proxy instance - //$chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Get a new task handler instance - $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - - // Put the task handler in registry - Registry::getRegistry()->addInstance('task_handler', $handlerInstance); - - /* - * Register all tasks: - * - * 1) apt-proxy listener - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('apt_proxy_listener_task_class'); - $handlerInstance->registerTask('apt_proxy_listener', $taskInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/task/chat/.htaccess b/application/hub/main/filter/task/chat/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/task/chat/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php deleted file mode 100644 index 85db533fb..000000000 --- a/application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatTaskHandlerInitializerFilter extends BaseChatFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createChatTaskHandlerInitializerFilter () { - // Get a new instance - $filterInstance = new ChatTaskHandlerInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If the filter chain needs to be interrupted - * @todo 5% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get chat instance - //$chatInstance = Registry::getRegistry()->getInstance('chat'); - - // Get a new task handler instance - $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - - // Put the task handler in registry - Registry::getRegistry()->addInstance('task_handler', $handlerInstance); - - /* - * Register all tasks: - * - * 1) Telnet session listener - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('chat_telnet_listener_task_class'); - $handlerInstance->registerTask('chat_telnet_listener', $taskInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/task/crawler/.htaccess b/application/hub/main/filter/task/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/task/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php deleted file mode 100644 index 1a5ee9eb7..000000000 --- a/application/hub/main/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerTaskHandlerInitializerFilter extends BaseCrawlerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCrawlerTaskHandlerInitializerFilter () { - // Get a new instance - $filterInstance = new CrawlerTaskHandlerInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If the filter chain needs to be interrupted - * @todo 10% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get crawler instance - //$crawlerInstance = Registry::getRegistry()->getInstance('crawler'); - - // Get a new task handler instance - $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - - // Put the task handler in registry - Registry::getRegistry()->addInstance('task_handler', $handlerInstance); - - /* - * Register all tasks: - * - * 1) "Communicator" for crawler->node communication - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_node_communicator_task_class'); - $handlerInstance->registerTask('crawler_node_communicator', $taskInstance); - - // 2) Local URL crawler (gets URLs locally and adds them to the analyzer's input stack) - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_local_url_crawler_task_class'); - $handlerInstance->registerTask('crawler_local_url_crawler', $taskInstance); - - // 3) Remote URL crawler (gets URLs locally for other nodes, also includes the crawled URL in local index) - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_remote_url_crawler_task_class'); - $handlerInstance->registerTask('crawler_remote_url_crawler', $taskInstance); - - // 4) Remote-crawl publisher (publishes crawl jobs for remote retrieval) - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_remote_job_publisher_task_class'); - $handlerInstance->registerTask('crawler_remote_job_publisher', $taskInstance); - - // 5) MIME sniffer - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_mime_sniffer_task_class'); - $handlerInstance->registerTask('crawler_mime_sniffer', $taskInstance); - - // 6) Document parser (converts document to meta format) - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_document_parser_task_class'); - $handlerInstance->registerTask('crawler_document_parser', $taskInstance); - - // 7) Document structure analyzer - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_structure_analyzer_task_class'); - $handlerInstance->registerTask('crawler_structure_analyzer', $taskInstance); - - // 8) Snippet extractor - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_snippet_extractor_task_class'); - $handlerInstance->registerTask('crawler_snippet_extractor', $taskInstance); - - // 9) Node ping - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_ping_task_class'); - $handlerInstance->registerTask('crawler_ping', $taskInstance); - - // 10) URL sources - foreach (explode(':', $this->getConfigInstance()->getConfigEntry('crawler_url_stacks')) as $stack) { - // Init task instance - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_url_source_' . $stack . '_task_class'); - - // And register it - $handlerInstance->registerTask('crawler_url_source_' . $stack, $taskInstance); - } // END - foreach - - // 11) Uploaded list scanner (checks for wanted files) - $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_uploaded_list_scanner_task_class'); - $handlerInstance->registerTask('crawler_uploaded_list_scanner', $taskInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/task/cruncher/.htaccess b/application/hub/main/filter/task/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/task/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php deleted file mode 100644 index 2d0095ec2..000000000 --- a/application/hub/main/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherTaskHandlerInitializerFilter extends BaseCruncherFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createCruncherTaskHandlerInitializerFilter () { - // Get a new instance - $filterInstance = new CruncherTaskHandlerInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If the filter chain needs to be interrupted - * @todo 5% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get cruncher instance - //$cruncherInstance = Registry::getRegistry()->getInstance('cruncher'); - - // Get a new task handler instance - $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - - // Put the task handler in registry - Registry::getRegistry()->addInstance('task_handler', $handlerInstance); - - // Register all tasks: - // - // 1) A task for fetching WUs (work units) or test units - $taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_work_unit_fetcher_task_class'); - $handlerInstance->registerTask('cruncher_work_unit_fetcher', $taskInstance); - - /* - * 2) A task for generating test units, a if() block could be placed - * around this but that would make this method look a little ugly and - * even more when more "temporary" tasks should be registered. - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_producer_task_class'); - $handlerInstance->registerTask('cruncher_test_unit_producer', $taskInstance); - - /* - * 3) A task for generating keys based on the generated test unit. This - * task will only be executed if the state of the cruncher is one of - * these: 'virgin'. - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_key_producer_task_class'); - $handlerInstance->registerTask('cruncher_key_producer', $taskInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/task/miner/.htaccess b/application/hub/main/filter/task/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/task/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php deleted file mode 100644 index aaa30dbf1..000000000 --- a/application/hub/main/filter/task/miner/class_MinerTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerTaskHandlerInitializerFilter extends BaseMinerFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createMinerTaskHandlerInitializerFilter () { - // Get a new instance - $filterInstance = new MinerTaskHandlerInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If the filter chain needs to be interrupted - * @todo 5% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get miner instance - //$minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Get a new task handler instance - $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - - // Put the task handler in registry - Registry::getRegistry()->addInstance('task_handler', $handlerInstance); - - // Register all tasks: - // - // 1) A task for fetching blocks from the network - $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_block_fetcher_task_class'); - $handlerInstance->registerTask('miner_block_fetcher', $taskInstance); - - /* - * 2) A task for generating a test "genesis" block. This "block" - * consists of several hashes of famous phrases or "catch lines" from - * free-software authors. - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_test_genesis_block_producer_task_class'); - $handlerInstance->registerTask('miner_test_genesis_block_producer', $taskInstance); - - /* - * 3) A task for generating a real "genesis" block. @TODO Define how a - * real "genesis" block is generated - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_real_genesis_block_producer_task_class'); - $handlerInstance->registerTask('miner_real_genesis_block_producer', $taskInstance); - - /* - * 4) A task for communicating into the locally running 'hub' node. - * This rask will check for new blocks on the mining network and - * tries to claim found blocks. - */ - $taskInstance = ObjectFactory::createObjectByConfiguredName('miner_node_communicator_task_class'); - $handlerInstance->registerTask('miner_node_communicator', $taskInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/filter/task/node/.htaccess b/application/hub/main/filter/task/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/filter/task/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php deleted file mode 100644 index 6b12e4169..000000000 --- a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeTaskHandlerInitializerFilter extends BaseNodeFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNodeTaskHandlerInitializerFilter () { - // Get a new instance - $filterInstance = new NodeTaskHandlerInitializerFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If the filter chain needs to be interrupted - * @todo Maybe some more tasks needs to be added? - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Get a new task handler instance - $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - - // Put the task handler in registry - Registry::getRegistry()->addInstance('task_handler', $handlerInstance); - - // Prepare a package-tags initialization task for the listeners - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class'); - - // Register it - $handlerInstance->registerTask('package_tags_init', $taskInstance); - - // Generate package writer task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_writer_task_class'); - - // Register it as well - $handlerInstance->registerTask('network_package_writer', $taskInstance); - - // Generate package reader task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class'); - - // Network package reader, needs to be delayed a little - $handlerInstance->registerTask('network_package_reader', $taskInstance); - - // Generate socket listener task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_socket_listener_task_class'); - - // Network package reader, needs to be delayed a little - $handlerInstance->registerTask('socket_listener', $taskInstance); - - // Generate package decoder task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_decoder_task_class'); - - // Register it as well - $handlerInstance->registerTask('package_decoder', $taskInstance); - - // Generate chunk assembler task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_chunk_assembler_task_class'); - - // Register it as well - $handlerInstance->registerTask('chunk_assembler', $taskInstance); - - // Generate DHT initialization task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_init_task_class'); - - // Register it as well - $handlerInstance->registerTask('dht_init', $taskInstance); - - // Generate DHT query task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_query_task_class'); - - // Register it as well - $handlerInstance->registerTask('dht_query', $taskInstance); - - // Generate DHT publication-check task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_publication_check_task_class'); - - // Register it as well - $handlerInstance->registerTask('dht_check_publication', $taskInstance); - - // Generate DHT publication task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_publication_task_class'); - - // Register it as well - $handlerInstance->registerTask('dht_publication', $taskInstance); - - // Prepare a self-test task for the listeners - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_selfconnect_task_class'); - - // Register it - $handlerInstance->registerTask('self_connect', $taskInstance); - - // Prepare a update-check task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_update_check_task_class'); - - // Register it - $handlerInstance->registerTask('update_check', $taskInstance); - - // Get the list instance here - $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); - - // Prepare a ping task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance)); - - // Register it - $handlerInstance->registerTask('ping', $taskInstance); - - /* - * Allow extra node-depending tasks, e.g. the bootstrapper node needs - * booting its DHT. DHTs are decentralized and are working on - * peer-to-peer basis. - */ - $nodeInstance->addExtraTasks($handlerInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/.htaccess b/application/hub/main/handler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/answer-status/.htaccess b/application/hub/main/handler/answer-status/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/answer-status/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/answer-status/announcement/.htaccess b/application/hub/main/handler/answer-status/announcement/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/answer-status/announcement/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php b/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php deleted file mode 100644 index 64425d5b7..000000000 --- a/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->searchData = array( - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - ); - - // Set handler name - $this->setHandlerName('announcement_answer_okay'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createAnnouncementAnswerOkayHandler () { - // Get new instance - $handlerInstance = new AnnouncementAnswerOkayHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles given message data array - * - * @param $messageData An array of message data - * @param $packageInstance An instance of a Receivable class - * @return void - * @todo Do some more here: Handle karma, et cetera? - */ - public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) { - /* - * Query DHT and force update (which will throw an exception if the - * node is not found). - */ - $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); - - // Get handler instance - $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); - - // Generate DHT bootstrap task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_late_bootstrap_task_class'); - - // Register it as well - $handlerInstance->registerTask('dht_late_bootstrap', $taskInstance); - - // Get the node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Change state - $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful(); - - // Prepare next message - $this->prepareNextMessage($messageData, $packageInstance); - } - - /** - * Initializes configuration data from given message data array - * - * The following array is being handled over: - * - * my-external-address => 1.2.3.4 - * my-internal-address => 5.6.7.8 - * my-status => reachable - * my-node-id => aaabbbcccdddeeefff123456789 - * my-session-id => aaabbbcccdddeeefff123456789 - * my-tcp-port => 9060 - * my-udp-port => 9060 - * answer-status => OKAY - * message_type => announcement_answer - * - * @param $messageData An array with all message data - * @return void - */ - protected function initMessageConfigurationData (array $messageData) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Get an array of all accepted object types - $objectList = $nodeInstance->getListFromAcceptedObjectTypes(); - - // Add missing (temporary) configuration 'accepted_object_types' - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList)); - } - - /** - * Removes configuration data with given message data array from global - * configuration. For content of $messageData see method comment above. - * - * @param $messageData An array with all message data - * @return void - */ - protected function removeMessageConfigurationData (array $messageData) { - // Remove temporay configuration - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/answer-status/class_ b/application/hub/main/handler/answer-status/class_ deleted file mode 100644 index b792e7b53..000000000 --- a/application/hub/main/handler/answer-status/class_ +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Handler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('|||_answer_==='); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function create???Handler () { - // Get new instance - $handlerInstance = new ???Handler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles given message data array - * - * @param $messageData An array of message data - * @return void - */ - public function handleAnswerMessageData (array $messageData) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php b/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php deleted file mode 100644 index 540bb1c45..000000000 --- a/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseAnserStatusHandler extends BaseDataHandler { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/answer-status/requests/.htaccess b/application/hub/main/handler/answer-status/requests/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/answer-status/requests/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php deleted file mode 100644 index 128dbc300..000000000 --- a/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->searchData = array( - XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, - ); - - // Set handler name - $this->setHandlerName('request_node_list_answer_okay'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createRequestNodeListAnswerOkayHandler () { - // Get new instance - $handlerInstance = new RequestNodeListAnswerOkayHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles given message data array - * - * @param $messageData An array of message data - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws NodeSessionIdVerficationException If the provided session id is not matching - * @todo Do some more here: Handle karma, et cetera? - */ - public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) { - // Make sure node-list is found in array - assert(isset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); - - // Save node list - $nodeList = json_decode(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); - - // Make sure it is completely decoded - assert(is_array($nodeList)); - - // ... and remove it as it should not be included now - unset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]); - - // Write node list to DHT - $this->getDhtInstance()->insertNodeList($nodeList); - - /* - * Query DHT and force update (which will throw an exception if the - * node is not found). - */ - $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); - - // Prepare next message ("hello" message to all returned nodes) - //$this->prepareNextMessage($messageData, $packageInstance); - } - - /** - * Initializes configuration data from given message data array - * - * The following array is being handled over: - * - * session-id => aaabbbcccdddeeefff123456789 - * node-list => aabb:ccdd:eeff - * answer-status => OKAY - * message_type => request_node_list_answer - * - * @param $messageData An array with all message data - * @return void - * @todo 0% done - */ - protected function initMessageConfigurationData (array $messageData) { - $this->partialStub('Please implement this method.'); - } - - /** - * Removes configuration data with given message data array from global - * configuration. For content of $messageData see method comment above. - * - * @param $messageData An array with all message data - * @return void - * @todo 0% done - */ - protected function removeMessageConfigurationData (array $messageData) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/chunks/.htaccess b/application/hub/main/handler/chunks/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/chunks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/chunks/class_ChunkHandler.php b/application/hub/main/handler/chunks/class_ChunkHandler.php deleted file mode 100644 index 180805cdd..000000000 --- a/application/hub/main/handler/chunks/class_ChunkHandler.php +++ /dev/null @@ -1,656 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable { - /** - * Stacker for chunks with final EOP - */ - const STACKER_NAME_CHUNKS_WITH_FINAL_EOP = 'final_chunks'; - const STACKER_NAME_CHUNKS_WITHOUT_FINAL = 'pending_chunks'; - const STACKER_NAME_ASSEMBLED_RAW_DATA = 'chunk_raw_data'; - - /** - * Chunk splits: - * 0 = Hash - * 1 = Serial number - * 2 = Raw data - */ - const CHUNK_SPLITS_INDEX_HASH = 0; - const CHUNK_SPLITS_INDEX_SERIAL = 1; - const CHUNK_SPLITS_INDEX_RAW_DATA = 2; - - /** - * The final array for assembling the original package back together - */ - private $finalPackageChunks = array(); - - /** - * Array of chunk hashes - */ - private $chunkHashes = array(); - - /** - * Raw EOP chunk data in an array: - * - * 0 = Final hash, - * 1 = Hash of last chunk - */ - private $eopChunk = array(); - - /** - * Raw package data - */ - private $rawPackageData = ''; - - /** - * Fragmenter instance, needs to be set here again - */ - private $fragmenterInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('chunk'); - - // Initialize handler - $this->initHandler(); - - // Get a fragmenter instance for later verification of serial numbers (e.g. if all are received) - $fragmenterInstance = FragmenterFactory::createFragmenterInstance('package'); - - // Set it in this handler - $this->fragmenterInstance = $fragmenterInstance; - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a chunk Handler class - */ - public final static function createChunkHandler () { - // Get new instance - $handlerInstance = new ChunkHandler(); - - // Get a FIFO stacker - $stackInstance = ObjectFactory::createObjectByConfiguredName('chunk_handler_stacker_class'); - - // Init all stacker - $stackInstance->initStacks(array( - self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, - self::STACKER_NAME_CHUNKS_WITHOUT_FINAL, - self::STACKER_NAME_ASSEMBLED_RAW_DATA - )); - - // Set the stacker in this handler - $handlerInstance->setStackInstance($stackInstance); - - // Get a crypto instance ... - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - - // ... and set it in this handler - $handlerInstance->setCryptoInstance($cryptoInstance); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Initializes the handler - * - * @return void - */ - private function initHandler () { - // Noisy debug line: - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Initializing handler ...'); - - // Init finalPackageChunks - $this->finalPackageChunks = array( - // Array for package content - 'content' => array(), - // ... and for the hashes - 'hashes' => array(), - // ... marker for that the final array is complete for assembling all chunks - 'is_complete' => FALSE, - // ... steps done to assemble all chunks - 'assemble_steps' => 0, - ); - - // ... chunkHashes: - $this->chunkHashes = array(); - - // ... eopChunk: - $this->eopChunk = array( - 0 => 'INVALID', - 1 => 'INVALID', - ); - } - - /** - * Checks whether the hash generated from package content is the same ("valid") as given - * - * @param $chunkSplits An array from a splitted chunk - * @return $isValid Whether the hash is "valid" - */ - private function isChunkHashValid (array $chunkSplits) { - // Noisy debug line: - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: chunkSplits=' . print_r($chunkSplits, TRUE)); - - // Assert on some elements - assert(isset($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA])); - assert(isset($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH])); - - // Now hash the raw data again - $chunkHash = $this->getCryptoInstance()->hashString($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA], $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH], FALSE); - - // Check it - $isValid = ($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] === $chunkHash); - - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: chunkHash=' . $chunkHash . ',isValid=' . intval($isValid)); - - // ... and return it - return $isValid; - } - - /** - * Checks whether the given serial number is valid - * - * @param $serialNumber A serial number from a chunk - * @return $isValid Whether the serial number is valid - */ - private function isSerialNumberValid ($serialNumber) { - // Check it - $isValid = ((strlen($serialNumber) == PackageFragmenter::MAX_SERIAL_LENGTH) && ($this->hexval($serialNumber, FALSE) === $serialNumber)); - - // Return result - return $isValid; - } - - /** - * Adds the chunk to the final array which will be used for the final step - * which will be to assemble all chunks back to the original package content - * and for the final hash check. - * - * This method may throw an exception if a chunk with the same serial number - * has already been added to avoid mixing chunks from different packages. - * - * @param $chunkSplits An array from a splitted chunk - * @return void - */ - private function addChunkToFinalArray (array $chunkSplits) { - // Is the serial number (index 1) already been added? - if (isset($this->finalPackageChunks[$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]])) { - // Then throw an exception - throw new ChunkAlreadyAssembledException(array($this, $chunkSplits), self::EXCEPTION_CHUNK_ALREADY_ASSEMBLED); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]); - - // Add the chunk data (index 2) to the final array and use the serial number as index - $this->finalPackageChunks['content'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]; - - // ... and the hash as well - $this->finalPackageChunks['hashes'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]; - } - - /** - * Marks the final array as completed, do only this if you really have all - * chunks together including EOP and "hash chunk". - * - * @return void - */ - private function markFinalArrayAsCompleted () { - /* - * As for now, just set the array element. If any further steps are - * being added, this should always be the last step. - */ - $this->finalPackageChunks['is_complete'] = TRUE; - } - - /** - * Sorts the chunks array by using the serial number as a sorting key. In - * most situations a call of ksort() is enough to accomblish this. So this - * method may only call ksort() on the chunks array. - * - * This method sorts 'content' and 'hashes' so both must have used the - * serial numbers as array indexes. - * - * @return void - */ - private function sortChunksArray () { - // Sort 'content' first - ksort($this->finalPackageChunks['content']); - - // ... then 'hashes' - ksort($this->finalPackageChunks['hashes']); - } - - /** - * Prepares the package assemble by removing last chunks (last shall be - * hash chunk, pre-last shall be EOP chunk) and verify that all serial - * numbers are valid (same as PackageFragmenter class would generate). - * - * @return void - */ - private function preparePackageAssmble () { - // Make sure both arrays have same count (this however should always be TRUE) - assert(count($this->finalPackageChunks['hashes']) == count($this->finalPackageChunks['content'])); - //* DIE: */ exit(__METHOD__ . ':finalPackageChunks='.print_r($this->finalPackageChunks['content'], TRUE)); - - /* - * Remove last element (hash chunk) from 'hashes'. This hash will never - * be needed, so ignore it. - */ - array_pop($this->finalPackageChunks['hashes']); - - // ... and from 'content' as well but save it for later use - $this->chunkHashes = explode(PackageFragmenter::CHUNK_HASH_SEPARATOR, substr(array_pop($this->finalPackageChunks['content']), strlen(PackageFragmenter::HASH_CHUNK_IDENTIFIER))); - - // Remove EOP chunk and keep a copy of it - array_pop($this->finalPackageChunks['hashes']); - $this->eopChunk = explode(PackageFragmenter::CHUNK_HASH_SEPARATOR, substr(array_pop($this->finalPackageChunks['content']), strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER))); - - // Verify all serial numbers - $this->verifyChunkSerialNumbers(); - } - - /** - * Verifies all chunk serial numbers by using a freshly initialized - * fragmenter instance. Do ALWAYS sort the array and array_pop() the hash - * chunk before calling this method to avoid re-requests of many chunks. - * - * @return void - */ - private function verifyChunkSerialNumbers () { - // Debug message - //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE)); - - // Get final hash - $finalHash = $this->generateFinalHash(implode('', $this->finalPackageChunks['content'])); - - // Reset the serial number generator - $this->fragmenterInstance->resetSerialNumber($finalHash); - - // "Walk" through all (content) chunks - foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) { - // Get next serial number - $nextSerial = $this->fragmenterInstance->getNextHexSerialNumber($finalHash); - - // Debug output - //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial); - - // Is it not the same? Then re-request it - if ($serialNumber != $nextSerial) { - // This is invalid, so remove it - unset($this->finalPackageChunks['content'][$serialNumber]); - unset($this->finalPackageChunks['hashes'][$serialNumber]); - - // And re-request it with valid serial number (and hash chunk) - $this->rerequestChunkBySerialNumber($nextSerial); - } // END - if - } // END - foreach - } - - /** - * Assembles and verifies ("final check") chunks back together to the - * original package (raw data for the start). This method should only be - * called AFTER the EOP and final-chunk chunk have been removed. - * - * @return void - */ - private function assembleAllChunksToPackage () { - // If chunkHashes is not filled, don't continue - assert(count($this->chunkHashes) > 0); - - // Init raw package data string - $this->rawPackageData = ''; - - // That went well, so start assembling all chunks - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Handling ' . count($this->finalPackageChunks['content']) . ' entries ...'); - foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) { - // Assert on 'hash' entry (must always be set) - assert(isset($this->finalPackageChunks['hashes'][$serialNumber])); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $serialNumber . ',hashes=' . $this->finalPackageChunks['hashes'][$serialNumber] . ' - validating ...'); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE) . 'chunkHashes=' . print_r($this->chunkHashes, TRUE)); - - // Is this chunk valid? This should be the case - assert($this->isChunkHashValid(array( - self::CHUNK_SPLITS_INDEX_HASH => $this->finalPackageChunks['hashes'][$serialNumber], - self::CHUNK_SPLITS_INDEX_RAW_DATA => $content - ))); - - // ... and is also in the hash chunk? - assert(in_array($this->finalPackageChunks['hashes'][$serialNumber], $this->chunkHashes)); - - // Verification okay, add it to the raw data - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($content) . ' bytes as raw package data ...'); - $this->rawPackageData .= $content; - } // END - foreach - - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: eopChunk[1]=' . $this->eopChunk[1] . ',index=' . (count($this->chunkHashes) - 2) . ',chunkHashes='.print_r($this->chunkHashes, TRUE)); - - // The last chunk hash must match with the one from eopChunk[1] - assert($this->eopChunk[1] == $this->chunkHashes[count($this->chunkHashes) - 2]); - } - - /** - * Generate final hash if EOP chunk is found, else an assert will happen. - * - * @param $rawPackageData Raw package data - * @return $finalHash Final hash if EOP chunk is found - */ - private function generateFinalHash ($rawPackageData) { - // Make sure the raw package data is given - assert((is_string($rawPackageData)) && (!empty($rawPackageData))); - - // Make sure the EOP chunk is set - assert((isset($this->eopChunk[0])) && (isset($this->eopChunk[1]))); - assert((is_string($this->eopChunk[0])) && (!empty($this->eopChunk[0]))); - - // Hash the raw data - $finalHash = $this->getCryptoInstance()->hashString($rawPackageData, $this->eopChunk[0], FALSE); - - // Return it - return $finalHash; - } - - /** - * Verifies the finally assembled raw package data by comparing it against - * the final hash. - * - * @return void - */ - private function verifyRawPackageData () { - // Generate final hash - $finalHash = $this->generateFinalHash($this->rawPackageData); - - // Is it the same? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: eopChunk[1]=' . $this->eopChunk[1] . ',finalHash=' . $finalHash); - assert($finalHash == $this->eopChunk[0]); - } - - /** - * Checks whether the final (last) chunk is valid - * - * @param $chunks An array with chunks and (hopefully) a valid final chunk - * @return $isValid Whether the final (last) chunk is valid - */ - private function isValidFinalChunk (array $chunks) { - // Default is all fine - $isValid = TRUE; - - // Split the (possible) EOP chunk - $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]); - - // Make sure chunks with only 3 elements are parsed (for details see ChunkHandler) - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE)); - assert(count($chunkSplits) == 3); - - // Validate final chunk - if (substr($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) { - // Not fine - $isValid = FALSE; - } elseif (substr_count($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) { - // CHUNK_HASH_SEPARATOR shall only be found once - $isValid = FALSE; - } - - // Return status - return $isValid; - } - - /** - * Adds all chunks if the last one verifies as a 'final chunk'. - * - * @param $chunks An array with chunks, the last one should be a 'final' - * @return void - * @throws FinalChunkVerificationException If the final chunk does not start with 'EOP:' - */ - public function addAllChunksWithFinal (array $chunks) { - // Try to validate the final chunk - try { - // Validate final chunk - $this->isValidFinalChunk($chunks); - } catch (AssertionException $e) { - // Last chunk is not valid - throw new FinalChunkVerificationException(array($this, $chunks, $e), BaseListener::EXCEPTION_FINAL_CHUNK_VERIFICATION); - } - - // Do we have some pending chunks (no final)? - while (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL)) { - // Then get it first and add it before the EOP chunks - array_unshift($chunks, $this->getStackInstance()->popNamed(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL)); - } // END - while - - // Add all chunks to the FIFO stacker - foreach ($chunks as $chunk) { - // Add the chunk - $this->getStackInstance()->pushNamed(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, $chunk); - } // END - foreach - } - - /** - * Adds all chunks and wait for more (e.g. incomplete transmission) - * - * @param $chunks An array with chunks, the last one should be a 'final' - * @return void - */ - public function addAllChunksWait (array $chunks) { - // Add all chunks to the FIFO stacker - foreach ($chunks as $chunk) { - // Add the chunk - $this->getStackInstance()->pushNamed(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL, $chunk); - } // END - foreach - } - - /** - * Checks whether unhandled chunks are available - * - * @return $unhandledChunks Whether unhandled chunks are left - */ - public function ifUnhandledChunksWithFinalAvailable () { - // Simply check if the stacker is not empty - $unhandledChunks = $this->getStackInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP) === FALSE; - - // Return result - return $unhandledChunks; - } - - /** - * Handles available chunks by processing one-by-one (not all together, - * this would slow-down the whole application) with the help of an - * iterator. - * - * @return void - */ - public function handleAvailableChunksWithFinal () { - // First check if there are undhandled chunks available - assert($this->ifUnhandledChunksWithFinalAvailable()); - - // Get an entry from the stacker - $chunk = $this->getStackInstance()->popNamed(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP); - - // Split the string with proper separator character - $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunk); - - /* - * Make sure three elements are always found: - * 0 = Hash - * 1 = Serial number - * 2 = Raw data - */ - assert(count($chunkSplits) == 3); - - // Is the generated hash from data same ("valid") as given hash? - if (!$this->isChunkHashValid($chunkSplits)) { - // Do some logging - self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Chunk content is not validating against given hash.'); - - // Re-request this chunk (trust the hash in index # 0) - $this->rerequestChunkBySplitsArray($chunkSplits); - - // Don't process this chunk - return; - } // END - if - - // Is the serial number valid (chars 0-9, length equals PackageFragmenter::MAX_SERIAL_LENGTH)? - if (!$this->isSerialNumberValid($chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL])) { - // Do some logging - self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Chunk serial number ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ' for hash ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ' is invalid.'); - - // Re-request this chunk - $this->rerequestChunkBySplitsArray($chunkSplits); - - // Don't process this chunk - return; - } // END - if - - /* - * It is now known that (as long as the hash algorithm has no - * collisions) the content is the same as the sender sends it to this - * peer. - * - * And also the serial number is valid (basicly) at this point. Now the - * chunk can be added to the final array. - */ - $this->addChunkToFinalArray($chunkSplits); - - // Is the stack now empty? - if ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP)) { - // Then mark the final array as complete - $this->markFinalArrayAsCompleted(); - } // END - if - } - - /** - * Checks whether unassembled chunks are available (ready) in final array - * - * @return $unassembledChunksAvailable Whether unassembled chunks are available - */ - public function ifUnassembledChunksAvailable () { - // For now do only check the array element 'is_complete' - $unassembledChunksAvailable = ($this->finalPackageChunks['is_complete'] === TRUE); - - // Return status - return $unassembledChunksAvailable; - } - - /** - * Assembles all chunks (except EOP and "hash chunk") back together to the original package data. - * - * This is done by the following steps: - * - * 1) Sort the final array with ksort(). This will bring the "hash - * chunk" up to the last array index and the EOP chunk to the - * pre-last array index - * 2) Assemble all chunks except two last (see above step) - * 3) While so, do the final check on all hashes - * 4) If the package is assembled back together, hash it again for - * the very final verification. - * - * @return void - */ - public function assembleChunksFromFinalArray () { - // Make sure the final array is really completed - assert($this->ifUnassembledChunksAvailable()); - - // Count up stepping - $this->finalPackageChunks['assemble_steps']++; - - // Do the next step - switch ($this->finalPackageChunks['assemble_steps']) { - case 1: // Sort the chunks array (the serial number shall act as a sorting key) - $this->sortChunksArray(); - break; - - case 2: // Prepare the assemble by removing last two indexes - $this->preparePackageAssmble(); - break; - - case 3: // Assemble all chunks back together to the original package - $this->assembleAllChunksToPackage(); - break; - - case 4: // Verify the raw data by hashing it again - $this->verifyRawPackageData(); - break; - - case 5: // Re-initialize handler to reset it to the old state - $this->initHandler(); - break; - - default: // Invalid step found - self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Invalid step ' . $this->finalPackageChunks['assemble_steps'] . ' detected.'); - break; - } // END - switch - } - - /** - * Checks whether the raw package data has been assembled back together. - * This can be safely assumed when rawPackageData is not empty and the - * collection of all chunks is FALSE (because initHandler() will reset it). - * - * @return $isRawPackageDataAvailable Whether raw package data is available - */ - public function ifRawPackageDataIsAvailable () { - // Check it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: this->rawPackageData()=' . strlen($this->rawPackageData) . ',ifUnassembledChunksAvailable()=' . intval($this->ifUnassembledChunksAvailable())); - $isRawPackageDataAvailable = ((!empty($this->rawPackageData)) && (!$this->ifUnassembledChunksAvailable())); - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: isRawPackageDataAvailable=' . intval($isRawPackageDataAvailable)); - return $isRawPackageDataAvailable; - } - - /** - * Handles the finally assembled raw package data by feeding it into another - * stacker for further decoding/processing. - * - * @return void - */ - public function handledAssembledRawPackageData () { - // Assert to make sure that there is raw package data available - assert($this->ifRawPackageDataIsAvailable()); - - // Then feed it into the next stacker - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($this->rawPackageData) . ' bytes to stack ' . self::STACKER_NAME_ASSEMBLED_RAW_DATA . ' ...'); - $this->getStackInstance()->pushNamed(self::STACKER_NAME_ASSEMBLED_RAW_DATA, $this->rawPackageData); - - // ... and reset it - $this->rawPackageData = ''; - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/class_ b/application/hub/main/handler/class_ deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/handler/class_ +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/handler/class_BaseDataHandler.php b/application/hub/main/handler/class_BaseDataHandler.php deleted file mode 100644 index 7b6b1d7d5..000000000 --- a/application/hub/main/handler/class_BaseDataHandler.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseDataHandler extends BaseHandler { - /** - * Last exception instance from database layer or NULL (default) - */ - private $lastException = NULL; - - /** - * Array with search criteria elements - */ - protected $searchData = array(); - - /** - * Array with all data XML nodes (which hold the actual data) and their values - */ - protected $messageDataElements = array(); - - /** - * Array for translating message data elements (other node's data mostly) - * into configuration elements. - */ - protected $messageToConfig = array(); - - /** - * Array for copying configuration entries - */ - protected $configCopy = array(); - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set it here - $this->setDhtInstance($dhtInstance); - } - - /** - * Getter for search data array - * - * @return $searchData Search data array - */ - public final function getSearchData () { - return $this->searchData; - } - - /** - * Getter for last exception - * - * @return $lastException Last thrown exception - */ - public final function getLastException () { - return $this->lastException; - } - - /** - * Setter for last exception - * - * @param $lastException Last thrown exception - * @return void - */ - public final function setLastException (FrameworkException $exceptionInstance = NULL) { - $this->lastException = $exceptionInstance; - } - - /** - * Prepares a message as answer for given message data for delivery. - * - * @param $messageData An array with all message data - * @param $packageInstance An instance of a Deliverable instance - * @return void - */ - protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to send an answer message for ' . $this->getHandlerName() . ' ...'); - - // Get a helper instance based on this handler's name - $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData)); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Load descriptor XML - $helperInstance->loadDescriptorXml($nodeInstance); - - /* - * Set missing (temporary) configuration data, mostly it needs to be - * copied from message data array. - */ - $this->initMessageConfigurationData($messageData); - - // Compile any configuration variables - $helperInstance->getTemplateInstance()->compileConfigInVariables(); - - // Deliver the package - $helperInstance->sendPackage($nodeInstance); - - /* - * Remove temporary configuration - */ - $this->removeMessageConfigurationData($messageData); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Answer message has been prepared.'); - } - - /** - * Prepares the next message - * - * @param $messageData An array with all message data - * @param $packageInstance An instance of a Deliverable instance - * @return void - */ - protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to send next message ...'); - - // Get a helper instance based on this handler's name - $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData)); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Load descriptor XML - $helperInstance->loadDescriptorXml($nodeInstance); - - /* - * Set missing (temporary) configuration data, mostly it needs to be - * copied from message data array. - */ - $this->initMessageConfigurationData($messageData); - - // Compile any configuration variables - $helperInstance->getTemplateInstance()->compileConfigInVariables(); - - // Deliver the package - $helperInstance->sendPackage($nodeInstance); - - /* - * Remove temporary configuration - */ - $this->removeMessageConfigurationData($messageData); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Next message has been prepared.'); - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - */ - abstract protected function initMessageConfigurationData (array $messageData); - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - */ - abstract protected function removeMessageConfigurationData (array $messageData); -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/.htaccess b/application/hub/main/handler/message-types/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/message-types/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/message-types/announcement/.htaccess b/application/hub/main/handler/message-types/announcement/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/message-types/announcement/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php deleted file mode 100644 index 6e4b50300..000000000 --- a/application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessageAnnouncementHandler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_announcement'); - - // Init message data array - $this->messageDataElements = array( - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS, - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE, - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID, - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, - ); - - // Init message-data->configuration translation array - $this->messageToConfig = array( - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID => 'your_node_id', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash', - ); - - // Init config-copy array - $this->configCopy = array( - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash', - ); - - // Init array - $this->searchData = array( - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS - ); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessageAnnouncementHandler () { - // Get new instance - $handlerInstance = new NodeMessageAnnouncementHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws AnnouncementNotAcceptedException If this node does not accept announcements - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Is this node accepting announcements? - if (!$nodeInstance->isAcceptingAnnouncements()) { - /* - * This node is not accepting announcements, then someone wants to - * announce his node to a non-bootstrap and non-master node. - */ - throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageData), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED); - } // END - if - - // Register the announcing node with this node - $this->registerNodeByMessageData($messageData); - - // Prepare answer message to be delivered back to the other node - $this->prepareAnswerMessage($messageData, $packageInstance); - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); - - // Add all ements - foreach ($this->messageDataElements as $key) { - // Is it there? - assert(isset($messageData[$key])); - - // Add it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Adding messageData[' . $key . ']=' . $messageData[$key] . ' ...'); - $dataSetInstance->addCriteria($key, $messageData[$key]); - } // END - foreach - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - */ - protected function initMessageConfigurationData (array $messageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); - - // "Walk" throught the translation array - foreach ($this->messageToConfig as $messageKey => $configKey) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); - - // Set the element in configuration - $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]); - } // END - foreach - - // "Walk" throught the config-copy array - foreach ($this->configCopy as $targetKey => $sourceKey) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); - - // Copy from source to targetKey - $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); - } // END - foreach - - // Translate last exception into a status code - $statusCode = $this->getTranslatedStatusFromLastException(); - - // Set it in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); - } - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - */ - protected function removeMessageConfigurationData (array $messageData) { - // "Walk" throught the translation array again - foreach ($this->messageToConfig as $dummy => $configKey) { - // Now unset this configuration entry (to save some memory) - $this->getConfigInstance()->unsetConfigEntry($configKey); - } // END - foreach - - // "Walk" throught the config-copy array again - foreach ($this->configCopy as $configKey => $dummy) { - // Now unset this configuration entry (to save some memory again) - $this->getConfigInstance()->unsetConfigEntry($configKey); - } // END - foreach - - // Remove NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS as well - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/answer/.htaccess b/application/hub/main/handler/message-types/answer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/message-types/answer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php deleted file mode 100644 index eab9f542f..000000000 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_announcement_answer'); - - // Init message data array - $this->messageDataElements = array( - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, - BaseXmlAnswerTemplateEngine::ANSWER_STATUS, - ); - - // Init message-data->configuration translation array - $this->messageToConfig = array( - /* - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address', - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id' - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash' - */ - ); - - // Init config-copy array - $this->configCopy = array( - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address', - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status', - XmlAnnouncementAnswerTemplateEngine::OAANNOUNCEMENT_DATA_SESSION_ID => 'session_id', - XmlAnnouncementAnswerTemplateEngine::OAANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash', - ); - - // Init array - $this->searchData = array( - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - ); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessageAnnouncementAnswerHandler () { - // Get new instance - $handlerInstance = new NodeMessageAnnouncementAnswerHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws NoAnnouncementAttemptedException If this node has not attempted to announce itself - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Has this node attempted to announce itself? - if (!$nodeInstance->ifNodeIsAnnouncing()) { - /* - * This node has never announced itself, so it doesn't expect - * announcement answer messages. - */ - throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); - } // END - if - - // Register the announcing node with this node - $this->registerNodeByMessageData($messageData); - - // Handle the answer status element - $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance); - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); - - // Add all ements - foreach ($this->messageDataElements as $key) { - // Is it there? - assert(isset($messageData[$key])); - - /* - * Add it, but remove any 'my-' prefixes as they are not used in - * database layer. - */ - $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); - } // END - foreach - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function initMessageConfigurationData (array $messageData) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function removeMessageConfigurationData (array $messageData) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php deleted file mode 100644 index 85c9165e8..000000000 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_announcement_answer'); - - // Init message data array - $this->messageDataElements = array( - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS, - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, - BaseXmlAnswerTemplateEngine::ANSWER_STATUS, - ); - - // Init message-data->configuration translation array - $this->messageToConfig = array( - /* - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id' - */ - ); - - // Init config-copy array - $this->configCopy = array( - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address', - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address', - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status', - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id', - ); - - // Init array - $this->searchData = array( - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - ); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessageDhtBootstrapAnswerHandler () { - // Get new instance - $handlerInstance = new NodeMessageDhtBootstrapAnswerHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws NoDhtBootstrapAttemptedException If this DHT has not attempted to bootstrap - * @todo ~30% done - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Get DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Has this DHT attempted to bootstrap? - if (!$dhtInstance->ifDhtIsBooting()) { - /* - * This DHT has never bootstrapped, so it doesn't expect - * announcement answer messages. - */ - throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED); - } // END - if - - // Unfinished - $this->partialStub('UNHANDLED: messageData=' . print_r($messageData, TRUE)); - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); - - // Add all ements - foreach ($this->messageDataElements as $key) { - // Is it there? - assert(isset($messageData[$key])); - - /* - * Add it, but remove any 'my-' prefixes as they are not used in - * database layer. - */ - $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); - } // END - foreach - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function initMessageConfigurationData (array $messageData) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function removeMessageConfigurationData (array $messageData) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php deleted file mode 100644 index 058b9ce55..000000000 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_request_node_list_answer'); - - // Init message data array - $this->messageDataElements = array( - XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, - XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST, - BaseXmlAnswerTemplateEngine::ANSWER_STATUS, - ); - - // Init message-data->configuration translation array - $this->messageToConfig = array( - /* - XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID => 'your_session_id' - */ - ); - - // Init search data array - $this->searchData = array( - XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, - ); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessageRequestNodeListAnswerHandler () { - // Get new instance - $handlerInstance = new NodeMessageRequestNodeListAnswerHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws NoRequestNodeListAttemptedException If this node has not attempted to announce itself - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Has this node attempted to announce itself? - if (!$nodeInstance->ifNodeHasAnnouncementCompleted()) { - /* - * This node has never announced itself, so it doesn't expect - * request-node-list answer messages. - */ - throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); - } // END - if - - // Register the announcing node with this node - $this->registerNodeByMessageData($messageData); - - // Handle the answer status element - $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance); - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); - - // Add all ements - foreach ($this->messageDataElements as $key) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData[' . $key . ']=' . $messageData[$key]); - - // Is it there? - assert(isset($messageData[$key])); - - /* - * Add it, but remove any 'my-' prefixes as they are not used in - * database layer. - */ - $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); - } // END - foreach - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function initMessageConfigurationData (array $messageData) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function removeMessageConfigurationData (array $messageData) { - // Please don't call this method - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/class_ b/application/hub/main/handler/message-types/class_ deleted file mode 100644 index 4853fd41d..000000000 --- a/application/hub/main/handler/message-types/class_ +++ /dev/null @@ -1,115 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessage???Handler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_==='); - - // Init message data array - $this->messageDataElements = array( - Xml???TemplateEngine::!!!_DATA_EXTERNAL_ADDRESS, - Xml???TemplateEngine::!!!_DATA_NODE_STATUS, - Xml???TemplateEngine::!!!_DATA_SESSION_ID, - Xml???TemplateEngine::!!!_DATA_LISTEN_PORT, - ); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessage???Handler () { - // Get new instance - $handlerInstance = new NodeMessage???Handler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Register the announcing node with this node - $this->registerNodeByMessageData($messageData); - - // Prepare answer message to be delivered back to the other node - $this->prepareAnswerMessage($messageData, $packageInstance); - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add all ements - foreach ($this->messageDataElements as $key) { - // Is it there? - assert(isset($messageData[$key])); - - // Add it - $dataSetInstance->addCriteria($key, $messageData[$key]); - } // END - foreach - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - */ - protected function initMessageConfigurationData (array $messageData) { - $this->partialStub('Please implement this method.'); - } - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - */ - protected function removeMessageConfigurationData (array $messageData) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/class_BaseMessageHandler.php b/application/hub/main/handler/message-types/class_BaseMessageHandler.php deleted file mode 100644 index 936f0178a..000000000 --- a/application/hub/main/handler/message-types/class_BaseMessageHandler.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseMessageHandler extends BaseDataHandler { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * "Getter" for a translated last exception as a status code - * - * @return $statusCode Translated status code from last exception - */ - protected function getTranslatedStatusFromLastException () { - // Default is all fine - $statusCode = BaseHubSystem::MESSAGE_STATUS_CODE_OKAY; - - // Is the last exception not NULL? - if ($this->getLastException() instanceof FrameworkException) { - // "Determine" the right status code (may differ from exception to exception) - $this->debugInstance('lastException=' . $this->getLastException()->__toString() . ',message=' . $this->getLastException()->getMessage() . ' is not finished!'); - } // END - if - - // Return the status code - return $statusCode; - } - - /** - * Registers an other node with this node by given message data. The - * following data must always be present: - * - * - session-id (for finding the node's record together with below data) - * - external-address (hostname or IP number) - * - listen-port (TCP/UDP listen port for inbound connections) - * - * @param $messageArray An array with all minimum message data - * @return void - */ - protected function registerNodeByMessageData (array $messageData) { - // Check if searchData has entries - assert(count($this->getSearchData()) > 0); - - // Let the DHT facade do the work - $this->getDhtInstance()->registerNodeByMessageData($messageData, $this); - } - - /** - * Posty-handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function postHandleMessageData (array $messageData, Receivable $packageInstance) { - /* - * Feed hash to miner by handling over the whole array as also the - * sender and tags are needed. - */ - $packageInstance->feedHashToMiner($messageData); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/dht/.htaccess b/application/hub/main/handler/message-types/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/message-types/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php deleted file mode 100644 index 35b609e4c..000000000 --- a/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ /dev/null @@ -1,213 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_dht_bootstrap'); - - // Init message data array - $this->messageDataElements = array( - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS, - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE, - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, - ); - - // Init message-data->configuration translation array - $this->messageToConfig = array( - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address', - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id' - ); - - // Init config-copy array - $this->configCopy = array( - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address', - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address', - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status', - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id', - ); - - // Init array - $this->searchData = array( - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - ); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessageDhtBootstrapHandler () { - // Get new instance - $handlerInstance = new NodeMessageDhtBootstrapHandler(); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // ... and set it here - $handlerInstance->setNodeInstance($nodeInstance); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $handlerInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws DhtBootstrapNotAcceptedException If this node does not accept DHT bootstrap requests - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Is this node accepting DHT bootstrap requests? - if (!$this->getNodeInstance()->isAcceptingDhtBootstrap()) { - /* - * This node is not accepting DHT bootstrap requests. - */ - throw new DhtBootstrapNotAcceptedException(array($this, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED); - } // END - if - - // Register the DHT bootstrap requesting node with this node - $this->registerNodeByMessageData($messageData); - - // Prepare answer message to be delivered back to the other node - $this->prepareAnswerMessage($messageData, $packageInstance); - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); - - // Add all ements - foreach ($this->messageDataElements as $key) { - // Is it there? - assert(isset($messageData[$key])); - - // Add it - $dataSetInstance->addCriteria($key, $messageData[$key]); - } // END - foreach - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - */ - protected function initMessageConfigurationData (array $messageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-BOOTSTRAP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); - - // "Walk" throught the translation array - foreach ($this->messageToConfig as $messageKey => $configKey) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-BOOTSTRAP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); - - // Set the element in configuration - $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]); - } // END - foreach - - // "Walk" throught the config-copy array - foreach ($this->configCopy as $targetKey => $sourceKey) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-BOOTSTRAP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); - - // Copy from source to target key - $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); - } // END - foreach - - // Translate last exception into a status code - $statusCode = $this->getTranslatedStatusFromLastException(); - - // Set it in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); - - /* - * Use the DHT instance to get a list of recipients. This means that all - * DHT nodes that accept bootstrap requests are read from the DHT - * database. - */ - $nodeList = $this->getDhtInstance()->findRecipientsByKey(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y'); - - // Make sure it is an array and has at least one entry - assert(is_array($nodeList)); - assert(count($nodeList) > 0); - - // Set it in configuration - $this->getConfigInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList))); - } - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - */ - protected function removeMessageConfigurationData (array $messageData) { - // "Walk" throught the translation array again - foreach ($this->messageToConfig as $dummy => $configKey) { - // Now unset this configuration entry (to save some memory) - $this->getConfigInstance()->unsetConfigEntry($configKey); - } // END - foreach - - // "Walk" throught the config-copy array again - foreach ($this->configCopy as $configKey => $dummy) { - // Now unset this configuration entry (to save some memory again) - $this->getConfigInstance()->unsetConfigEntry($configKey); - } // END - foreach - - // Remove temporary "special" values as well - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); - $this->getConfigInstance()->unsetConfigEntry('dht_nodes'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/requests/.htaccess b/application/hub/main/handler/message-types/requests/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/message-types/requests/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php deleted file mode 100644 index 92cc25eac..000000000 --- a/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ /dev/null @@ -1,176 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_request_node_list'); - - // Init message data array - $this->messageDataElements = array( - XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, - ); - - // Init config-copy array - $this->configCopy = array( - ); - - // Init search data array - $this->searchData = array( - XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, - ); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessageRequestNodeListHandler () { - // Get new instance - $handlerInstance = new NodeMessageRequestNodeListHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - * @throws RequestNotAcceptedException If this node does not accept this request - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Is this node accepting announcements? - if (!$nodeInstance->isAcceptingNodeListRequests()) { - /* - * This node is not accepting node list requests. Throw an - * exception to abort any further processing. - */ - throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_REQUEST_NOT_ACCEPTED); - } // END - if - - // Register the announcing node with this node - $this->registerNodeByMessageData($messageData); - - // Prepare answer message to be delivered back to the other node - $this->prepareAnswerMessage($messageData, $packageInstance); - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); - - // Add all ements - foreach ($this->messageDataElements as $key) { - // Is it there? - assert(isset($messageData[$key])); - - // Add it - $dataSetInstance->addCriteria($key, $messageData[$key]); - } // END - foreach - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - */ - protected function initMessageConfigurationData (array $messageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); - - // "Walk" throught the config-copy array - foreach ($this->configCopy as $targetKey => $sourceKey) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...'); - - // Copy from source to targetKey - $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey)); - } // END - foreach - - // Query local DHT for nodes except given session id - $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData( - $messageData, - $this, - XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, - XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, - BaseHubNode::OBJECT_LIST_SEPARATOR - ); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.'); - - // Set it serialized in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList))); - - // Translate last exception into a status code - $statusCode = $this->getTranslatedStatusFromLastException(); - - // Set it in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode); - } - - /** - * Removes configuration data with given message data array from global - * configuration - * - * @param $messageData An array with all message data - * @return void - */ - protected function removeMessageConfigurationData (array $messageData) { - // "Walk" throught the config-copy array again - foreach ($this->configCopy as $configKey => $dummy) { - // Now unset this configuration entry (to save some memory again) - $this->getConfigInstance()->unsetConfigEntry($configKey); - } // END - foreach - - // Remove answer status/node list as well - $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS); - $this->getConfigInstance()->unsetConfigEntry('node_list'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/message-types/self-connect/.htaccess b/application/hub/main/handler/message-types/self-connect/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/message-types/self-connect/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php b/application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php deleted file mode 100644 index e1ac210a2..000000000 --- a/application/hub/main/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeMessageSelfConnectHandler extends BaseMessageHandler implements HandleableMessage, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('message_self_connect'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createNodeMessageSelfConnectHandler () { - // Get new instance - $handlerInstance = new NodeMessageSelfConnectHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Handles data array of the message - * - * @param $messageData An array with message data to handle - * @param $packageInstance An instance of a Receivable class - * @return void - */ - public function handleMessageData (array $messageData, Receivable $packageInstance) { - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Are node id and session id the same? - if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $nodeInstance->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $nodeInstance->getSessionId())) { - // Both are equal - self::createDebugInstance(__CLASS__)->debugOutput('SELF-CONNECT[' . __METHOD__ . ':' . __LINE__ . ']: Have connected to myself, both node and session id are equal!'); - - // ... and change state - $nodeInstance->getStateInstance()->nodeHasSelfConnected(); - } else { - // Something really horrible happened - // @TODO Throw an exception here instead of dying - $this->debugInstance(__METHOD__ . ': ids mismatching! messageData=' . print_r($messageData, TRUE)); - } - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); - - // Please don't call this method! - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Initializes configuration data from given message data array - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function initMessageConfigurationData (array $messageData) { - // Please don't call this method! - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Removes configuration data with given message data array from global configuration - * - * @param $messageData An array with all message data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - protected function removeMessageConfigurationData (array $messageData) { - // Please don't call this method! - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/network/.htaccess b/application/hub/main/handler/network/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/network/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/network/class_ b/application/hub/main/handler/network/class_ deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/handler/network/class_ +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/handler/network/class_BaseRawDataHandler.php b/application/hub/main/handler/network/class_BaseRawDataHandler.php deleted file mode 100644 index 6c4b37936..000000000 --- a/application/hub/main/handler/network/class_BaseRawDataHandler.php +++ /dev/null @@ -1,182 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseRawDataHandler extends BaseHandler { - // Error codes: - // - Socket raw data stream errors - const SOCKET_ERROR_UNKNOWN = 'unknown_error'; // Unknown error (should not happen) - const SOCKET_ERROR_TRANSPORT_ENDPOINT = 'transport_endpoint'; // Transport endpoint has closed - const SOCKET_ERROR_INVALID_BASE64_MODULO = 'base64_modulo'; // Length is not modulo 4 - const SOCKET_ERROR_INVALID_BASE64_MESSAGE = 'base64_message'; // Raw data is not Base64-encoded - const SOCKET_ERROR_UNHANDLED = 'unhandled_package'; // Unhandled raw data (not bad) - const SOCKET_ERROR_CONNECTION_REFUSED = 'connection_refused'; // The name says it: connection refused - const SOCKET_ERROR_CONNECTION_TIMED_OUT = 'connection_timed_out'; // The name says it: connection attempt has timed-out - const SOCKET_ERROR_OPERATION_IN_PROGRESS = 'operation_in_progress'; // 'Operation now in progress' - const SOCKET_ERROR_OPERATION_ALREADY_PROGRESS = 'operation_already_progress'; // 'Operation already in progress' - const SOCKET_ERROR_RESOURCE_UNAVAILABLE = 'resource_unavailable'; // 'Resource temporary unavailable' - const SOCKET_ERROR_NO_ROUTE_TO_HOST = 'no_route_to_host'; // The name says it: no route to host - const SOCKET_ERROR_CONNECTION_RESET_BY_PEER = 'connection_reset_by_peer'; // Connection reset by peer - const SOCKET_ERROR_BROKEN_PIPE = 'broken_pipe'; // Broken pipe - const SOCKET_CONNECTED = 'connected'; // Nothing errorous happens, socket is connected - - // - Package errors - const PACKAGE_ERROR_INVALID_DATA = 'invalid_data'; // Invalid data in package found - const PACKAGE_ERROR_INCOMPLETE_DATA = 'incomplete_data'; // Incomplete data sent (e.g. field is missing) - const PACKAGE_ERROR_INVALID_CONTENT = 'invalid_content'; // Content is invalid (e.g. not well-formed) - const PACKAGE_ERROR_RECIPIENT_MISMATCH = 'recipient_error'; // Recipient is not us - const PACKAGE_LEVEL_CHECK_OKAY = 'checked_package'; // Package is fine - - // Package data - const PACKAGE_RAW_DATA = 'raw_data'; - const PACKAGE_ERROR_CODE = 'error_code'; - - // Start/end marker - const STREAM_START_MARKER = '[[S]]'; - const STREAM_END_MARKER = '[[E]]'; - - /** - * Stacker for raw data - */ - const STACKER_NAME_RAW_DATA = 'raw_data'; - - /** - * Error code from socket - */ - private $errorCode = -1; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Set error code to 'unknown' - $this->setErrorCode(self::SOCKET_ERROR_UNKNOWN); - - // Init stacker instance for processed raw data - $stackInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_stacker_class'); - - // Remember this in this package handler - $this->setStackInstance($stackInstance); - - // Init stacker - $this->initStack(); - } - - /** - * Initializes the stacker for raw data - * - * @return void - */ - protected function initStack () { - $this->getStackInstance()->initStack(self::STACKER_NAME_RAW_DATA); - } - - /** - * Adds given raw data to the raw data stacker - * - * @param $rawData raw data from the socket resource - * @return void - */ - protected function addRawDataToStacker ($rawData) { - /* - * Add the deocoded data and error code to the stacker so other classes - * (e.g. NetworkPackage) can "pop" it from the stacker. - */ - $this->getStackInstance()->pushNamed(self::STACKER_NAME_RAW_DATA, array( - self::PACKAGE_RAW_DATA => $rawData, - self::PACKAGE_ERROR_CODE => $this->getErrorCode() - )); - } - - /** - * Checks whether raw data is pending for further processing. - * - * @return $isPending Whether raw data is pending - */ - public function isRawDataPending () { - // Does the stacker have some entries (not empty)? - $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA)); - - // Return it - return $isPending; - } - - /** - * "Getter" for next raw data from the stacker - * - * @return $rawData Raw data from the stacker - */ - public function getNextRawData () { - // "Pop" the raw data from the stacker - $rawData = $this->getStackInstance()->popNamed(self::STACKER_NAME_RAW_DATA); - - // And return it - return $rawData; - } - - /** - * Checks whether the 'recipient' field matches our own an universal node - * locator. - * - * @param $packageData Raw package data - * @return $matches Whether it matches - * @todo This method will be moved to a better place - */ - protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) { - // Construct own address first - $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator(); - - // Does it match? - $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); - - // Return result - return $matches; - } - - /** - * Setter for error code - * - * @param $errorCode The error code we shall set - * @return void - */ - public final function setErrorCode ($errorCode) { - $this->errorCode = $errorCode; - } - - /** - * Getter for error code - * - * @return $errorCode The error code - */ - public final function getErrorCode () { - return $this->errorCode; - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/network/tcp/.htaccess b/application/hub/main/handler/network/tcp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/network/tcp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/network/tcp/class_ b/application/hub/main/handler/network/tcp/class_ deleted file mode 100644 index 96b146f9f..000000000 --- a/application/hub/main/handler/network/tcp/class_ +++ /dev/null @@ -1,208 +0,0 @@ -while (count($clients) > 0) { - // create a copy, so $clients doesn't get modified by socket_select() - $read = $clients; - - // get a list of all the clients that have data to be read from - // if there are no clients with data, go to next iteration - $left = @socket_select($read, $write = null, $except = null, 0, 150); - if ($left < 1) { - continue; - } - - // check if there is a client trying to connect - if (in_array($mainSocket, $read)) { - // accept the client, and add him to the $clients array - $new_sock = socket_accept($mainSocket); - $clients[] = $new_sock; - - // send the client a welcome message - socket_write($new_sock, "No noobs, but I'll make an exception. :)\n". - "There are ".(count($clients) - 1)." client(s) connected to the server.\n"); - - socket_getpeername($new_sock, $ip); - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}"); - - // Notify all chatter - if (count($clients) > 2) { - foreach ($clients as $send_sock) { - if ($send_sock != $mainSocket && $send_sock != $new_sock) { - socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n"); - } - } - } - - // remove the listening socket from the clients-with-data array - $key = array_search($mainSocket, $read); - unset($read[$key]); - } - - // loop through all the clients that have data to read from - foreach ($read as $read_sock) { - // Get client data - socket_getpeername($read_sock, $ip); - - // read until newline or 1024 bytes - // socket_read while show errors when the client is disconnected, so silence the error messages - $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ); - - // check if the client is disconnected - if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) { - - // remove client for $clients array - $key = array_search($read_sock, $clients); - unset($clients[$key]); - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1).""); - - // Notify all chatter - if (count($clients) > 1) { - foreach ($clients as $send_sock) { - if ($send_sock != $mainSocket) { - socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n"); - } - } - } - - // continue to the next client to read from, if any - socket_write($read_sock, "Server: Good bye.\n"); - socket_shutdown($read_sock, 2); - socket_close($read_sock); - continue; - } elseif (in_array(trim($data), $shutdown)) { - // Is he allowed to shutdown? - if (!in_array($ip, $masters)) { - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!"); - socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n"); - $data = ""; - continue; - } - - // Close all connections a leave here - foreach ($clients as $client) { - // Send message to client - if ($client !== $mainSocket && $client != $read_sock) { - socket_write($client, "Server: Shutting down! Thank you for joining us.\n"); - } - - // Quit him - socket_shutdown($client, 2); - socket_close($client); - } // end foreach - - // Leave the loop - $data = ""; - $clients = array(); - continue; - } - - // trim off the trailing/beginning white spaces - $data = trim($data); - - // Test for HTML codes - $tags = strip_tags($data); - - // check if there is any data after trimming off the spaces - if (!empty($data) && $tags == $data && count($clients) > 2) { - // Send confirmation to "chatter" - socket_write($read_sock, "\nServer: Message accepted.\n"); - - // send this to all the clients in the $clients array (except the first one, which is a listening socket) - foreach ($clients as $send_sock) { - - // if its the listening sock or the client that we got the message from, go to the next one in the list - if ($send_sock == $mainSocket || $send_sock == $read_sock) - continue; - - // write the message to the client -- add a newline character to the end of the message - socket_write($send_sock, "{$ip}:{$data}\n"); - - } // end of broadcast foreach - } elseif ($tags != $data) { - // HTML codes are not allowed - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!"); - socket_write($read_sock, "Server: HTML is forbidden!\n"); - } elseif ((count($clients) == 2) && ($read_sock != $mainSocket)) { - // No one else will hear the "chatter" - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself."); - socket_write($read_sock, "Server: No one will hear you!\n"); - } - } // end of reading foreach -} - -// close the listening socket -socket_close($mainSocket); - -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Listener extends BaseListener implements Listenable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance A NodeHelper instance - * @return $listenerInstance An instance a prepared listener class - */ - public final static function create???Listener (NodeHelper $nodeInstance) { - // Get new instance - $listenerInstance = new ???Listener(); - - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - * @todo 0% done - */ - public function initListener() { - $this->partialStub('Need to implement this method.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - * @todo 0% done - */ - public function doListen() { - $this->partialStub('Need to implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php deleted file mode 100644 index 1c8532a4b..000000000 --- a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { - /** - * Last socket error (default: Success) - */ - private $lastSocketError = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('tcp'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a Networkable class - */ - public static final function createTcpRawDataHandler () { - // Get new instance - $handlerInstance = new TcpRawDataHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Processes raw data from given resource. This is mostly useful for TCP - * package handling and is implemented in the TcpListener class - * - * @param $resource A valid socket resource array - * @return void - */ - public function processRawDataFromResource (array $socketArray) { - // Check the resource - if ((!isset($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])) || (!is_resource($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]))) { - // Throw an exception - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } // END - if - - // Reset error code to unhandled - $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError)); - - /* - * Read the raw data from socket. If you change PHP_BINARY_READ to - * PHP_NORMAL_READ, this line will endless block. This script does only - * provide simultanous threads, not real. - */ - $rawData = socket_read($socketArray[BasePool::SOCKET_ARRAY_RESOURCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); - - // Get socket error code back - $this->lastSocketError = socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); - - // Debug output of read data length - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror($this->lastSocketError)); - //* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: rawData=' . $rawData); - - // Is it valid? - if ($this->lastSocketError == 11) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); - - /* - * Error code 11 (Resource temporary unavailable) can be safely - * ignored on non-blocking sockets. The socket is currently not - * sending any data. - */ - socket_clear_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); - - // Skip any further processing - return; - } elseif (($rawData === FALSE) || ($this->lastSocketError > 0)) { - // Network error or connection lost - $this->setErrorCode($this->lastSocketError); - } elseif (empty($rawData)) { - // The peer did send nothing to us which is now being ignored - return; - } else { - /* - * All is fine at this point. So it is okay to add the raw data to - * the stacker. Here it doesn't matter if the raw data is a - * well-formed BASE64-encoded message with start and markers. This - * will be checked later on. - */ - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($rawData) . ' bytes to stacker ...'); - $this->addRawDataToStacker($rawData); - } - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/network/udp/.htaccess b/application/hub/main/handler/network/udp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/network/udp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/network/udp/class_UdpRawDataHandler.php b/application/hub/main/handler/network/udp/class_UdpRawDataHandler.php deleted file mode 100644 index a0d4cc132..000000000 --- a/application/hub/main/handler/network/udp/class_UdpRawDataHandler.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UdpRawDataHandler extends BaseRawDataHandler implements Networkable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('udp'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a Networkable class - */ - public static final function createUdpRawDataHandler () { - // Get new instance - $handlerInstance = new UdpRawDataHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Processes raw data from given resource. This is mostly useful for UDP - * package handling and is implemented in the UdpListener class - * - * @param $socketArray A valid socket resource array - * @return void - * @throws InvalidResourceException If the given resource is invalid - * @todo 0% - */ - public function processRawDataFromResource (array $socketArray) { - // Check the resource - if ((!isset($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])) || (!is_resource($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]))) { - // Throw an exception - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } // END - if - - // Implement processing here - $this->partialStub('Please implement this method. resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRRAY_CONN_TYPE]); - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/protocol/.htaccess b/application/hub/main/handler/protocol/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/protocol/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/protocol/class_ b/application/hub/main/handler/protocol/class_ deleted file mode 100644 index 665316593..000000000 --- a/application/hub/main/handler/protocol/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???ProtocolHandler extends BaseProtocolHandler implements HandleableProtocol, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('|||_protocol'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function create???ProtocolHandler () { - // Get new instance - $handlerInstance = new ???ProtocolHandler(); - - // Return the prepared instance - return $handlerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/protocol/class_BaseProtocolHandler.php b/application/hub/main/handler/protocol/class_BaseProtocolHandler.php deleted file mode 100644 index cf085db57..000000000 --- a/application/hub/main/handler/protocol/class_BaseProtocolHandler.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseProtocolHandler extends BaseHandler { - /** - * Whole UNL data array - */ - private $universalNodeLocatorData = array(); - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for UNL data array to satify HandleableProtocol - * - * @para $unlData The UNL data array - * @return void - */ - protected final function setUniversalNodeLocatorData (array $unlData) { - // Set new UNL data array - $this->universalNodeLocatorData = $unlData; - } - - /** - * Getter for UNL data array to satify HandleableProtocol - * - * @return $unlData The UNL data array - */ - public final function getUniversalNodeLocatorDataArray () { - // Return UNL data array - return $this->universalNodeLocatorData; - } - - /** - * Validates given UNL very basicly by given regular expression. You - * normally don't need/want to overwrite this method as this is a very basic - * validation only based on a regex. - * - * @param $unl Universal Node Locator to validate - * @return $isValid Whether the UNL is valid - */ - protected final function isValidUniversalNodeLocator ($unl) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',regex=' . $regex . ' - CALLED!'); - - // Very basic regex check - $isValid = (preg_match($this->getRegularExpression(), $unl) === 1); - - // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: isValid=' . intval($isValid) . ' - EXIT!'); - return $isValid; - } - - /** - * Parses the given UNL by splitting it up in its components. The UNL ... - * - * protocol://address[:port] - * - * ... becomes: - * - * array( - * 'protocol' => 'value', - * 'address' => 'value', - * 'extra' => 'port' - * ) - * - * The value for 'extra' then must be handled by parseUniversalNodeLocator() - * of the individual protocol handler as this is protocol-specific. - * - * @param $unl Universal Node Locator (UNL) to "parse" - * @return $unlData Array with all components of the UNL - */ - protected function parseGenericUniversalNodeLocator ($unl) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ' - CALLED!'); - - // Make sure the UNL is valid - assert($this->isValidUniversalNodeLocator($unl)); - - /* - * "Parse" the UNL "generically", sadly this cannot be done by using preg_match() :-( - * @TODO If you know why, please fix and explain it to me. - */ - $unlParts = explode('://', $unl); - - // Split again the last part as: address:port - $unlParts[1] = explode(':', $unlParts[1]); - - // Now there is an almost useable array which then can be copied to the "real" array. - $unlData = array( - UniversalNodeLocator::UNL_PART_PROTOCOL => $unlParts[0], - UniversalNodeLocator::UNL_PART_ADDRESS => $unlParts[1][0], - UniversalNodeLocator::UNL_PART_EXTRA => $unlParts[1][1] - ); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unlData=' . print_r($unlData, TRUE) . ' - EXIT!'); - - // Return the generic array - return $unlData; - } - - /** - * Gets an element from universalNodeLocatorData array - * - * @param $element Element in universalNodeLocatorData array - * @return $value Found value - */ - protected final function getUniversalNodeLocatorDataElement ($element) { - // Is the element there? - assert(isset($this->universalNodeLocatorData[$element])); - - // Return it - return $this->universalNodeLocatorData[$element]; - } - - /** - * "Getter" for currently saved UNL - * - * @return $unl Currently saved Universal Node Locator - */ - public final function getCurrentUniversalNodeLocator () { - // Construct generic UNL - $unl = sprintf('%s://%s', - $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_PROTOCOL), - $this->getAddressPart() - ); - - // Return it - return $unl; - } - - /** - * Default implementation for returning address part, may not be suitable - * for IPv4/IPv6 protocol handlers. So you have to overwrite (NOT CHANGE!) this method. - * - * @return $address Address part for the final UNL - */ - public function getAddressPart () { - // Return it - return $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_ADDRESS); - } - - /** - * If the found UNL (address) matches own external or internal address - * - * @param $unl UNL to test - * @return $ifMatches Whether the found UNL matches own addresss - */ - public function isOwnAddress ($unl) { - // Get own external UNL - $externalUnl = HubTools::determineOwnExternalAddress(); - - // Get internal UNL - $internalUnl = HubTools::determineOwnInternalAddress(); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',externalUnl=' . $externalUnl . ',internalUnl=' . $internalUnl); - //* DIE-DEBUG: */ die(__METHOD__.':unl=' . $unl . ',this='.print_r($this, TRUE)); - - // Is it the same? - $ifMatches = (($unl === $externalUnl) || ($unl === $internalUnl)); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: ifMatches=' . intval($ifMatches)); - - // Return result - return $ifMatches; - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/protocol/ipv4/.htaccess b/application/hub/main/handler/protocol/ipv4/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/protocol/ipv4/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/protocol/ipv4/class_ b/application/hub/main/handler/protocol/ipv4/class_ deleted file mode 100644 index 665316593..000000000 --- a/application/hub/main/handler/protocol/ipv4/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???ProtocolHandler extends BaseProtocolHandler implements HandleableProtocol, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('|||_protocol'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function create???ProtocolHandler () { - // Get new instance - $handlerInstance = new ???ProtocolHandler(); - - // Return the prepared instance - return $handlerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php b/application/hub/main/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php deleted file mode 100644 index 686f00685..000000000 --- a/application/hub/main/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php +++ /dev/null @@ -1,176 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseIpV4ProtocolHandler extends BaseProtocolHandler { - // Regular expression for validating IP:port UNLs - const UNL_REGEX = '/^([a-z]{1,}):\/\/\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b:(6553[0-5]|655[0-2][0-9]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$/'; - - /** - * Port number - */ - private $port = 0; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Set regex - $this->setRegularExpression(self::UNL_REGEX); - } - - /** - * Setter for port number to satify HandleableProtocol - * - * @para $port The port number - * @return void - */ - protected final function setPort ($port) { - // Set new port number - $this->port = $port; - } - - /** - * Getter for port number to satify HandleableProtocol - * - * @return $port The port number - */ - public final function getPort () { - // Return port number - return $this->port; - } - - /** - * Parses the given UNL by splitting it up in its components. The UNL ... - * - * protocol://address[:port] - * - * ... becomes: - * - * array( - * 'protocol' => 'value', - * 'address' => 'value', - * 'port' => 123 - * ) - * - * @param $unl Universal Node Locator (UNL) to "parse" - * @return $unlData Array with all components of the UNL - */ - protected function parseUniversalNodeLocator ($unl) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ' - CALLED!'); - - // First generic parse - $unlData = parent::parseGenericUniversalNodeLocator($unl); - - /* - * Make sure the generic parts are all there. In case of a rewrite, - * these assertitions will bail out on badly formed arrays. - */ - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_EXTRA])); - - // Copy 'extra' -> 'port' ... - $unlData[UniversalNodeLocator::UNL_PART_PORT] = $unlData[UniversalNodeLocator::UNL_PART_EXTRA]; - - // ... and drop 'extra' - unset($unlData[UniversalNodeLocator::UNL_PART_EXTRA]); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unlData=' . print_r($unlData, TRUE) . ' - EXIT!'); - return $unlData; - } - - /** - * Validates given 'recipient' if it is a valid UNL. This means that the UNL - * can be parsed by the protocol handler. - * - * @param $packageData Valid raw package data - * @return $isValid Whether the UNL can be validated - */ - public function isValidUniversalNodeLocatorByPackageData (array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Is 'recipient' there? - assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); - - // Is the correct handler choosen? - assert(substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($this->getHandlerName())) != $this->getHandlerName()); - - // Default is from generic validation - $isValid = $this->isValidUniversalNodeLocator($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: PACKAGE_DATA_RECIPIENT=' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ',isValid[' . gettype($isValid) . ']=' . intval($isValid)); - - // If this doesn't fail, continue validating the IP:port combination - if ($isValid === TRUE) { - // ... and validate IP:port, first "parse" the UNL - $unlData = $this->parseUniversalNodeLocator($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); - - /* - * Make sure the extra field 'port' is there. This may look - * superflious but in case of a rewrite this assert will stop at - * badly formated arrays. - */ - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); - - // Set whole UNL data array - $this->setUniversalNodeLocatorData($unlData); - - // Set port - $this->setPort($unlData[UniversalNodeLocator::UNL_PART_PORT]); - } // END - if - - // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: isValid=' . intval($isValid) . ' - EXIT!'); - return $isValid; - } - - /** - * This implementation uses it's parent method and combines it with the - * port part to construct a valid address:port combination. - * - * @return $address Address part for the final UNL - */ - public function getAddressPart () { - // Construct address - $address = sprintf('%s:%s', - parent::getAddressPart(), - $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_PORT) - ); - - // Return it - return $address; - } -} - -// [EOF] -?> diff --git a/application/hub/main/handler/protocol/ipv4/tcp/.htaccess b/application/hub/main/handler/protocol/ipv4/tcp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/handler/protocol/ipv4/tcp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php b/application/hub/main/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php deleted file mode 100644 index 586199681..000000000 --- a/application/hub/main/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TcpProtocolHandler extends BaseIpV4ProtocolHandler implements HandleableProtocol, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler and protocol type - $this->setHandlerName('tcp_protocol'); - $this->setProtocolName('tcp'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableMessage class - */ - public final static function createTcpProtocolHandler () { - // Get new instance - $handlerInstance = new TcpProtocolHandler(); - - // Return the prepared instance - return $handlerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/.htaccess b/application/hub/main/helper/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/class_ b/application/hub/main/helper/class_ deleted file mode 100644 index e982dd39d..000000000 --- a/application/hub/main/helper/class_ +++ /dev/null @@ -1,86 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class !!!???Helper extends BaseHubSystemHelper implements Helpable!!! { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_```); - - // Set package tags - $this->setPackageTags(array('???')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function create!!!???Helper () { - // Get new instance - $helperInstance = new !!!???Helper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @return void - */ - public function loadDescriptorXml () { - $this->partialStub('Please implement this method.'); - } - - /** - * Do the helped attempt by delivering a package to ourselfs - * - * @param $|||Instance An instance of a !!!Helper class - * @return void - */ - public function sendPackage (!!!Helper $|||Instance) { - // Sanity check: Is the ||| in the approx. state? (///) - $|||Instance->getStateInstance()->validate!!!StateIs+++(); - - // Compile the template, this inserts the loaded ||| data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/class_BaseHubSystemHelper.php b/application/hub/main/helper/class_BaseHubSystemHelper.php deleted file mode 100644 index 38d6a9c5e..000000000 --- a/application/hub/main/helper/class_BaseHubSystemHelper.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHubSystemHelper extends BaseHubSystem implements HubHelper { - /** - * Recipient type - */ - private $recipientType = 'invalid'; - - /** - * Package tags - */ - private $packageTags = array(); - - /** - * Protected constructor - * - * @param $className Name of the concrete class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for recipient type - * - * @return $recipientType Type of a recipient (the helper is made for) - */ - protected final function setRecipientType ($recipientType) { - $this->recipientType = $recipientType; - } - - /** - * Getter for recipient type - * - * @return $recipientType Type of a recipient (the helper is made for) - */ - public final function getRecipientType () { - return $this->recipientType; - } - - /** - * Getter for package tags in a simple array - * - * @return $packageTags An array with all tags for the currently handled package - */ - public final function getPackageTags () { - return $this->packageTags; - } - - /** - * Setter for package tags in a simple array - * - * @param $packageTags An array with all tags for the currently handled package - * @return void - */ - public final function setPackageTags (array $packageTags) { - $this->packageTags = $packageTags; - } - - /** - * Tries to determine the used protocol for this package (this helper is helping to send out) - * - * @return $protocolType Type of protocol to use, usually TCP - * @todo 0% done - */ - public function determineProtocolType () { - die(__METHOD__ . ':' . print_r($this, TRUE)); - // Return it - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/connection/.htaccess b/application/hub/main/helper/connection/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/connection/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/connection/class_ b/application/hub/main/helper/connection/class_ deleted file mode 100644 index 8d29049ea..000000000 --- a/application/hub/main/helper/connection/class_ +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???ConnectionHelper extends BaseConnectionHelper implements ConnectionHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set protocol - $this->setProtocolName('!!!'); - } - - /** - * Creates a socket resource ("connection") for given recipient in package data - * - * @param $packageData Raw package data - * @return $socketResource Socket resource - */ - public static function createConnectionFromPackageData (array $packageData) { - die(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/connection/class_BaseConnectionHelper.php b/application/hub/main/helper/connection/class_BaseConnectionHelper.php deleted file mode 100644 index 78e2db83d..000000000 --- a/application/hub/main/helper/connection/class_BaseConnectionHelper.php +++ /dev/null @@ -1,349 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseConnectionHelper extends BaseHubSystemHelper implements Registerable { - // Exception codes - const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x9100; - - /** - * Connection type 'incoming' - */ - const CONNECTION_TYPE_INCOMING = 'incoming'; - - /** - * Connection type 'outgoing' - */ - const CONNECTION_TYPE_OUTGOING = 'outgoing'; - - /** - * Connection type 'server' - */ - const CONNECTION_TYPE_SERVER = 'server'; - - /** - * Name of used protocol for this connection - */ - private $connectionType = 'invalid'; - - /** - * (IP) Adress used - */ - private $address = 0; - - /** - * Sent data in bytes - */ - private $sentData = 0; - - /** - * Whether this connection is initialized - */ - private $isInitialized = FALSE; - - /** - * Whether this connection is shutted down - */ - private $shuttedDown = FALSE; - - /** - * Currently queued chunks - */ - private $queuedChunks = array(); - - /** - * Current final hash - */ - private $currentFinalHash = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init state which sets the state to 'init' - $this->initState(); - - // Initialize output stream - $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_output_stream_class'); - - // And add it to this connection helper - $this->setOutputStreamInstance($streamInstance); - - // Get package instance from factory - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // ... and set it here - $this->setPackageInstance($packageInstance); - - // Register this connection helper - Registry::getRegistry()->addInstance('connection', $this); - - // Get the fragmenter instance - $fragmenterInstance = FragmenterFactory::createFragmenterInstance('package'); - - // Set it here - $this->setFragmenterInstance($fragmenterInstance); - } - - /** - * Getter for real class name, overwrites generic method and is final - * - * @return $class Name of this class - */ - public final function __toString () { - // Class name representation - $class = self::getConnectionClassName($this->getAddress(), $this->getConnectionPort(), parent::__toString()); - - // Return it - return $class; - } - - /** - * Getter for connection type - * - * @return $connectionType Name of used protocol in this connection - */ - public final function getConnectionType () { - return $this->connectionType; - } - - /** - * Setter for connection type - * - * @param $connectionType Name of used protocol in this connection - * @return void - */ - protected final function setConnectionType ($connectionType) { - $this->connectionType = $connectionType; - } - - /** - * Getter for IP address - * - * @return $address The IP address - */ - public final function getAddress () { - return $this->address; - } - - /** - * Setter for IP address - * - * @param $address The IP address - * @return void - */ - protected final function setAddress ($address) { - $this->address = $address; - } - - /** - * Setter for isInitialized - * - * @param $isInitialized Name of used protocol in this connection - * @return void - */ - protected final function setIsInitialized ($isInitialized) { - $this->isInitialized = $isInitialized; - } - - /** - * Getter for isInitialized (NOTE: no 'get' prefix for boolean attributes!) - * - * @return $isInitialized Name of used protocol in this connection - */ - protected final function isInitialized () { - return $this->isInitialized; - } - - /** - * Static "getter" for this connection class' name - * - * @param $address IP address - * @param $port Port number - * @param $className Original class name - * @return $class Expanded class name - */ - public static function getConnectionClassName ($address, $port, $className) { - // Construct it - $class = $address . ':' . $port . ':' . $className; - - // ... and return it - return $class; - } - - /** - * Initializes the peer's state which sets it to 'init' - * - * @return void - */ - private function initState() { - // Get the state factory and create the initial state. - PeerStateFactory::createPeerStateInstanceByName('init', $this); - } - - /** - * "Getter" for raw data from a package array. A fragmenter is used which - * will returns us only so many raw data which fits into the back buffer. - * The rest is being held in a back-buffer and waits there for the next - * cycle and while be then sent. - * - * This method does 2 simple steps: - * 1) Request a chunk from set fragmenter instance - * 2) Finally return the chunk (array) to the caller - * - * @param $packageData Raw package data array - * @return $chunkData Raw data chunk - */ - private function getRawDataFromPackageArray (array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: currentFinalHash=' . $this->currentFinalHash); - - // Make sure the final hash is set - assert((is_string($this->currentFinalHash)) && (!empty($this->currentFinalHash))); - - // Get the next raw data chunk from the fragmenter - $rawDataChunk = $this->getFragmenterInstance()->getNextRawDataChunk($this->currentFinalHash); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: rawDataChunk=' . print_r($rawDataChunk, TRUE)); - - // Get chunk hashes and chunk data - $chunkHashes = array_keys($rawDataChunk); - $chunkData = array_values($rawDataChunk); - - // Is the required data there? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData)); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('chunkData='.print_r($chunkData, TRUE)); - if ((isset($chunkHashes[0])) && (isset($chunkData[0]))) { - // Remember this chunk as queued - $this->queuedChunks[$chunkHashes[0]] = $chunkData[0]; - - // Return the raw data - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...'); - return $chunkData[0]; - } else { - // Return zero string - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Returning zero bytes from ' . __METHOD__ . '!'); - return ''; - } - } - - /** - * "Accept" a visitor by simply calling it back - * - * @param $visitorInstance A Visitor instance - * @return void - */ - protected final function accept (Visitor $visitorInstance) { - // Just call the visitor - $visitorInstance->visitConnectionHelper($this); - } - - /** - * Sends raw package data to the recipient - * - * @param $packageData Raw package data - * @return void - * @throws InvalidSocketException If we got a problem with this socket - */ - public function sendRawPackageData (array $packageData) { - // The helper's state must be 'connected' - $this->getStateInstance()->validatePeerStateConnected(); - - // Implode the package data array and fragement the resulting string, returns the final hash - $finalHash = $this->getFragmenterInstance()->fragmentPackageArray($packageData, $this); - - // Is the final hash set? - if ($finalHash !== TRUE) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Setting finalHash=' . $finalHash . ',currentFinalHash[' . gettype($this->currentFinalHash) . ']=' . $this->currentFinalHash); - - // Set final hash - $this->currentFinalHash = $finalHash; - } // END - if - - // Reset serial number - $this->getFragmenterInstance()->resetSerialNumber($this->currentFinalHash); - - // Init variables - $rawData = ''; - $dataStream = ' '; - - // Fill sending buffer with data - while (strlen($dataStream) > 0) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE)); - - // Convert the package data array to a raw data stream - $dataStream = $this->getRawDataFromPackageArray($packageData); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...'); - $rawData .= $dataStream; - } // END - while - - // Nothing to sent is bad news, so assert on it - assert(strlen($rawData) > 0); - - // Calculate buffer size - $bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length'); - - // Encode the raw data with our output-stream - $encodedData = $this->getOutputStreamInstance()->streamData($rawData); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[]=' . gettype($this->getSocketResource()) . PHP_EOL); - - // Init array - $encodedDataArray = array( - NetworkPackage::RAW_FINAL_HASH_INDEX => $this->currentFinalHash, - NetworkPackage::RAW_ENCODED_DATA_INDEX => $encodedData, - NetworkPackage::RAW_SENT_BYTES_INDEX => 0, - NetworkPackage::RAW_SOCKET_INDEX => $this->getSocketResource(), - NetworkPackage::RAW_BUFFER_SIZE_INDEX => $bufferSize, - NetworkPackage::RAW_DIFF_INDEX => 0 - ); - - // Calculate difference - $diff = $encodedDataArray[NetworkPackage::RAW_BUFFER_SIZE_INDEX] - strlen($encodedDataArray[NetworkPackage::RAW_ENCODED_DATA_INDEX]); - - // Push raw data to the package's outgoing stack - $this->getPackageInstance()->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); - } - - /** - * Getter for shuttedDown - * - * @return $shuttedDown Whether this connection is shutted down - */ - public final function isShuttedDown () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown)); - return $this->shuttedDown; - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/connection/ipv4/.htaccess b/application/hub/main/helper/connection/ipv4/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/connection/ipv4/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php b/application/hub/main/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php deleted file mode 100644 index 3db9b16c9..000000000 --- a/application/hub/main/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php +++ /dev/null @@ -1,335 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseIpV4ConnectionHelper extends BaseConnectionHelper { - /** - * Port number used - */ - private $connectionPort = 0; - - /** - * Protected constructor - * - * @param $className Name of implementing class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for port number to satify HandleableProtocol - * - * @return $connectionPort The port number - */ - public final function getConnectionPort () { - return $this->connectionPort; - } - - /** - * Setter for port number to satify HandleableProtocol - * - * @param $connectionPort The port number - * @return void - */ - protected final function setConnectionPort ($connectionPort) { - $this->connectionPort = $connectionPort; - } - - /** - * Initializes the current connection - * - * @return void - * @throws SocketOptionException If setting any socket option fails - */ - protected function initConnection () { - // Get socket resource - $socketResource = $this->getSocketResource(); - - // Set the option to reuse the port - if (!socket_set_option($socketResource, SOL_SOCKET, SO_REUSEADDR, 1)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); - - // And throw again - // @TODO Move this to the socket error handler - throw new SocketOptionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - /* - * Set socket to non-blocking mode before trying to establish a link to - * it. This is now the default behaviour for all connection helpers who - * call initConnection(); . - */ - if (!socket_set_nonblock($socketResource)) { - // Handle this socket error with a faked recipientData array - $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); - - // And throw again - throw new SocketOptionException(array($helperInstance, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Last step: mark connection as initialized - $this->setIsInitialized(TRUE); - } - - /** - * Attempts to connect to a peer by given IP number and port from a valid - * unlData array with currently configured timeout. - * - * @param $unlData Valid UNL data array - * @return $isConnected Whether the connection went fine - * @see Please see http://de.php.net/manual/en/function.socket-connect.php#84465 for original code - * @todo Rewrite the while() loop to a iterator to not let the software stay very long here - */ - protected function connectToPeerByUnlData (array $unlData) { - // Only call this if the connection is initialized by initConnection() - assert($this->isInitialized()); - - // Is unlData complete? - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); - - // Get current time - $time = time(); - - // "Cache" socket resource and timeout config - $socketResource = $this->getSocketResource(); - $timeout = $this->getConfigInstance()->getConfigEntry('socket_timeout_seconds'); - - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Trying to connect to ' . $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] . ':' . $unlData[UniversalNodeLocator::UNL_PART_PORT] . ' with socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' ...'); - - // Try to connect until it is connected - while ($isConnected = !@socket_connect($socketResource, $unlData[UniversalNodeLocator::UNL_PART_ADDRESS], $unlData[UniversalNodeLocator::UNL_PART_PORT])) { - // Get last socket error - $socketError = socket_last_error($socketResource); - - // Skip any errors which may happen on non-blocking connections - if (($socketError == SOCKET_EINPROGRESS) || ($socketError == SOCKET_EALREADY)) { - // Now, is that attempt within parameters? - if ((time() - $time) >= $timeout) { - // Didn't work within timeout - $isConnected = FALSE; - break; - } // END - if - - // Sleep about one second - $this->idle(1000); - } elseif ($socketError != 0) { - // Stop on everything else pronto - $isConnected = FALSE; - break; - } - } // END - while - - // Is the peer connected? - if ($isConnected === TRUE) { - // Connection is fully established here, so change the state. - PeerStateFactory::createPeerStateInstanceByName('connected', $this); - } else { - /* - * There was a problem connecting to the peer (this state is a meta - * state until the error handler has found the real cause). - */ - PeerStateFactory::createPeerStateInstanceByName('problem', $this); - } - - // Return status - return $isConnected; - } - - /** - * Marks this connection as shutted down - * - * @return void - */ - protected final function markConnectionShuttedDown () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $this->__toString() . ' has been marked as shutted down'); - $this->shuttedDown = TRUE; - - // And remove the (now invalid) socket - $this->setSocketResource(FALSE); - } - - // ************************************************************************ - // Socket error handler call-back methods - // ************************************************************************ - - /** - * Handles socket error 'connection timed out', but does not clear it for - * later debugging purposes. - * - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - * @throws SocketConnectionException The connection attempts fails with a time-out - */ - protected function socketErrorConnectionTimedOutHandler ($socketResource, array $unlData) { - // Get socket error code for verification - $socketError = socket_last_error($socketResource); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($socketResource); - - // Throw it again - throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } - - /** - * Handles socket error 'resource temporary unavailable', but does not - * clear it for later debugging purposes. - * - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - * @throws SocketConnectionException The connection attempts fails with a time-out - */ - protected function socketErrorResourceUnavailableHandler ($socketResource, array $unlData) { - // Get socket error code for verification - $socketError = socket_last_error($socketResource); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($socketResource); - - // Throw it again - throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } - - /** - * Handles socket error 'connection refused', but does not clear it for - * later debugging purposes. - * - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - * @throws SocketConnectionException The connection attempts fails with a time-out - */ - protected function socketErrorConnectionRefusedHandler ($socketResource, array $unlData) { - // Get socket error code for verification - $socketError = socket_last_error($socketResource); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($socketResource); - - // Throw it again - throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } - - /** - * Handles socket error 'no route to host', but does not clear it for later - * debugging purposes. - * - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - * @throws SocketConnectionException The connection attempts fails with a time-out - */ - protected function socketErrorNoRouteToHostHandler ($socketResource, array $unlData) { - // Get socket error code for verification - $socketError = socket_last_error($socketResource); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($socketResource); - - // Throw it again - throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } - - /** - * Handles socket error 'operation already in progress' which happens in - * method connectToPeerByUnlData() on timed out connection - * attempts. - * - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - * @throws SocketConnectionException The connection attempts fails with a time-out - */ - protected function socketErrorOperationAlreadyProgressHandler ($socketResource, array $unlData) { - // Get socket error code for verification - $socketError = socket_last_error($socketResource); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Half-shutdown this socket (see there for difference to shutdownSocket()) - $this->halfShutdownSocket($socketResource); - - // Throw it again - throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } - - /** - * Handles socket error 'connection reset by peer', but does not clear it for - * later debugging purposes. - * - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - * @throws SocketConnectionException The connection attempts fails with a time-out - */ - protected function socketErrorConnectionResetByPeerHandler ($socketResource, array $unlData) { - // Get socket error code for verification - $socketError = socket_last_error($socketResource); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($socketResource); - - // Throw it again - throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } - - /** - * Handles socket "error" 'operation now in progress' which can be safely - * passed on with non-blocking connections. - * - * @param $socketResource A valid socket resource - * @param $unlData A valid UNL data array - * @return void - */ - protected function socketErrorOperationInProgressHandler ($socketResource, array $unlData) { - self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Operation is now in progress, this is usual for non-blocking connections and is no bug.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/connection/ipv4/tcp/.htaccess b/application/hub/main/helper/connection/ipv4/tcp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/connection/ipv4/tcp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php b/application/hub/main/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php deleted file mode 100644 index 682c181bb..000000000 --- a/application/hub/main/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements ConnectionHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set protocol - $this->setProtocolName('tcp'); - } - - /** - * Creates a half-connected socket resource ("connection") for given - * recipient in package data. After you called this method you still need to - * connect to the other node. - * - * @param $packageData Raw package data - * @return $socketResource Socket resource - * @throws SocketCreationException If the socket could not be created - * @throws SocketOptionException If a socket option could not be set - * @throws SocketConnectionException If a connection could not be opened - * @todo $errorCode/-Message are now in handleSocketError()'s call-back methods - */ - public static function createConnectionFromPackageData (array $packageData) { - // Create an instance - $helperInstance = new TcpConnectionHelper(); - - // Create a socket instance - $socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - - // Is the socket resource valid? - if (!is_resource($socketResource)) { - /* - * Something bad happened, calling handleSocketError() is not - * possible here because that method would throw an - * InvalidSocketException back. - */ - throw new SocketCreationException(array($helperInstance, gettype($socketResource)), BaseListener::EXCEPTION_SOCKET_CREATION_FAILED); - } // END - if - - // Get socket error code for verification - $socketError = socket_last_error($socketResource); - - // Check if there was an error else - if ($socketError > 0) { - // Handle this socket error with a faked recipientData array - $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); - - // Then throw again - throw new SocketCreationException(array($helperInstance, gettype($socketResource), $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_SOCKET_CREATION_FAILED); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Setting socket resource ... (' . gettype($socketResource) . ')'); - - // Set the resource - $helperInstance->setSocketResource($socketResource); - - // Init connection - $helperInstance->initConnection(); - - // @TODO The whole resolving part should be moved out and made more configurable - // Init recipient data - $unlData = array(); - - // Try to solve the recipient - try { - // Get protocol handler back from package data - $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData); - - // Get UNL data - $unlData = $handlerInstance->getUniversalNodeLocatorDataArray(); - - // Make sure it is a valid Universal Node Locator array (3 elements) - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); - - // Set handler instance - $helperInstance->setHandlerInstance($handlerInstance); - } catch (NoValidHostnameException $e) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage()); - - // Is the recipient equal as configured IP - if (substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_address'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_address')) { - // This may connect to shipsimu.org and requests 'ip.php' which will return our external IP address - $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] = HubTools::determineExternalAddress(); - - // Do we have ip:port match? - // @TODO Rewrite this test for UNLs - if (strpos($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], ':') === FALSE) { - // No ip:port! - $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' does not contain ":". Please fix this.'); - } // END - if - - // "explode" the ip:port, so index 1 will be the port number - // @TODO Rewrite this test for UNLs - $recipientArray = explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); - - // Add the port - $unlData[UniversalNodeLocator::UNL_PART_PORT] = $recipientArray[UniversalNodeLocator::UNL_PART_PORT]; - } else { - // It doesn't match, we need to take care of this later - $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . '!=' . $helperInstance->getConfigInstance()->getConfigEntry('external_address')); - } - } - - // Set address and maybe port - $helperInstance->setAddress($unlData[UniversalNodeLocator::UNL_PART_ADDRESS]); - $helperInstance->setConnectionPort($unlData[UniversalNodeLocator::UNL_PART_PORT]); - - // Now connect to it - if (!$helperInstance->connectToPeerByUnlData($unlData)) { - // Handle socket error - $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, $unlData); - } // END - if - - // Okay, that should be it. Return it... - return $socketResource; - } - - /** - * Do the shutdown sequence for this connection helper - * - * @return void - * @throws SocketShutdownException If the current socket could not be shut down - * @todo We may want to implement a filter for ease notification of other objects like our pool - */ - public function doShutdown () { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down socket resource ' . $this->getSocketResource()); - - // Clear any previous errors - socket_clear_error($this->getSocketResource()); - - // Call the shutdown function on the currently set socket - if (!socket_shutdown($this->getSocketResource())) { - // Could not shutdown socket, this is fine if e.g. the other side is not connected, so analyse it - if (socket_last_error($this->getSocketResource()) != 107) { - // Something bad happened while we shutdown a socket - throw new SocketShutdownException($this, BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - } // END - if - - // Try to make blocking IO for socket_close() - socket_set_block($this->getSocketResource()); - - // Drop all data (don't sent any on socket closure) - socket_set_option($this->getSocketResource(), SOL_SOCKET, SO_LINGER, array('l_onoff' => 1, 'l_linger' => 0)); - - // Finally close socket to free some resources - socket_close($this->getSocketResource()); - - // Mark this connection as shutted down - $this->markConnectionShuttedDown(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/connection/ipv4/udp/.htaccess b/application/hub/main/helper/connection/ipv4/udp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/connection/ipv4/udp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/connection/ipv4/udp/class_UdpConnectionHelper.php b/application/hub/main/helper/connection/ipv4/udp/class_UdpConnectionHelper.php deleted file mode 100644 index 4ab6f3b26..000000000 --- a/application/hub/main/helper/connection/ipv4/udp/class_UdpConnectionHelper.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UdpConnectionHelper extends BaseIpV4ConnectionHelper implements ConnectionHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set protocol - $this->setProtocolName('udp'); - } - - /** - * Creates a half-connected socket resource ("connection") for given - * recipient in package data. After you called this method you still need to - * connect to the other node. - * - * @param $packageData Raw package data - * @return $socketResource Socket resource - */ - public static function createConnectionFromPackageData (array $packageData) { - $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: Unfinished method, packageData[]=' . count($packageData)); - } - - /** - * Do the shutdown sequence for this connection helper - * - * @return void - * @throws SocketShutdownException If the current socket could not be shut down - * @todo Implement a filter for ease notification of other objects like the pool - */ - public function doShutdown () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/dht/.htaccess b/application/hub/main/helper/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/dht/class_DhtBootstrapHelper.php b/application/hub/main/helper/dht/class_DhtBootstrapHelper.php deleted file mode 100644 index 1fc25af21..000000000 --- a/application/hub/main/helper/dht/class_DhtBootstrapHelper.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_DHT); - - // Set package tags - $this->setPackageTags(array('dht_bootstrap')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function createDhtBootstrapHelper () { - // Get new instance - $helperInstance = new DhtBootstrapHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the announcement descriptor for parsing - * - * @param $dhtInstance An instance of a Distributable class - * @return void - */ - public function loadDescriptorXml (Distributable $dhtInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with DHT boostrap ...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_bootstrap_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Do the helped attempt by delivering a package to ourselfs - * - * @param $dhtInstance An instance of a Distributable class - * @return void - */ - public function sendPackage (Distributable $dhtInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - /* - * Sanity check: Is the DHT in the approx. state? 'init' for bootstrap - * nodes and 'virgin' for all others. - */ - $dhtInstance->getStateInstance()->validateDhtStateIsVirginOrInit(); - - // Compile the template, this inserts the loaded dht data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - //* DEBUG: */ die(__METHOD__ . ':dhtInstance=' . print_r($dhtInstance, TRUE)); - $packageInstance->enqueueRawDataFromTemplate($this); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/dht/class_DhtPublishEntryHelper.php b/application/hub/main/helper/dht/class_DhtPublishEntryHelper.php deleted file mode 100644 index b4cd7cedf..000000000 --- a/application/hub/main/helper/dht/class_DhtPublishEntryHelper.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtPublishEntryHelper extends BaseHubSystemHelper implements HelpableDht { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_DHT); - - // Set package tags - $this->setPackageTags(array('dht_publish_entry')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function createDhtPublishEntryHelper () { - // Get new instance - $helperInstance = new DhtPublishEntryHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the announcement descriptor for parsing - * - * @param $dhtInstance An instance of a Distributable class - * @return void - */ - public function loadDescriptorXml (Distributable $dhtInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with publishing an entry ...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_publish_entry_template_class'); - - // Set stacker - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Do the helped attempt by delivering a package to ourselfs - * - * @param $dhtInstance An instance of a Distributable class - * @return void - */ - public function sendPackage (Distributable $dhtInstance) { - // Compile the template, this inserts the loaded dht data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/messages/.htaccess b/application/hub/main/helper/messages/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/messages/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/messages/class_ b/application/hub/main/helper/messages/class_ deleted file mode 100644 index db234f141..000000000 --- a/application/hub/main/helper/messages/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???MessageHelper extends BaseMessageHelper implements MessageHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $messageInstance An instance of a UnitHelper class - */ - public final static function create???MessageHelper () { - // Get new instance - $messageInstance = new ???MessageHelper(); - - // Return the prepared instance - return $messageInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/messages/class_BaseMessageHelper.php b/application/hub/main/helper/messages/class_BaseMessageHelper.php deleted file mode 100644 index 0dcbf7251..000000000 --- a/application/hub/main/helper/messages/class_BaseMessageHelper.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseMessageHelper extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/messages/crypto/.htaccess b/application/hub/main/helper/messages/crypto/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/messages/crypto/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php b/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php deleted file mode 100644 index b91e729e0..000000000 --- a/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CryptoRandomUnitMessageHelper extends BaseMessageHelper implements MessageHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $sourceType Type of the source - * @return $messageInstance An instance of a UnitHelper class - */ - public final static function createCryptoRandomUnitMessageHelper ($sourceType) { - // Get new instance - $messageInstance = new CryptoRandomUnitMessageHelper(); - - // Generate a source instance - $sourceInstance = UnitSourceFactory::createUnitSourceInstance($sourceType); - - // Set the source instance - $messageInstance->setSourceInstance($sourceInstance); - - // Return the prepared instance - return $messageInstance; - } - - /** - * Generates an encrypted random message - * - * @return $encryptedMessage The encrypted random message - */ - public function generateRandomMessage () { - // Get the message from our source - $encryptedMessage = $this->getSourceInstance()->generateMessageFromSource(); - - // Return it - return $encryptedMessage; - } - - /** - * "Getter" for an iterator for keys - * - * @return $iteratorInstance An instance of a Iterator class - */ - public function getKeyIterator () { - // Create the iterator instance - $iteratorInstance = ObjectFactory::createObjectByConfiguredName('test_unit_producer_key_iterator_class'); - - // And return it - return $iteratorInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/.htaccess b/application/hub/main/helper/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/announcement/.htaccess b/application/hub/main/helper/node/announcement/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/announcement/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/announcement/class_NodeAnnouncementHelper.php b/application/hub/main/helper/node/announcement/class_NodeAnnouncementHelper.php deleted file mode 100644 index eb4f6d1e1..000000000 --- a/application/hub/main/helper/node/announcement/class_NodeAnnouncementHelper.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeAnnouncementHelper extends BaseNodeHelper implements HelpableNode { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER); - - // Set package tags - $this->setPackageTags(array('announcement')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public static final function createNodeAnnouncementHelper () { - // Get new instance - $helperInstance = new NodeAnnouncementHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the announcement descriptor for parsing - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with announcement to upper hubs...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Publishes the node's descriptor XML to all found upper nodes when the - * node has not yet published it's descriptor to a bootstrap node. This is - * done by getting the raw XML content and inserting all variables into - * the code. After this wents fine, the rendered content got "packaged" - * for network delivery. - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/answer/.htaccess b/application/hub/main/helper/node/answer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/answer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/answer/announcement/.htaccess b/application/hub/main/helper/node/answer/announcement/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/answer/announcement/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/main/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php deleted file mode 100644 index 1ae11467d..000000000 --- a/application/hub/main/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init package tags - $this->setPackageTags(array('announcement_answer')); - } - - /** - * Creates the helper class - * - * @param $messageData An array with all message data - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNodeAnnouncementMessageAnswerHelper (array $messageData) { - // Get new instance - $helperInstance = new NodeAnnouncementMessageAnswerHelper(); - - // Set session id of other peer as recipient - $helperInstance->setRecipientType($messageData[XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID]); - - // Set message data - $helperInstance->setMessageData($messageData); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer an announcement...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_answer_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Send out announcement answer package - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active/reachable) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/answer/class_BaseHubAnswerHelper.php b/application/hub/main/helper/node/answer/class_BaseHubAnswerHelper.php deleted file mode 100644 index 2d699f18e..000000000 --- a/application/hub/main/helper/node/answer/class_BaseHubAnswerHelper.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHubAnswerHelper extends BaseNodeHelper { - /** - * Message data array - */ - private $messageData = array(); - - /** - * Protected constructor - * - * @param $className Name of the concrete class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for message data - * - * @return $messageData An array with message data - */ - protected final function setMessageData (array $messageData) { - $this->messageData = $messageData; - } - - /** - * Getter for message data - * - * @return $messageData An array with message data - */ - public final function getMessageData () { - return $this->messageData; - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/answer/dht/.htaccess b/application/hub/main/helper/node/answer/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/answer/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php b/application/hub/main/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php deleted file mode 100644 index 07d9e041c..000000000 --- a/application/hub/main/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtBootstrapMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init package tags - $this->setPackageTags(array('dht_bootstrap_answer')); - } - - /** - * Creates the helper class - * - * @param $messageData An array with all message data - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNodeDhtBootstrapMessageAnswerHelper (array $messageData) { - // Get new instance - $helperInstance = new NodeDhtBootstrapMessageAnswerHelper(); - - // Set session id of other peer as recipient - $helperInstance->setRecipientType($messageData[XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID]); - - // Set message data - $helperInstance->setMessageData($messageData); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer a DHT bootstrap request...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_dht_bootstrap_answer_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Send out announcement answer package - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active/reachable) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/answer/requests/.htaccess b/application/hub/main/helper/node/answer/requests/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/answer/requests/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/main/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php deleted file mode 100644 index 5f391a0fc..000000000 --- a/application/hub/main/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init package tags - $this->setPackageTags(array('request_node_list_answer')); - } - - /** - * Creates the helper class - * - * @param $messageData An array with all message data - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNodeRequestNodeListMessageAnswerHelper (array $messageData) { - // Get new instance - $helperInstance = new NodeRequestNodeListMessageAnswerHelper(); - - // Set session id of other peer as recipient - $helperInstance->setRecipientType($messageData[XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID]); - - // Set message data - $helperInstance->setMessageData($messageData); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer a request: node-list...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_answer_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // "Cache" entries instance for next foreach loop - $entriesInstance = $templateInstance->getTemplateInstance(); - - // Is must not be NULL (then it can only be a template instance) - assert(!is_null($entriesInstance)); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Send out request-node-list answer package - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active/reachable) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/class_ b/application/hub/main/helper/node/class_ deleted file mode 100644 index 21bbb6575..000000000 --- a/application/hub/main/helper/node/class_ +++ /dev/null @@ -1,83 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Node???Helper extends BaseNodeHelper implements HelpableNode { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_!!!); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNode???Helper () { - // Get new instance - $helperInstance = new Node???Helper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @return void - */ - public function loadDescriptorXml () { - $this->partialStub('Please implement this method.'); - } - - /** - * Do the helped attempt by delivering a package to ourselfs - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsActive(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/class_BaseNodeHelper.php b/application/hub/main/helper/node/class_BaseNodeHelper.php deleted file mode 100644 index e2a92b051..000000000 --- a/application/hub/main/helper/node/class_BaseNodeHelper.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseNodeHelper extends BaseHubSystemHelper { - /** - * Protected constructor - * - * @param $className Name of the concrete class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/connection/.htaccess b/application/hub/main/helper/node/connection/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/connection/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/connection/class_NodeSelfConnectHelper.php b/application/hub/main/helper/node/connection/class_NodeSelfConnectHelper.php deleted file mode 100644 index 5c57946f0..000000000 --- a/application/hub/main/helper/node/connection/class_NodeSelfConnectHelper.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeSelfConnectHelper extends BaseNodeHelper implements HelpableNode { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF); - - // Set package tags - $this->setPackageTags(array('self_connect')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public static final function createNodeSelfConnectHelper () { - // Get new instance - $helperInstance = new NodeSelfConnectHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting self-connect...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_self_connect_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Do the self-connect attempt by delivering a package to ourselfs - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnouncing(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/node/requests/.htaccess b/application/hub/main/helper/node/requests/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/node/requests/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/node/requests/class_NodeRequestNodeListHelper.php b/application/hub/main/helper/node/requests/class_NodeRequestNodeListHelper.php deleted file mode 100644 index e674c326e..000000000 --- a/application/hub/main/helper/node/requests/class_NodeRequestNodeListHelper.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeRequestNodeListHelper extends BaseNodeHelper implements HelpableNode { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER); - - // Set package tags - $this->setPackageTags(array('request_node_list')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNodeRequestNodeListHelper () { - // Get new instance - $helperInstance = new NodeRequestNodeListHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to request: node-list...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Do the helped attempt by delivering a package to ourselfs - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsAnnouncementCompleted(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/work_units/.htaccess b/application/hub/main/helper/work_units/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/work_units/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/work_units/class_ b/application/hub/main/helper/work_units/class_ deleted file mode 100644 index 400fac1fe..000000000 --- a/application/hub/main/helper/work_units/class_ +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???WorkUnitHelper extends BaseWorkUnitHelper implements UnitHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $unitInstance An instance of a UnitHelper class - */ - public final static function create???WorkUnitHelper () { - // Get new instance - $unitInstance = new ???WorkUnitHelper(); - - // Return the prepared instance - return $unitInstance; - } - - /** - * Initializes this WU helper - * - * @return void - * @todo 0% done - */ - protected function initializeUnitHelper () { - $this->partialStub('Please implement this method.'); - } - - /** - * Generates a work/test/foo unit instance - * - * @return $unitInstance A work unit instance - * @todo 0% done - */ - public function generateUnit () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php b/application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php deleted file mode 100644 index 7dc344ecd..000000000 --- a/application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseWorkUnitHelper extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // All WU helpers needs to be initialized - $this->initializeUnitHelper(); - } - - /** - * Initializes this WU helper - * - * @return void - */ - abstract protected function initializeUnitHelper (); -} - -// [EOF] -?> diff --git a/application/hub/main/helper/work_units/cruncher/.htaccess b/application/hub/main/helper/work_units/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/helper/work_units/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php b/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php deleted file mode 100644 index 704a8d9c5..000000000 --- a/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherTestUnitHelper extends BaseWorkUnitHelper implements UnitHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $unitInstance An instance of a UnitHelper class - */ - public final static function createCruncherTestUnitHelper () { - // Get new instance - $unitInstance = new CruncherTestUnitHelper(); - - // Return the prepared instance - return $unitInstance; - } - - /** - * Initializes this WU helper. This method satisfies the abstract - * BaseWorkUnitHelper class. - * - * @return void - * @todo 0% done - */ - protected function initializeUnitHelper () { - $this->partialStub('Please implement this method.'); - } - - /** - * Generates a work/test/foo unit instance. This method satifies the - * UnitHelper interface. - * - * @return $unitInstance A work unit instance - * @todo 0% done - */ - public function generateNextUnitInstance () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/info/.htaccess b/application/hub/main/info/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/info/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/info/class_ b/application/hub/main/info/class_ deleted file mode 100644 index 58c9aa1b8..000000000 --- a/application/hub/main/info/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Info extends BaseInfo implements ShareableInfo { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $infoInstance An instance of a ShareableInfo class - */ - public final static function create???Info () { - // Get new instance - $infoInstance = new ???Info(); - - // Return the prepared instance - return $infoInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/info/class_BaseInfo.php b/application/hub/main/info/class_BaseInfo.php deleted file mode 100644 index 1a24194e9..000000000 --- a/application/hub/main/info/class_BaseInfo.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseInfo extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/info/connection/.htaccess b/application/hub/main/info/connection/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/info/connection/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/info/connection/class_ConnectionInfo.php b/application/hub/main/info/connection/class_ConnectionInfo.php deleted file mode 100644 index f9751b569..000000000 --- a/application/hub/main/info/connection/class_ConnectionInfo.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $infoInstance An instance of a ShareableInfo class - */ - public final static function createConnectionInfo () { - // Get new instance - $infoInstance = new ConnectionInfo(); - - // Return the prepared instance - return $infoInstance; - } - - /** - * Fills the information class with data from a Listenable instance - * - * @param $listenerInstance An instance of a Listenable class - * @return void - */ - public function fillWithListenerInformation (Listenable $listenerInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); - - // Fill the generic array with several data from the listener: - $this->setProtocolName($listenerInstance->getProtocolName()); - $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $listenerInstance->getListenAddress()); - $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $listenerInstance->getListenPort()); - - // Set listener here - $this->setListenerInstance($listenerInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Fills the information class with data from a ConnectionHelper instance - * - * @param $helperInstance An instance of a ConnectionHelper class - * @return void - */ - public function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!'); - - // Fill the generic array with several data from the listener: - $this->setProtocolName($helperInstance->getProtocolName()); - $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $helperInstance->getAddress()); - $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $helperInstance->getConnectionPort()); - - // Set helper here - $this->setHelperInstance($helperInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Getter for address - * - * @return $address Address from shared information - */ - public final function getAddress () { - // Return it from generic array - return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS); - } - - /** - * Getter for port - * - * @return $port Port from shared information - */ - public final function getPort () { - // Return it from generic array - return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT); - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/.htaccess b/application/hub/main/iterator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/hub/.htaccess b/application/hub/main/iterator/hub/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/hub/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/hub/class_HubPingIterator.php b/application/hub/main/iterator/hub/class_HubPingIterator.php deleted file mode 100644 index 8f65db578..000000000 --- a/application/hub/main/iterator/hub/class_HubPingIterator.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubPingIterator extends BaseIterator implements Iterator { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $iteratorInstance An instance of a Iterator class - */ - public static final function createHubPingIterator () { - // Get new instance - $iteratorInstance = new HubPingIterator(); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - */ - public function current () { - // Default is null - $current = NULL; - - $this->partialStub('Please implement this method.'); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $key Current key in iteration - */ - public function key () { - // Default is null - $key = NULL; - - $this->partialStub('Please implement this method.'); - - // Return it - return $key; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->partialStub('Please implement this method.'); - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->partialStub('Please implement this method.'); - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return void - */ - public function valid () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/network/.htaccess b/application/hub/main/iterator/network/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/network/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/network/class_NetworkListenIterator.php b/application/hub/main/iterator/network/class_NetworkListenIterator.php deleted file mode 100644 index 18c2e8018..000000000 --- a/application/hub/main/iterator/network/class_NetworkListenIterator.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This current implementation is not recommended, use a - * @todo latency-based iteration or similar approaches - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NetworkListenIterator extends BaseIterator implements Iterator { - /** - * Key for the global list index - */ - private $indexKey = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listInstance A list of a Listable - * @return $iteratorInstance An instance a Iterator class - */ - public static final function createNetworkListenIterator (Listable $listInstance) { - // Get new instance - $iteratorInstance = new NetworkListenIterator(); - - // Set the list - $iteratorInstance->setListInstance($listInstance); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - * @throws IndexOutOfBoundsException If $indexKey is out of bounds - */ - public function current () { - // Default is null - $current = NULL; - - // Is the entry valid? - if (!$this->valid()) { - // Throw an exception here - throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if - - // Now get the entry - $current = $this->getListInstance()->getEntry($this->key()); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $indexKey Current key in iteration - */ - public function key () { - return $this->indexKey; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->indexKey++; - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->indexKey = 0; - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return $isValid Whether the current entry is there - */ - public function valid () { - // Check for total active peers and if we are not at the end - $isValid = ($this->key() < $this->getListInstance()->count()); - - // Return result - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/pool/.htaccess b/application/hub/main/iterator/pool/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/pool/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/pool/handler/.htaccess b/application/hub/main/iterator/pool/handler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/pool/handler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/pool/handler/class_Handler b/application/hub/main/iterator/pool/handler/class_Handler deleted file mode 100644 index 9ec43c124..000000000 --- a/application/hub/main/iterator/pool/handler/class_Handler +++ /dev/null @@ -1,107 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Handler???Iterator extends BaseIterator implements Iterator { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $iteratorInstance An instance a Iterator class - */ - public final static function createHandler???Iterator () { - // Get new instance - $iteratorInstance = new Handler???Iterator(); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - */ - public function current () { - // Default is null - $current = null; - - $this->partialStub('Please implement this method.'); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $key Current key in iteration - */ - public function key () { - // Default is null - $key = null; - - $this->partialStub('Please implement this method.'); - - // Return it - return $key; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->partialStub('Please implement this method.'); - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->partialStub('Please implement this method.'); - } - - /** - * Checks wether the current entry is valid (not at the end of the list) - * - * @return void - */ - public function valid () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php b/application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php deleted file mode 100644 index e23c2fde6..000000000 --- a/application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This current implementation is not recommended, use a - * @todo latency-based iteration or similar approaches - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HandlerPoolIterator extends BaseIterator implements Iterator { - /** - * Key for the global list index - */ - private $indexKey = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listInstance A list of a Listable - * @return $iteratorInstance An instance a Iterator class - */ - public static final function createHandlerPoolIterator (Listable $listInstance) { - // Get new instance - $iteratorInstance = new HandlerPoolIterator(); - - // Set the list - $iteratorInstance->setListInstance($listInstance); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - * @throws IndexOutOfBoundsException If $indexKey is out of bounds - */ - public function current () { - // Default is null - $current = NULL; - - // Is the entry valid? - if (!$this->valid()) { - // Throw an exception here - throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if - - // Now get the entry - $current = $this->getListInstance()->getEntry($this->key()); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $indexKey Current key in iteration - */ - public function key () { - return $this->indexKey; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->indexKey++; - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->indexKey = 0; - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return $isValid Whether the current entry is there - */ - public function valid () { - // Check for total active peers and if we are not at the end - $isValid = ($this->key() < $this->getListInstance()->count()); - - // Return result - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/pool/monitor/.htaccess b/application/hub/main/iterator/pool/monitor/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/pool/monitor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/pool/monitor/class_MonitorPoolIterator.php b/application/hub/main/iterator/pool/monitor/class_MonitorPoolIterator.php deleted file mode 100644 index d94a6f218..000000000 --- a/application/hub/main/iterator/pool/monitor/class_MonitorPoolIterator.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This current implementation is not recommended, use a - * @todo latency-based iteration or similar approaches - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MonitorPoolIterator extends BaseIterator implements Iterator, Registerable { - /** - * Key for the global list index - */ - private $indexKey = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listInstance A list of a Listable - * @return $iteratorInstance An instance a Iterator class - */ - public static final function createMonitorPoolIterator (Listable $listInstance) { - // Get new instance - $iteratorInstance = new MonitorPoolIterator(); - - // Set the list - $iteratorInstance->setListInstance($listInstance); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - * @throws IndexOutOfBoundsException If $indexKey is out of bounds - */ - public function current () { - // Default is null - $current = NULL; - - // Is the entry valid? - if (!$this->valid()) { - // Throw an exception here - throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if - - // Now get the entry - $current = $this->getListInstance()->getEntry($this->key()); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $indexKey Current key in iteration - */ - public function key () { - return $this->indexKey; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->indexKey++; - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->indexKey = 0; - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return $isValid Whether the current entry is there - */ - public function valid () { - // Check for total active peers and if we are not at the end - $isValid = ($this->key() < $this->getListInstance()->count()); - - // Return result - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/pool/shutdown/.htaccess b/application/hub/main/iterator/pool/shutdown/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/pool/shutdown/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/pool/shutdown/class_Shutdown b/application/hub/main/iterator/pool/shutdown/class_Shutdown deleted file mode 100644 index 5e0aaa843..000000000 --- a/application/hub/main/iterator/pool/shutdown/class_Shutdown +++ /dev/null @@ -1,107 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Shutdown???Iterator extends BaseIterator implements Iterator { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $iteratorInstance An instance a Iterator class - */ - public final static function createShutdown???Iterator () { - // Get new instance - $iteratorInstance = new Shutdown???Iterator(); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - */ - public function current () { - // Default is null - $current = null; - - $this->partialStub('Please implement this method.'); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $key Current key in iteration - */ - public function key () { - // Default is null - $key = null; - - $this->partialStub('Please implement this method.'); - - // Return it - return $key; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->partialStub('Please implement this method.'); - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->partialStub('Please implement this method.'); - } - - /** - * Checks wether the current entry is valid (not at the end of the list) - * - * @return void - */ - public function valid () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php b/application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php deleted file mode 100644 index 9d53a2937..000000000 --- a/application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ShutdownPoolIterator extends BaseIterator implements Iterator { - /** - * Key for the global list index - */ - private $indexKey = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listInstance A list of a Listable - * @return $iteratorInstance An instance a Iterator class - */ - public static final function createShutdownPoolIterator (Listable $listInstance) { - // Get new instance - $iteratorInstance = new ShutdownPoolIterator(); - - // Set the list - $iteratorInstance->setListInstance($listInstance); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - * @throws IndexOutOfBoundsException If $indexKey is out of bounds - */ - public function current () { - // Default is null - $current = NULL; - - // Is the entry valid? - if (!$this->valid()) { - // Throw an exception here - throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if - - // Now get the entry - $current = $this->getListInstance()->getEntry($this->key()); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $indexKey Current key in iteration - */ - public function key () { - return $this->indexKey; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->indexKey++; - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->indexKey = 0; - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return $isValid Whether the current entry is there - */ - public function valid () { - // Check for total active peers and if we are not at the end - $isValid = ($this->key() < $this->getListInstance()->count()); - - // Return result - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/pool/tasks/.htaccess b/application/hub/main/iterator/pool/tasks/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/pool/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php b/application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php deleted file mode 100644 index 7611ebc59..000000000 --- a/application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This current implementation is not recommended, use a - * @todo latency-based iteration or similar approaches - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TaskPoolIterator extends BaseIterator implements Iterator, Registerable { - /** - * Key for the global list index - */ - private $indexKey = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listInstance A list of a Listable - * @return $iteratorInstance An instance a Iterator class - */ - public static final function createTaskPoolIterator (Listable $listInstance) { - // Get new instance - $iteratorInstance = new TaskPoolIterator(); - - // Set the list - $iteratorInstance->setListInstance($listInstance); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - * @throws IndexOutOfBoundsException If $indexKey is out of bounds - */ - public function current () { - // Default is null - $current = NULL; - - // Is the entry valid? - if (!$this->valid()) { - // Throw an exception here - throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if - - // Now get the entry - $current = $this->getListInstance()->getEntry($this->key()); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $indexKey Current key in iteration - */ - public function key () { - return $this->indexKey; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->indexKey++; - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->indexKey = 0; - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return $isValid Whether the current entry is there - */ - public function valid () { - // Check for total active peers and if we are not at the end - $isValid = ($this->key() < $this->getListInstance()->count()); - - // Return result - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/iterator/producer/.htaccess b/application/hub/main/iterator/producer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/producer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/producer/keys/.htaccess b/application/hub/main/iterator/producer/keys/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/iterator/producer/keys/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php b/application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php deleted file mode 100644 index ce2c1411d..000000000 --- a/application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TestUnitKeyProducerIterator extends BaseIterator implements Iterator { - /** - * Maximum different bit combinations - */ - private $maxBits = 0; - - /** - * Key length - */ - private $keyLength = 0; - - /** - * Current iteration - */ - private $currentIteration = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Get key length - $this->keyLength = $this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length'); - - // Make sure the key length isn't getting to big (32 byte = 256 bit is really, really a lot!) - assert($this->keyLength <= (8 * 32)); - - // Set max bits entry - $this->maxBits = pow(2, $this->keyLength); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('ITERATOR: maxBits=' . $this->maxBits . ',keyLength=' . $this->keyLength . ' bits'); - } - - /** - * Creates an instance of this class - * - * @return $iteratorInstance An instance of a Iterator class - */ - public final static function createTestUnitKeyProducerIterator () { - // Get new instance - $iteratorInstance = new TestUnitKeyProducerIterator(); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value - * - * @return $current Current value in iteration - */ - public function current () { - // Calculate ASCII string representation of the key number - $current = $this->dec2asc($this->currentIteration); - - // Prepend more zeros - $current = str_pad($current, ($this->keyLength / 8), chr(0), STR_PAD_LEFT); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $key Current key in iteration - * @throws UnsupportedOperationException This method should not be called - */ - public function key () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - /* - * This is of course a very ineffective key generation iterator because - * it will create a lot of keys that will never decode an encrypted - * message. If you know a better algorithm which is freely available and - * can be implemented as an itertator please contact me. - */ - $this->currentIteration++; - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - * @throws UnsupportedOperationException This method should not be called - */ - public function rewind () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return void - */ - public function valid () { - return ($this->currentIteration <= $this->maxBits); - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/.htaccess b/application/hub/main/listener/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/listener/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php deleted file mode 100644 index ab44d2d6f..000000000 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseListenerDecorator extends BaseDecorator implements Visitable { - /** - * Listener type - */ - private $listenerType = 'invalid'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for listen address - * - * @return $listenAddress The address this listener should listen on - */ - public final function getListenAddress () { - return $this->getListenerInstance()->getListenAddress(); - } - - /** - * Getter for listen port - * - * @return $listenPort The port this listener should listen on - */ - public final function getListenPort () { - return $this->getListenerInstance()->getListenPort(); - } - - /** - * Getter for connection type - * - * @return $connectionType Connection type for this listener - */ - public final function getConnectionType () { - return $this->getListenerInstance()->getConnectionType(); - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this decorator - $visitorInstance->visitDecorator($this); - - // Visit the covered class - $visitorInstance->visitListener($this->getListenerInstance()); - } - - /** - * Getter for listener type. - * - * @return $listenerType The listener's type (hub/peer) - */ - public final function getListenerType () { - return $this->listenerType; - } - - /** - * Setter for listener type. - * - * @param $listenerType The listener's type (hub/peer) - * @return void - */ - protected final function setListenerType ($listenerType) { - $this->listenerType = $listenerType; - } - - /** - * Getter for peer pool instance - * - * @return $poolInstance A peer pool instance - */ - public final function getPoolInstance () { - return $this->getListenerInstance()->getPoolInstance(); - } - - /** - * Monitors incoming raw data from the handler and transfers it to the - * given receiver instance. - * - * @return void - */ - public function monitorIncomingRawData () { - // Get the handler instance - $handlerInstance = $this->getListenerInstance()->getHandlerInstance(); - - /* - * Does our deocorated listener (or even a decorator again) have a - * handler assigned? Remember that a handler will hold all incoming raw - * data and not a listener. - */ - if (!$handlerInstance instanceof Networkable) { - // Skip this silently for now. Later on, this will become mandatory! - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('No handler assigned to this listener decorator. this=' . $this->__toString() . ', listenerInstance=' . $this->getListenerInstance()->__toString()); - return; - } // END - if - - // Does the handler have some decoded data pending? - if (!$handlerInstance->isRawDataPending()) { - // No data is pending so skip further code silently - return; - } // END - if - - // Get receiver (network package) instance - $receiverInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - /* - * We have some pending decoded data. The receiver instance is an - * abstract network package (which can be received and sent out) so - * handle the decoded data over. At this moment we don't need to know - * if the decoded data origins from a TCP or UDP connection so we can - * just pass it over to the network package receiver - */ - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-LISTENER-DECORATOR[' . __METHOD__ . ':' . __LINE__ . '] Going to handle over some raw data to receiver instance (' . $receiverInstance->__toString() . ') ...'); - $receiverInstance->addRawDataToIncomingStack($handlerInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/decorators/.htaccess b/application/hub/main/listener/decorators/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/listener/decorators/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/listener/tcp/.htaccess b/application/hub/main/listener/tcp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/listener/tcp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/listener/tcp/class_ b/application/hub/main/listener/tcp/class_ deleted file mode 100644 index 96b146f9f..000000000 --- a/application/hub/main/listener/tcp/class_ +++ /dev/null @@ -1,208 +0,0 @@ -while (count($clients) > 0) { - // create a copy, so $clients doesn't get modified by socket_select() - $read = $clients; - - // get a list of all the clients that have data to be read from - // if there are no clients with data, go to next iteration - $left = @socket_select($read, $write = null, $except = null, 0, 150); - if ($left < 1) { - continue; - } - - // check if there is a client trying to connect - if (in_array($mainSocket, $read)) { - // accept the client, and add him to the $clients array - $new_sock = socket_accept($mainSocket); - $clients[] = $new_sock; - - // send the client a welcome message - socket_write($new_sock, "No noobs, but I'll make an exception. :)\n". - "There are ".(count($clients) - 1)." client(s) connected to the server.\n"); - - socket_getpeername($new_sock, $ip); - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}"); - - // Notify all chatter - if (count($clients) > 2) { - foreach ($clients as $send_sock) { - if ($send_sock != $mainSocket && $send_sock != $new_sock) { - socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n"); - } - } - } - - // remove the listening socket from the clients-with-data array - $key = array_search($mainSocket, $read); - unset($read[$key]); - } - - // loop through all the clients that have data to read from - foreach ($read as $read_sock) { - // Get client data - socket_getpeername($read_sock, $ip); - - // read until newline or 1024 bytes - // socket_read while show errors when the client is disconnected, so silence the error messages - $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ); - - // check if the client is disconnected - if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) { - - // remove client for $clients array - $key = array_search($read_sock, $clients); - unset($clients[$key]); - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1).""); - - // Notify all chatter - if (count($clients) > 1) { - foreach ($clients as $send_sock) { - if ($send_sock != $mainSocket) { - socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n"); - } - } - } - - // continue to the next client to read from, if any - socket_write($read_sock, "Server: Good bye.\n"); - socket_shutdown($read_sock, 2); - socket_close($read_sock); - continue; - } elseif (in_array(trim($data), $shutdown)) { - // Is he allowed to shutdown? - if (!in_array($ip, $masters)) { - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!"); - socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n"); - $data = ""; - continue; - } - - // Close all connections a leave here - foreach ($clients as $client) { - // Send message to client - if ($client !== $mainSocket && $client != $read_sock) { - socket_write($client, "Server: Shutting down! Thank you for joining us.\n"); - } - - // Quit him - socket_shutdown($client, 2); - socket_close($client); - } // end foreach - - // Leave the loop - $data = ""; - $clients = array(); - continue; - } - - // trim off the trailing/beginning white spaces - $data = trim($data); - - // Test for HTML codes - $tags = strip_tags($data); - - // check if there is any data after trimming off the spaces - if (!empty($data) && $tags == $data && count($clients) > 2) { - // Send confirmation to "chatter" - socket_write($read_sock, "\nServer: Message accepted.\n"); - - // send this to all the clients in the $clients array (except the first one, which is a listening socket) - foreach ($clients as $send_sock) { - - // if its the listening sock or the client that we got the message from, go to the next one in the list - if ($send_sock == $mainSocket || $send_sock == $read_sock) - continue; - - // write the message to the client -- add a newline character to the end of the message - socket_write($send_sock, "{$ip}:{$data}\n"); - - } // end of broadcast foreach - } elseif ($tags != $data) { - // HTML codes are not allowed - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!"); - socket_write($read_sock, "Server: HTML is forbidden!\n"); - } elseif ((count($clients) == 2) && ($read_sock != $mainSocket)) { - // No one else will hear the "chatter" - out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself."); - socket_write($read_sock, "Server: No one will hear you!\n"); - } - } // end of reading foreach -} - -// close the listening socket -socket_close($mainSocket); - -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Listener extends BaseListener implements Listenable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance A NodeHelper instance - * @return $listenerInstance An instance a prepared listener class - */ - public final static function create???Listener (NodeHelper $nodeInstance) { - // Get new instance - $listenerInstance = new ???Listener(); - - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - * @todo 0% done - */ - public function initListener() { - $this->partialStub('Need to implement this method.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - * @todo 0% done - */ - public function doListen() { - $this->partialStub('Need to implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/tcp/class_TcpListener.php b/application/hub/main/listener/tcp/class_TcpListener.php deleted file mode 100644 index 7ef6a1f05..000000000 --- a/application/hub/main/listener/tcp/class_TcpListener.php +++ /dev/null @@ -1,342 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TcpListener extends BaseListener implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set the protocol to TCP - $this->setProtocolName('tcp'); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance A NodeHelper instance - * @return $listenerInstance An instance a prepared listener class - */ - public static final function createTcpListener (NodeHelper $nodeInstance) { - // Get new instance - $listenerInstance = new TcpListener(); - - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - * @throws InvalidSocketException Thrown if the socket could not be initialized - */ - public function initListener () { - // Create a streaming socket, of type TCP/IP - $mainSocket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - - // Is the socket resource valid? - if (!is_resource($mainSocket)) { - // Something bad happened - throw new InvalidSocketException(array($this, $mainSocket), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Get socket error code for verification - $socketError = socket_last_error($mainSocket); - - // Check if there was an error else - if ($socketError > 0) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Then throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - // Set the option to reuse the port - if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Get socket error code for verification - $socketError = socket_last_error($mainSocket); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // And throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - /* - * "Bind" the socket to the given address, on given port so this means - * that all connections on this port are now our resposibility to - * send/recv data, disconnect, etc.. - */ - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); - if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Get socket error code for verification - $socketError = socket_last_error($mainSocket); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // And throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - // Start listen for connections - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Listening for connections.'); - if (!socket_listen($mainSocket)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Get socket error code for verification - $socketError = socket_last_error($mainSocket); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // And throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - // Now, we want non-blocking mode - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting non-blocking mode.'); - if (!socket_set_nonblock($mainSocket)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Get socket error code for verification - $socketError = socket_last_error($mainSocket); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // And throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - // Set the main socket - $this->registerServerSocketResource($mainSocket); - - // Initialize the peer pool instance - $poolInstance = ObjectFactory::createObjectByConfiguredName('node_pool_class', array($this)); - - // Add main socket - $poolInstance->addPeer($mainSocket, BaseConnectionHelper::CONNECTION_TYPE_SERVER); - - // And add it to this listener - $this->setPoolInstance($poolInstance); - - // Initialize iterator for listening on packages - $iteratorInstance = ObjectFactory::createObjectByConfiguredName('network_listen_iterator_class', array($poolInstance->getPoolEntriesInstance())); - - // Rewind it and remember it in this class - $iteratorInstance->rewind(); - $this->setIteratorInstance($iteratorInstance); - - // Initialize the network package handler - $handlerInstance = ObjectFactory::createObjectByConfiguredName('tcp_raw_data_handler_class'); - - // Set it in this class - $this->setHandlerInstance($handlerInstance); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - * @throws InvalidSocketException If an invalid socket resource has been found - */ - public function doListen () { - // Get all readers - $readers = $this->getPoolInstance()->getAllSingleSockets(); - $writers = array(); - $excepts = array(); - - // Check if we have some peers left - $left = socket_select( - $readers, - $writers, - $excepts, - 0, - 150 - ); - - // Some new peers found? - if ($left < 1) { - // Debug message - //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE)); - - // Nothing new found - return; - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE)); - - // Do we have changed peers? - if (in_array($this->getSocketResource(), $readers)) { - /* - * Then accept it, if this socket is set to non-blocking IO and the - * connection is NOT sending any data, socket_read() may throw - * error 11 (Resource temporary unavailable). This really nasty - * because if you have blocking IO socket_read() will wait and wait - * and wait ... - */ - $newSocket = socket_accept($this->getSocketResource()); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',serverSocket=' .$this->getSocketResource()); - - // Array for timeout settings - $options = array( - // Seconds - 'sec' => $this->getConfigInstance()->getConfigEntry('tcp_socket_accept_wait_sec'), - // Milliseconds - 'usec' => $this->getConfigInstance()->getConfigEntry('tcp_socket_accept_wait_usec') - ); - - // Set timeout to configured seconds - // @TODO Does this work on Windozer boxes??? - if (!socket_set_option($newSocket, SOL_SOCKET, SO_RCVTIMEO, $options)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); - } // END - if - - // Output result (only for debugging!) - /* - $option = socket_get_option($newSocket, SOL_SOCKET, SO_RCVTIMEO); - self::createDebugInstance(__CLASS__)->debugOutput('SO_RCVTIMEO[' . gettype($option) . ']=' . print_r($option, TRUE)); - */ - - // Enable SO_OOBINLINE - if (!socket_set_option($newSocket, SOL_SOCKET, SO_OOBINLINE ,1)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); - } // END - if - - // Set non-blocking - if (!socket_set_nonblock($newSocket)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); - } // END - if - - // Add it to the peers - $this->getPoolInstance()->addPeer($newSocket, BaseConnectionHelper::CONNECTION_TYPE_INCOMING); - - // Get peer name - if (!socket_getpeername($newSocket, $peerName)) { - // Handle this socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $newSocket, array('0.0.0.0', '0')); - } // END - if - - // Get node instance - $nodeInstance = Registry::getRegistry()->getInstance('node'); - - // Create a faked package data array - $packageData = array( - NetworkPackage::PACKAGE_DATA_SENDER => $peerName . ':0', - NetworkPackage::PACKAGE_DATA_RECIPIENT => $nodeInstance->getSessionId(), - NetworkPackage::PACKAGE_DATA_STATUS => NetworkPackage::PACKAGE_STATUS_FAKED - ); - - // Get a connection info instance - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); - - // Will the info instance with listener data - $infoInstance->fillWithListenerInformation($this); - - // Get a socket registry - $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); - - // Register the socket with the registry and with the faked array - $registryInstance->registerSocket($infoInstance, $newSocket, $packageData); - } // END - if - - // Do we have to rewind? - if (!$this->getIteratorInstance()->valid()) { - // Rewind the list - $this->getIteratorInstance()->rewind(); - } // END - if - - // Get the current value - $currentSocket = $this->getIteratorInstance()->current(); - - // Handle it here, if not main server socket - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource()); - if (($currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] != BaseConnectionHelper::CONNECTION_TYPE_SERVER) && ($currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] != $this->getSocketResource())) { - // ... or else it will raise warnings like 'Transport endpoint is not connected' - $this->getHandlerInstance()->processRawDataFromResource($currentSocket); - } // END - if - - // Advance to next entry. This should be the last line. - $this->getIteratorInstance()->next(); - } - - /** - * Checks whether the listener would accept the given package data array - * - * @param $packageData Raw package data - * @return $accepts Whether this listener does accept - * @throws UnsupportedOperationException If this method is called - */ - public function ifListenerAcceptsPackageData (array $packageData) { - // Please don't call this - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/tcp/decorators/.htaccess b/application/hub/main/listener/tcp/decorators/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/listener/tcp/decorators/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php b/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php deleted file mode 100644 index 2df0959a8..000000000 --- a/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ClientTcpListenerDecorator extends BaseListenerDecorator implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set listener type and protocol name - $this->setListenerType('peer'); - $this->setProtocolName('tcp'); - } - - /** - * Creates an instance of this class - * - * @param $listenerInstance A Listener instance - * @return $decoratorInstance An instance a prepared listener decorator class - */ - public static final function createClientTcpListenerDecorator (Listenable $listenerInstance) { - // Get new instance - $decoratorInstance = new ClientTcpListenerDecorator(); - - // Set the application instance - $decoratorInstance->setListenerInstance($listenerInstance); - - // Return the prepared instance - return $decoratorInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - */ - public function initListener () { - $this->partialStub('WARNING: This method should not be called.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - */ - public function doListen () { - // Handle generic TCP package - $this->getListenerInstance()->doListen(); - - // Handle peer TCP package - $this->partialStub('Need to handle peer TCP package.'); - } - - /** - * Checks whether the listener would accept the given package data array - * - * @param $packageData Raw package data - * @return $accepts Whether this listener does accept - */ - public function ifListenerAcceptsPackageData (array $packageData) { - // Get a tags instance - $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); - - // So is the package accepted with this listener? - $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); - - // Return the result - return $accepts; - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php b/application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php deleted file mode 100644 index 1f2532cf9..000000000 --- a/application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubTcpListenerDecorator extends BaseListenerDecorator implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set listener type and protocol name - $this->setListenerType('hub'); - $this->setProtocolName('tcp'); - } - - /** - * Creates an instance of this class - * - * @param $listenerInstance A Listener instance - * @return $decoratorInstance An instance a prepared listener decorator class - */ - public static final function createHubTcpListenerDecorator (Listenable $listenerInstance) { - // Get new instance - $decoratorInstance = new HubTcpListenerDecorator(); - - // Set the application instance - $decoratorInstance->setListenerInstance($listenerInstance); - - // Return the prepared instance - return $decoratorInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - */ - public function initListener () { - $this->partialStub('WARNING: This method should not be called.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - */ - public function doListen () { - // Handle generic TCP package - $this->getListenerInstance()->doListen(); - - // Handle hub TCP package - $this->partialStub('Need to handle hub TCP package.'); - } - - /** - * Checks whether the listener would accept the given package data array - * - * @param $packageData Raw package data - * @return $accepts Whether this listener does accept - */ - public function ifListenerAcceptsPackageData (array $packageData) { - // Get a tags instance - $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); - - // So is the package accepted with this listener? - $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); - - // Return the result - return $accepts; - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/udp/.htaccess b/application/hub/main/listener/udp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/listener/udp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/listener/udp/class_ b/application/hub/main/listener/udp/class_ deleted file mode 100644 index 8be5d3893..000000000 --- a/application/hub/main/listener/udp/class_ +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Udp???Listener extends BaseListener implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance A NodeHelper instance - * @return $listenerInstance An instance a prepared listener class - */ - public final static function createUdp???Listener (NodeHelper $nodeInstance) { - // Get new instance - $listenerInstance = new Udp???Listener(); - - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - * @todo 0% done - */ - public function initListener() { - $this->partialStub('Need to implement this method.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - * @todo 0% done - */ - public function doListen() { - $this->partialStub('Need to implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/udp/class_UdpListener.php b/application/hub/main/listener/udp/class_UdpListener.php deleted file mode 100644 index a9c9d51de..000000000 --- a/application/hub/main/listener/udp/class_UdpListener.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UdpListener extends BaseListener implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set the protocol to UDP - $this->setProtocolName('udp'); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance A NodeHelper instance - * @return $listenerInstance An instance a prepared listener class - */ - public static final function createUdpListener (NodeHelper $nodeInstance) { - // Get new instance - $listenerInstance = new UdpListener(); - - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - * @throws InvalidSocketException Thrown if the socket is invalid or an - * error was detected. - */ - public function initListener () { - // Try to open a UDP socket - $mainSocket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - - // Is the socket a valid resource or do we have any error? - if (!is_resource($mainSocket)) { - // Then throw an InvalidSocketException - throw new InvalidSocketException(array($this, $mainSocket), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - /* - * "Bind" the socket to the given address, on given port so this means - * that all connections on this port are now our resposibility to - * send/recv data, disconnect, etc.. - */ - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort()); - if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) { - // Handle the socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Get socket error code for verification - $socketError = socket_last_error($mainSocket); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // And throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - // Now, we want non-blocking mode - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting non-blocking mode.'); - if (!socket_set_nonblock($mainSocket)) { - // Handle the socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Get socket error code for verification - $socketError = socket_last_error($socket); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // And throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - // Set the option to reuse the port - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting re-use address option.'); - if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) { - // Handle the socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0')); - /* - // Get socket error code for verification - $socketError = socket_last_error($mainSocket); - - // Get error message - $errorMessage = socket_strerror($socketError); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // And throw again - throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - - // Remember the socket in our class - $this->registerServerSocketResource($mainSocket); - - // Initialize the network package handler - $handlerInstance = ObjectFactory::createObjectByConfiguredName('udp_raw_data_handler_class'); - - // Set it in this class - $this->setHandlerInstance($handlerInstance); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - * @todo ~50% done - */ - public function doListen() { - // Read a package and determine the peer - $amount = @socket_recvfrom($this->getSocketResource(), $rawData, $this->getConfigInstance()->getConfigEntry('udp_buffer_length'), MSG_DONTWAIT, $peer, $port); - - // Get last error - $lastError = socket_last_error($this->getSocketResource()); - - // Do we have an error at the line? - if ($lastError == 11) { - /* - * This (resource temporary unavailable) can be safely ignored on - * "listening" UDP ports. If we don't clear the error here, our UDP - * "listener" won't read any packages except if the UDP sender - * starts the transmission before this "listener" came up... - */ - socket_clear_error($this->getSocketResource()); - - // Skip further processing - return; - } elseif ($lastError > 0) { - // Other error detected - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Error detected: ' . socket_strerror($lastError)); - - // Skip further processing - return; - } elseif ((empty($rawData)) || (trim($peer) == '')) { - // Zero sized packages/peer names are usual in non-blocking mode - return; - } // END - if - - // Debug only - self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port); - } - - /** - * Checks whether the listener would accept the given package data array - * - * @param $packageData Raw package data - * @return $accepts Whether this listener does accept - */ - function ifListenerAcceptsPackageData (array $packageData) { - $this->partialStub('This call should not happen. Please report it.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/udp/decorators/.htaccess b/application/hub/main/listener/udp/decorators/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/listener/udp/decorators/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php b/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php deleted file mode 100644 index 7393cbfb8..000000000 --- a/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ClientUdpListenerDecorator extends BaseListenerDecorator implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set listener type and protocol name - $this->setListenerType('peer'); - $this->setProtocolName('udp'); - } - - /** - * Creates an instance of this class - * - * @param $listenerInstance A Listener instance - * @return $decoratorInstance An instance a prepared listener decorator class - */ - public static final function createClientUdpListenerDecorator (Listenable $listenerInstance) { - // Get new instance - $decoratorInstance = new ClientUdpListenerDecorator(); - - // Set the application instance - $decoratorInstance->setListenerInstance($listenerInstance); - - // Return the prepared instance - return $decoratorInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - */ - public function initListener () { - $this->partialStub('WARNING: This method should not be called.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - */ - public function doListen () { - // Handle generic UDP packages first - $this->getListenerInstance()->doListen(); - - // Handle this peer UDP package - $this->partialStub('Need to handle peer UDP package.'); - } - - /** - * Checks whether the listener would accept the given package data array - * - * @param $packageData Raw package data - * @return $accepts Whether this listener does accept - */ - function ifListenerAcceptsPackageData (array $packageData) { - // Get a tags instance - $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); - - // So is the package accepted with this listener? - $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); - - // Return the result - return $accepts; - } -} - -// [EOF] -?> diff --git a/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php b/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php deleted file mode 100644 index 141e7c880..000000000 --- a/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubUdpListenerDecorator extends BaseListenerDecorator implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set listener type and protocol name - $this->setListenerType('hub'); - $this->setProtocolName('udp'); - } - - /** - * Creates an instance of this class - * - * @param $listenerInstance A Listener instance - * @return $decoratorInstance An instance a prepared listener decorator class - */ - public static final function createHubUdpListenerDecorator (Listenable $listenerInstance) { - // Get new instance - $decoratorInstance = new HubUdpListenerDecorator(); - - // Set the application instance - $decoratorInstance->setListenerInstance($listenerInstance); - - // Return the prepared instance - return $decoratorInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - */ - public function initListener () { - $this->partialStub('WARNING: This method should not be called.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - */ - public function doListen () { - // Handle generic UDP package first - $this->getListenerInstance()->doListen(); - - // Handle hub UDP package - $this->partialStub('Need to handle hub UDP package.'); - } - - /** - * Checks whether the listener would accept the given package data array - * - * @param $packageData Raw package data - * @return $accepts Whether this listener does accept - */ - public function ifListenerAcceptsPackageData (array $packageData) { - // Get a tags instance - $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); - - // So is the package accepted with this listener? - $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); - - // Return the result - return $accepts; - } -} - -// [EOF] -?> diff --git a/application/hub/main/lists/.htaccess b/application/hub/main/lists/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lists/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/lists/hub/.htaccess b/application/hub/main/lists/hub/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lists/hub/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/lists/hub/class_HubList.php b/application/hub/main/lists/hub/class_HubList.php deleted file mode 100644 index efe935f6f..000000000 --- a/application/hub/main/lists/hub/class_HubList.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubList extends BaseList implements Listable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $listInstance An instance a Listable class - */ - public static final function createHubList () { - // Get new instance - $listInstance = new HubList(); - - // Add groups for e.g. connected/disconnected hubs - $listInstance->addGroup('connected'); - $listInstance->addGroup('disconnected'); - - // Return the prepared instance - return $listInstance; - } - - /** - * "Getter" for an iterator instance of this list (not implemented) - * - * @return $iteratorInstance An instance of a Iterator class - */ - public function getListIterator () { - $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); - } - - /** - * Clears this list by cleaning up all groups together. - * - * @return void - */ - public function clearList () { - // Clear both groups together - $this->clearGroups(array('connected', 'disconnected')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/lists/pool/.htaccess b/application/hub/main/lists/pool/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lists/pool/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/lists/pool/class_PoolEntriesList.php b/application/hub/main/lists/pool/class_PoolEntriesList.php deleted file mode 100644 index 41e29f8b6..000000000 --- a/application/hub/main/lists/pool/class_PoolEntriesList.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PoolEntriesList extends BaseList implements Listable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $listInstance An instance a Listable class - */ - public static final function createPoolEntriesList () { - // Get new instance - $listInstance = new PoolEntriesList(); - - // Add 'pool' group - $listInstance->addGroup('pool'); - - // Return the prepared instance - return $listInstance; - } - - /** - * "Getter" for an iterator instance of this list - * - * @return $iteratorInstance An instance of a Iterator class - */ - public function getListIterator () { - // Get the iterator instance from the factory - $iteratorInstance = ObjectFactory::createObjectByConfiguredName('node_ping_iterator_class', array($this)); - - // Rewind it - $iteratorInstance->rewind(); - - // ... and return it - return $iteratorInstance; - } - - /** - * Clears this list by cleaning up all groups together. - * - * @return void - */ - public function clearList () { - // Clear the only one group - $this->clearGroup('pool'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/lists/query/.htaccess b/application/hub/main/lists/query/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lists/query/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/lists/query/local/.htaccess b/application/hub/main/lists/query/local/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lists/query/local/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/lists/recipient/.htaccess b/application/hub/main/lists/recipient/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lists/recipient/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/lists/recipient/class_RecipientList.php b/application/hub/main/lists/recipient/class_RecipientList.php deleted file mode 100644 index a8ac4e916..000000000 --- a/application/hub/main/lists/recipient/class_RecipientList.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RecipientList extends BaseList implements Listable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $listInstance An instance a Listable class - */ - public static final function createRecipientList () { - // Get new instance - $listInstance = new RecipientList(); - - // Add groups: - // 1.) Universal Node Locators - $listInstance->addGroup('unl'); - - // 2.) Session ids - $listInstance->addGroup('session_id'); - - // Return the prepared instance - return $listInstance; - } - - /** - * "Getter" for an iterator instance of this list (not implemented) - * - * @return $iteratorInstance An instance of a Iterator class - */ - public function getListIterator () { - $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); - } - - /** - * Clears this list by cleaning up all groups together. - * - * @return void - */ - public function clearList () { - // Clear both groups - $this->clearGroups(array('unl', 'session_id')); - } -} - -// [EOF] -?> diff --git a/application/hub/main/lookup/.htaccess b/application/hub/main/lookup/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lookup/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/lookup/class_ b/application/hub/main/lookup/class_ deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/lookup/class_ +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/lookup/peer/.htaccess b/application/hub/main/lookup/peer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/lookup/peer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/miner/.htaccess b/application/hub/main/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/miner/chash/.htaccess b/application/hub/main/miner/chash/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/miner/chash/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/miner/chash/class_HubCoinMiner.php b/application/hub/main/miner/chash/class_HubCoinMiner.php deleted file mode 100644 index 2b9ddb1d7..000000000 --- a/application/hub/main/miner/chash/class_HubCoinMiner.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubCoinMiner extends BaseHubMiner implements MinerHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set version number - $this->setVersion('0.0.0'); - } - - /** - * Creates an instance of this hub-miner class - * - * @return $minerInstance An instance of this hub-miner class - */ - public final static function createHubCoinMiner () { - // Get a new instance - $minerInstance = new HubCoinMiner(); - - // Return the instance - return $minerInstance; - } - - /** - * This method fills the in-buffer with (a) test unit(s) which are mainly - * used for development of the crunching part. They must be enabled in - * configuration, or else your miner runs out of WUs and waits for more - * to show up. - * - * In this method we already know that the in-buffer is going depleted so - * no need to double-check it here. - * - * @return void - */ - protected function fillInBufferQueueWithTestUnits () { - // Are test units enabled? - if ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'N') { - // They are disabled, so skip any further steps - return; - } elseif ($this->getStateInstance()->isMinerStateVirgin()) { - // No virgin miners please, because they usually have no test units ready for crunching - return; - } - - // Get a test-unit generator instance - $generatorInstance = ObjectFactory::createObjectByConfiguredName('miner_test_unit_generator_class'); - - // We don't need an iterator here because we just need to generate some test units - for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('miner_max_text_unit_amount'); $idx++) { - // Get a test unit from it - $unitInstance = $generatorInstance->generateNextUnitInstance(); - - // ... and finally queue it to the in-buffer queue - $this->queueUnitInstanceToInBuffer($unitInstance); - } // END - for - } - - /** - * This method fills the in-buffer with (real) WUs which will be crunched - * and the result be sent back to the key producer instance. - * - * @return void - */ - protected function fillInBufferQueueWithWorkUnits () { - // This miner's state must not be one of these: 'virgin' - if ($this->getStateInstance()->isMinerStateVirgin()) { - // We can silently skip here, until the generation is finished - return; - } // END - if - - // @TODO Implement this method - $this->partialStub('Please implement this method.'); - } - - /** - * Method to "bootstrap" the miner. This step does also apply provided - * command-line arguments stored in the request instance. No buffer queue - * will be initialized here, we only do "general" things here. - * - * @return void - * @todo Implement this method - */ - public function doBootstrapping () { - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - // Output all lines - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('Hubcoin miner v' . $this->getVersion() . ' is starting ...'); - self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2014 Miner Developer Team'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); - self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); - self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - } - - /** - * Add some miner-specific filters - * - * @param $controllerInstance An object of a Controller instance - * @param $responseInstance An object of a Responseable instance - * @return void - * @todo 0% done - */ - public function addExtraFilters (Controller $controllerInstance, Responseable $responseInstance) { - // Add some filters here - $this->partialStub('Please add some miner-specific filters, if required.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/miner/class_ b/application/hub/main/miner/class_ deleted file mode 100644 index 090621d91..000000000 --- a/application/hub/main/miner/class_ +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Hub???Miner extends BaseHubMiner implements MinerHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set version number - $this->setVersion('x.x'); - } - - /** - * Creates an instance of this hub-miner class - * - * @param $requestInstance An instance of a Requestable class - * @return $minerInstance An instance of this hub-miner class - */ - public final static function createHub???Miner (Requestable $requestInstance) { - // Get a new instance - $minerInstance = new Hub???Miner(); - - // Set the request instance - $minerInstance->setRequestInstance($requestInstance); - - // Return the instance - return $minerInstance; - } - - /** - * Method to "bootstrap" the miner. This step does also apply provided - * command-line arguments stored in the request instance. The regular miner - * should communicate with the bootstrap-miners at this point. - * - * @return void - * @todo Implement this method - */ - public function doBootstrapping () { - // Call generic (parent) bootstrapping method first - parent::doGenericBootstrapping(); - $this->partialStub('Please implement this method.'); - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - $this->partialStub('Please implement this method.'); - } - - /** - * Add some miner-specific filters - * - * @return void - */ - public function addExtraHubFilters () { - // Add some filters here - } -} - -// [EOF] -?> diff --git a/application/hub/main/miner/class_BaseHubMiner.php b/application/hub/main/miner/class_BaseHubMiner.php deleted file mode 100644 index ecdfaa459..000000000 --- a/application/hub/main/miner/class_BaseHubMiner.php +++ /dev/null @@ -1,244 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseHubMiner extends BaseHubSystem implements Updateable { - /** - * Version information - */ - private $version = 'x.x'; - - /** - * By default no miner is active - */ - private $isActive = FALSE; - - /** - * All buffer queue instances (a FIFO) - */ - private $bufferInstance = NULL; - - /** - * An array for initialized producers - */ - private $producersInitialized = array(); - - /** - * Stacker name for incoming queue - */ - const STACKER_NAME_IN_QUEUE = 'in_queue'; - - /** - * Stacker name for outcoming queue - */ - const STACKER_NAME_OUT_QUEUE = 'out_queue'; - - /** - * Maximum number of producers (2: test and real) - */ - const MAX_PRODUCERS = 2; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init this miner - $this->initMiner(); - } - - /** - * Initialize the miner generically - * - * @return void - */ - private function initMiner () { - // Add own instance to registry - Registry::getRegistry()->addInstance('miner', $this); - - // Init the state - MinerStateFactory::createMinerStateInstanceByName('init'); - } - - /** - * Getter for version - * - * @return $version Version number of this miner - */ - protected final function getVersion () { - return $this->version; - } - - /** - * Setter for version - * - * @param $version Version number of this miner - * @return void - */ - protected final function setVersion ($version) { - $this->version = (string) $version; - } - - /** - * Checks whether the in-buffer queue is filled by comparing it's current - * amount of entries against a threshold. - * - * @return $isFilled Whether the in-buffer is filled - */ - protected function isInBufferQueueFilled () { - // Determine it - $isFilled = ($this->bufferInstance->getStackCount(self::STACKER_NAME_IN_QUEUE) > $this->getConfigInstance()->getConfigEntry('miner_in_buffer_min_threshold')); - - // And return the result - return $isFilled; - } - - /** - * This method fills the in-buffer with (a) test unit(s) which are mainly - * used for development of the crunching part. They must be enabled in - * configuration, or else your miner runs out of WUs and waits for more - * to show up. - * - * In this method we already know that the in-buffer is going depleted so - * no need to double-check it here. - * - * @return void - */ - abstract protected function fillInBufferQueueWithTestUnits (); - - /** - * This method fills the in-buffer with (real) WUs which will be crunched - * and the result be sent back to the key producer instance. - * - * @return void - */ - abstract protected function fillInBufferQueueWithWorkUnits (); - - /** - * Enables/disables the miner (just sets a flag) - * - * @param $version Version number of this miner - * @return void - */ - public final function enableIsActive ($isActive = TRUE) { - $this->isActive = (bool) $isActive; - } - - /** - * Determines whether the miner is active - * - * @return $isActive Whether the miner is active - */ - public final function isActive () { - return $this->isActive; - } - - /** - * Initializes all buffer queues (mostly in/out). This method is demanded - * by the MinerHelper interface. - * - * @return void - */ - public function initBufferQueues () { - /* - * Initialize both buffer queues, we can use the FIFO class here - * directly and encapsulate its method calls with protected methods. - */ - $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('miner_buffer_stacker_class'); - - // Initialize common stackers, like in/out - $this->bufferInstance->initStacks(array( - self::STACKER_NAME_IN_QUEUE, - self::STACKER_NAME_OUT_QUEUE - )); - - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('MINER: All buffers are now initialized.'); - } - - /** - * This method determines if the in-buffer is going to depleted and if so, - * it fetches more WUs from the network. If no WU can be fetched from the - * network and if enabled, a random test WU is being generated. - * - * This method is demanded from the MinerHelper interface. - * - * @return void - */ - public function doFetchWorkUnits () { - // Simply check if we have enough WUs left in the in-buffer queue (a FIFO) - if (!$this->isInBufferQueueFilled()) { - // The in-buffer queue needs filling, so head out and get some work - $this->fillInBufferQueueWithWorkUnits(); - - // Is the buffer still not filled and are test-packages allowed? - if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('miner_test_units_enabled') == 'Y')) { - // Then fill the in-buffer with (one) test-unit(s) - $this->fillInBufferQueueWithTestUnits(); - } // END - if - } // END - if - } - - /** - * Updates a given field with new value - * - * @param $fieldName Field to update - * @param $fieldValue New value to store - * @return void - * @throws DatabaseUpdateSupportException If this class does not support database updates - * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem - */ - public function updateDatabaseField ($fieldName, $fieldValue) { - // Unfinished - $this->partialStub('Unfinished!'); - return; - } - - /** - * Changes the state to 'booting' and shall be called after the block - * producer has been initialized. - * - * @param $producerInstance An instance of a BlockProducer class - * @return void - */ - public function blockProducerHasInitialized (BlockProducer $producerInstance) { - // Make sure the state is correct ('init') - $this->getStateInstance()->validateMinerStateIsInit(); - - // Mark given producer as initialized - $this->producersInitialized[$producerInstance->__toString()] = TRUE; - - // Has all producers been initialized? - if (count($this->producersInitialized) == self::MAX_PRODUCERS) { - // Change it to 'booting' - MinerStateFactory::createMinerStateInstanceByName('booting'); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/nodes/.htaccess b/application/hub/main/nodes/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/nodes/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/nodes/boot/.htaccess b/application/hub/main/nodes/boot/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/nodes/boot/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/nodes/boot/class_HubBootNode.php b/application/hub/main/nodes/boot/class_HubBootNode.php deleted file mode 100644 index 62342384d..000000000 --- a/application/hub/main/nodes/boot/class_HubBootNode.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubBootNode extends BaseHubNode implements NodeHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this hub-node class - * - * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class - */ - public static final function createHubBootNode (Requestable $requestInstance) { - // Get a new instance - $nodeInstance = new HubBootNode(); - - // Set the request instance - $nodeInstance->setRequestInstance($requestInstance); - - // Return the instance - return $nodeInstance; - } - - /** - * Method to "bootstrap" the node. This step does also apply provided - * command-line arguments stored in the request instance. The regular node - * should communicate with the bootstrap-nodes at this point. - * - * @return void - * @todo add some more special bootstrap things for this boot node - */ - public function doBootstrapping () { - // Get UNL - $unl = $this->detectOwnUniversalNodeLocator(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl); - - // Now check if the IP address matches one of the bootstrap nodes - if ($this->ifAddressMatchesBootstrapNodes($unl)) { - // Get our port from configuration - $ourPort = $this->getConfigInstance()->getConfigEntry('node_listen_port'); - - // Extract port - $bootPort = substr($this->getBootUniversalNodeLocator(), -strlen($ourPort), strlen($ourPort)); - - // Is the port the same? - if ($bootPort == $ourPort) { - // It is the same! - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: UNL matches bootstrap node ' . $this->getBootUniversalNodeLocator() . '.'); - - // Now, does the mode match - if ($this->getRequestInstance()->getRequestElement('mode') == self::NODE_TYPE_BOOT) { - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Our node is a valid bootstrap node.'); - } else { - // Output warning - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Mismatching mode ' . $this->getRequestInstance()->getRequestElement('mode') . '!=' . BaseHubNode::NODE_TYPE_BOOT . ' detected.'); - } - } else { - // IP does match, but no port - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our UNL ' . $unl . ' does match a known bootstrap-node but not the port ' . $ourPort . '/' . $bootPort . '.'); - } - } else { - // Node does not match any know bootstrap-node - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our UNL ' . $unl . ' does not match any known bootstrap-nodes.'); - } - - // Enable acceptance of announcements - $this->enableAcceptingAnnouncements(); - - // This might not be all... - $this->partialStub('Please implement more bootsrapping steps.'); - } - - /** - * Add some node-specific filters - * - * @return void - */ - public function addExtraNodeFilters () { - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Get the controller from the application - $controllerInstance = $applicationInstance->getControllerInstance(); - - // @TODO Add some filters here - $this->partialStub('Add some filters here.'); - } - - /** - * Adds extra tasks to the given handler for this node - * - * @param $handlerInstance An instance of a HandleableTask class - * @return void - */ - public function addExtraTasks (HandleableTask $handlerInstance) { - // Prepare a task for booting the DHT - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_bootstrap_task_class'); - - // Register it - $handlerInstance->registerTask('dht_bootstrap', $taskInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/nodes/class b/application/hub/main/nodes/class deleted file mode 100644 index 24dbb9808..000000000 --- a/application/hub/main/nodes/class +++ /dev/null @@ -1,11 +0,0 @@ - - /** - * Adds extra tasks to the given handler for this node - * - * @param $handlerInstance An instance of a HandleableTask class - * @return void - * @todo 0% done - */ - public function addExtraTasks (HandleableTask $handlerInstance) { - $this->partialStub('Please add some tasks or empty this method.'); - } diff --git a/application/hub/main/nodes/class_ b/application/hub/main/nodes/class_ deleted file mode 100644 index 9514e1fff..000000000 --- a/application/hub/main/nodes/class_ +++ /dev/null @@ -1,98 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Hub???Node extends BaseHubNode implements NodeHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this hub-node class - * - * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class - */ - public final static function createHub???Node (Requestable $requestInstance) { - // Get a new instance - $nodeInstance = new Hub???Node(); - - // Set the request instance - $nodeInstance->setRequestInstance($requestInstance); - - // Return the instance - return $nodeInstance; - } - - /** - * Method to "bootstrap" the node. This step does also apply provided - * command-line arguments stored in the request instance. The regular node - * should communicate with the bootstrap-nodes at this point. - * - * @return void - * @todo Implement this method - */ - public function doBootstrapping () { - // Call generic (parent) bootstrapping method first - parent::doGenericBootstrapping(); - $this->partialStub('Please implement this method.'); - } - - /** - * Initializes hub-specific queues - * - * @return void - * @todo Implement this method - */ - public function initQueues () { - $this->partialStub('Please implement this method.'); - } - - /** - * Add some node-specific filters - * - * @return void - */ - public function addExtraHubFilters () { - // Add some filters here - } - - /** - * Adds extra tasks to the given handler for this node - * - * @param $handlerInstance An instance of a HandleableTask class - * @return void - * @todo 0% done - */ - public function addExtraTasks (HandleableTask $handlerInstance) { - $this->partialStub('Please add some tasks or empty this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php deleted file mode 100644 index 1dff70eea..000000000 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ /dev/null @@ -1,834 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { - /** - * Node types - */ - const NODE_TYPE_BOOT = 'boot'; - const NODE_TYPE_MASTER = 'master'; - const NODE_TYPE_LIST = 'list'; - const NODE_TYPE_REGULAR = 'regular'; - - // Exception constants - const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00; - - // Other constants - const OBJECT_LIST_SEPARATOR = ','; - - /** - * Universal node locator of bootstrap node - */ - private $bootUnl = ''; - - /** - * Whether this node is anncounced (keep on FALSE!) - * @deprecated - */ - private $hubIsAnnounced = FALSE; - - /** - * Whether this hub is active (default: FALSE) - */ - private $isActive = FALSE; - - /** - * Whether this node accepts announcements (default: FALSE) - */ - private $acceptAnnouncements = FALSE; - - /** - * Whether this node accepts DHT bootstrap requests (default: FALSE) - */ - private $acceptDhtBootstrap = FALSE; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_info_db_wrapper_class'); - - // Set it here - $this->setWrapperInstance($wrapperInstance); - - // Get a crypto instance - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - - // Set it here - $this->setCryptoInstance($cryptoInstance); - - // Set the node instance in registry - Registry::getRegistry()->addInstance('node', $this); - - // Init state which sets the state to 'init' - $this->initState(); - } - - /** - * Initializes the node's state which sets it to 'init' - * - * @return void - */ - private function initState() { - // Get the state factory and create the initial state. - NodeStateFactory::createNodeStateInstanceByName('init'); - } - - /** - * Generates a private key and hashes it (for speeding up things) - * - * @param $searchInstance An instance of a LocalSearchCriteria class - * @return void - */ - private function generatePrivateKeyAndHash (LocalSearchCriteria $searchInstance) { - // Get an RNG instance - $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); - - // Generate a pseudo-random string - $randomString = $rngInstance->randomString(255); - - // Hash and encrypt the string so we become a node id (also documented as "hub id") - $this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString)); - $this->setPrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey())); - - // Register the node id with our wrapper - $this->getWrapperInstance()->registerPrivateKey($this, $this->getRequestInstance(), $searchInstance); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . ''); - } - - /** - * Generates a random string from various data inluding UUID if PECL - * extension uuid is installed. - * - * @param $length Length of the random part - * @return $randomString Random string - * @todo Make this code more generic and move it to CryptoHelper or - */ - protected function generateRamdomString ($length) { - // Get an RNG instance - $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); - - // Generate a pseudo-random string - $randomString = $rngInstance->randomString($length) . ':' . $this->getBootUniversalNodeLocator() . ':' . $this->getRequestInstance()->getRequestElement('mode'); - - // Add UUID for even more entropy for the hasher - $randomString .= $this->getCryptoInstance()->createUuid(); - - // Return it - return $randomString; - } - - /** - * Getter for boot UNL (Universal Node Locator) - * - * @return $bootUnl The UNL (Universal Node Locator) of the boot node - */ - protected final function getBootUniversalNodeLocator () { - return $this->bootUnl; - } - - /** - * Checks whether the given IP address matches one of the bootstrap nodes - * - * @param $remoteAddr IP address to checkout against our bootstrapping list - * @return $isFound Whether the IP is found - */ - protected function ifAddressMatchesBootstrapNodes ($remoteAddr) { - // By default nothing is found - $isFound = FALSE; - - // Run through all configured IPs - foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) { - // Does it match? - if ($unl == $remoteAddr) { - // Found it! - $isFound = TRUE; - - // Remember the UNL - $this->bootUnl = $unl; - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: UNL matches remote address ' . $unl . '.'); - - // Stop further searching - break; - } elseif ($unl == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) { - /* - * IP matches listen address. At this point we really don't care - * if we can really listen on that address - */ - $isFound = TRUE; - - // Remember the port number - $this->bootUnl = $unl; - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: UNL matches listen address ' . $unl . '.'); - - // Stop further searching - break; - } - } // END - foreach - - // Return the result - return $isFound; - } - - /** - * Tries to detect own UNL (Universal Node Locator) - * - * @return $unl Node's own universal node locator - */ - public function detectOwnUniversalNodeLocator () { - // Is "cache" set? - if (!isset($GLOBALS[__METHOD__])) { - // Get the UNL array back - $unlData = $this->getUniversalNodeLocatorArray(); - - // There are 2 UNLs, internal and external. - if ($this->getConfigInstance()->getConfigEntry('allow_publish_internal_address') == 'N') { - // Public "external" UNL address - $GLOBALS[__METHOD__] = $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]; - } else { - // Non-public "internal" UNL address - $GLOBALS[__METHOD__] = $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL]; - } - } // END - if - - // Return it - return $GLOBALS[__METHOD__]; - } - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - public function outputConsoleTeaser () { - // Get the app instance (for shortening our code) - $app = $this->getApplicationInstance(); - - // Output all lines - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' mode active'); - self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.'); - self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain'); - self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.'); - self::createDebugInstance(__CLASS__)->debugOutput(' '); - } - - /** - * Generic method to acquire a hub-id. On first run this generates a new one - * based on many pseudo-random data. On any later run, unless the id - * got not removed from database, it will be restored from the database. - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance) { - // Is there a node id? - if ($this->getWrapperInstance()->ifNodeDataIsFound($this)) { - // Get the node id from result and set it - $this->setNodeId($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID)); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . ''); - } else { - // Get an RNG instance - $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); - - // Generate a pseudo-random string - $randomString = $rngInstance->randomString(255); - - // Hash and encrypt the string so we become a node id (also documented as "hub id") - $this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString))); - - // Register the node id with our wrapper - $this->getWrapperInstance()->registerNodeId($this, $this->getRequestInstance()); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . ''); - } - } - - /** - * Generates a session id which will be sent to the other hubs and peers - * - * @return void - */ - public function bootstrapGenerateSessionId () { - // Now get a search criteria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Search for the node number one which is hard-coded the default - $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1); - $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $this->getRequestInstance()->getRequestElement('mode')); - $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID , $this->getNodeId()); - $searchInstance->setLimit(1); - - // Remember it for later usage - $this->setSearchInstance($searchInstance); - - // Get a random string - $randomString = $this->generateRamdomString(255); - - // Hash and encrypt the string so we become a "node id" aka Hub-Id - $this->setSessionId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString))); - - // Register the node id with our wrapper - $this->getWrapperInstance()->registerSessionId($this, $this->getRequestInstance(), $searchInstance); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . ''); - - // Change the state because the node has aquired a session id - $this->getStateInstance()->nodeGeneratedSessionId(); - } - - /** - * Generate a private key for en-/decryption - * - * @return void - */ - public function bootstrapGeneratePrivateKey () { - // Is it valid? - if ($this->getWrapperInstance()->ifNodeDataIsFound($this)) { - // Is the element set? - if (is_null($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY))) { - /* - * Auto-generate the private key for e.g. out-dated database - * "tables". This allows a smooth update for the underlaying - * database table. - */ - $this->generatePrivateKeyAndHash($this->getSearchInstance()); - } else { - // Get the node id from result and set it - $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY))); - $this->setPrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH)); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Re-using found private key hash: ' . $this->getPrivateKeyHash() . ''); - } - } else { - /* - * Generate it in a private method (no confusion with 'private - * method access' and 'private key' here! ;-)). - */ - $this->generatePrivateKeyAndHash($this->getSearchInstance()); - } - } - - /** - * Adds hub data elements to a given dataset instance - * - * @param $criteriaInstance An instance of a storeable criteria - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { - // Make sure the request instance is set as it is not optional. - assert($requestInstance instanceof Requestable); - - // Add node number and type - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1); - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $requestInstance->getRequestElement('mode')); - - // Add the node id - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId()); - - // Add the session id if acquired - if ($this->getSessionId() != '') { - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId()); - } // END - if - - // Add the private key if acquired - if ($this->getPrivateKey() != '') { - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey())); - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash()); - } // END - if - - // Add own external and internal addresses as UNLs - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, HubTools::determineOwnInternalAddress()); - $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, HubTools::determineOwnExternalAddress()); - } - - /** - * Updates a given field with new value - * - * @param $fieldName Field to update - * @param $fieldValue New value to store - * @return void - * @throws DatabaseUpdateSupportException If this class does not support database updates - * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem - */ - public function updateDatabaseField ($fieldName, $fieldValue) { - // Unfinished - $this->partialStub('Unfinished!'); - return; - - // Get a critieria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add search criteria - $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); - $searchInstance->setLimit(1); - - // Now get another criteria - $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); - - // Add criteria entry which we shall update - $updateInstance->addCriteria($fieldName, $fieldValue); - - // Add the search criteria for searching for the right entry - $updateInstance->setSearchInstance($searchInstance); - - // Set wrapper class name - $updateInstance->setWrapperConfigEntry('user_db_wrapper_class'); - - // Remember the update in database result - $this->getResultInstance()->add2UpdateQueue($updateInstance); - } - - /** - * Announces this hub to the upper (bootstrap or list) hubs. After this is - * successfully done the given task is unregistered from the handler. This - * might look a bit overloaded here but the announcement phase isn't a - * simple "Hello there" message, it may later on also contain more - * informations like the object list. - * - * @param $taskInstance The task instance running this announcement - * @return void - * @throws NodeAlreadyAnnouncedException If this hub is already announced - * @todo Change the first if() block to check for a specific state - */ - public function announceToUpperNodes (Taskable $taskInstance) { - // Is this hub node announced? - if ($this->hubIsAnnounced === TRUE) { - // Already announced! - throw new NodeAlreadyAnnouncedException($this, self::EXCEPTION_HUB_ALREADY_ANNOUNCED); - } // END - if - - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('HUB-Announcement: START (taskInstance=' . $taskInstance->__toString(). ')'); - - // Get a helper instance - $helperInstance = ObjectFactory::createObjectByConfiguredName('node_announcement_helper_class'); - - // Load the announcement descriptor - $helperInstance->loadDescriptorXml($this); - - // Compile all variables - $helperInstance->getTemplateInstance()->compileConfigInVariables(); - - // "Publish" the descriptor by sending it to the bootstrap/list nodes - $helperInstance->sendPackage($this); - - // Change the state, this should be the last line except debug output - $this->getStateInstance()->nodeAnnouncingToUpperHubs(); - - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('HUB-Announcement: FINISHED'); - } - - /** - * Does a self-connect attempt on the public IP address. This should make - * it sure, we are reachable from outside world. For this kind of package we - * don't need that overload we have in the announcement phase. - * - * @param $taskInstance The task instance running this announcement - * @return void - */ - public function doSelfConnection (Taskable $taskInstance) { - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Self Connection: START (taskInstance=' . $taskInstance->__toString(). ')'); - - // Get a helper instance - $helperInstance = ObjectFactory::createObjectByConfiguredName('node_self_connect_helper_class', array($this)); - - // Load the descriptor (XML) file - $helperInstance->loadDescriptorXml($this); - - // Compile all variables - $helperInstance->getTemplateInstance()->compileConfigInVariables(); - - // And send the package away - $helperInstance->sendPackage($this); - - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Self Connection: FINISHED'); - } - - /** - * Activates the hub by doing some final preparation and setting - * $hubIsActive to TRUE. - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function activateNode (Requestable $requestInstance, Responseable $responseInstance) { - // Checks whether a listener is still active and shuts it down if one - // is still listening. - if (($this->determineIfListenerIsActive()) && ($this->isNodeActive())) { - // Shutdown them down before they can hurt anything - $this->shutdownListenerPool(); - } // END - if - - // Get the controller here - $controllerInstance = Registry::getRegistry()->getInstance('controller'); - - // Run all filters for the hub activation - $controllerInstance->executeActivationFilters($requestInstance, $responseInstance); - - // ----------------------- Last step from here ------------------------ - // Activate the hub. This is ALWAYS the last step in this method - $this->getStateInstance()->nodeIsActivated(); - // ---------------------- Last step until here ------------------------ - } - - /** - * Initializes the listener pool (class) - * - * @return void - */ - public function initializeListenerPool () { - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Initialize listener: START'); - - // Get a new pool instance - $this->setListenerPoolInstance(ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this))); - - // Get an instance of the low-level listener - $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this)); - - // Setup address and port - $listenerInstance->setListenAddressByConfiguration('node_listen_addr'); - - /* - * All nodes can now use the same configuration entry because it can be - * customized in config-local.php. - */ - $listenerInstance->setListenPortByConfiguration('node_listen_port'); - - // Initialize the listener - $listenerInstance->initListener(); - - // Get a decorator class - $decoratorInstance = ObjectFactory::createObjectByConfiguredName('node_tcp_listener_class', array($listenerInstance)); - - // Add this listener to the pool - $this->getListenerPoolInstance()->addListener($decoratorInstance); - - // Get a decorator class - $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance)); - - // Add this listener to the pool - $this->getListenerPoolInstance()->addListener($decoratorInstance); - - // Get an instance of the low-level listener - $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this)); - - // Setup address and port - $listenerInstance->setListenAddressByConfiguration('node_listen_addr'); - - /* - * All nodes can now use the same configuration entry because it can be - * customized in config-local.php. - */ - $listenerInstance->setListenPortByConfiguration('node_listen_port'); - - // Initialize the listener - $listenerInstance->initListener(); - - // Get a decorator class - $decoratorInstance = ObjectFactory::createObjectByConfiguredName('node_udp_listener_class', array($listenerInstance)); - - // Add this listener to the pool - $this->getListenerPoolInstance()->addListener($decoratorInstance); - - // Get a decorator class - $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance)); - - // Add this listener to the pool - $this->getListenerPoolInstance()->addListener($decoratorInstance); - - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Initialize listener: FINISHED.'); - } - - /** - * Getter for isActive attribute - * - * @return $isActive Whether the hub is active - */ - public final function isNodeActive () { - return $this->isActive; - } - - /** - * Enables (default) or disables isActive flag - * - * @param $isActive Whether the hub is active - * @return void - */ - public final function enableIsActive ($isActive = TRUE) { - $this->isActive = (bool) $isActive; - } - - /** - * Checks whether this node accepts announcements - * - * @return $acceptAnnouncements Whether this node accepts announcements - */ - public final function isAcceptingAnnouncements () { - // Check it (this node must be active and not shutdown!) - $acceptAnnouncements = (($this->acceptAnnouncements === TRUE) && ($this->isNodeActive())); - - // Return it - return $acceptAnnouncements; - } - - /** - * Checks whether this node accepts DHT bootstrap requests - * - * @return $acceptDhtBootstrap Whether this node accepts DHT bootstrap requests - */ - public final function isAcceptingDhtBootstrap () { - // Check it (this node must be active and not shutdown!) - $acceptDhtBootstrap = (($this->acceptDhtBootstrap === TRUE) && ($this->isNodeActive())); - - // Return it - return $acceptDhtBootstrap; - } - - /** - * Checks whether this node has attempted to announce itself - * - * @return $hasAnnounced Whether this node has attempted to announce itself - * @todo Add checking if this node has been announced to the sender node - */ - public function ifNodeIsAnnouncing () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeIsAnnouncing(): state=' . $this->getStateInstance()->getStateName()); - - // Simply check the state of this node - $hasAnnounced = ($this->getStateInstance() instanceof NodeAnnouncingState); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeIsAnnouncing(): hasAnnounced=' . intval($hasAnnounced)); - - // Return it - return $hasAnnounced; - } - - /** - * Checks whether this node has attempted to announce itself and completed it - * - * @return $hasAnnouncementCompleted Whether this node has attempted to announce itself and completed it - * @todo Add checking if this node has been announced to the sender node - */ - public function ifNodeHasAnnouncementCompleted () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName()); - - // Simply check the state of this node - $hasAnnouncementCompleted = ($this->getStateInstance() instanceof NodeAnnouncementCompletedState); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted)); - - // Return it - return $hasAnnouncementCompleted; - } - - /** - * Enables whether this node accepts announcements - * - * @param $acceptAnnouncements Whether this node accepts announcements (default: TRUE) - * @return void - */ - protected final function enableAcceptingAnnouncements ($acceptAnnouncements = TRUE) { - $this->acceptAnnouncements = $acceptAnnouncements; - } - - /** - * Enables whether this node accepts DHT bootstrap requests - * - * @param $acceptDhtBootstrap Whether this node accepts DHT bootstrap requests (default: TRUE) - * @return void - */ - public final function enableAcceptDhtBootstrap ($acceptDhtBootstrap = TRUE) { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Enabling DHT bootstrap requests ...'); - $this->acceptDhtBootstrap = $acceptDhtBootstrap; - } - - /** - * Checks wether this node is accepting node-list requests - * - * @return $acceptsRequest Wether this node accepts node-list requests - */ - public function isAcceptingNodeListRequests () { - /* - * Only 'regular' nodes does not accept such requests, checking - * HubRegularNode is faster, but if e.g. HubRegularI2PNode will be - * added then the next check will be TRUE. - */ - $acceptsRequest = ((!$this instanceof HubRegularNode) && ($this->getRequestInstance()->getRequestElement('mode') != self::NODE_TYPE_REGULAR)); - - // Return it - return $acceptsRequest; - } - - /** - * Determines an instance of a LocateableNode class - * - * @return $unlInstance An instance of a LocateableNode class for this node - */ - public function determineUniversalNodeLocator () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Determine UNL based on this node: - // 1) Get discovery class - $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class'); - - // 2) "Determine" it - $unlInstance = $discoveryInstance->discoverUniversalNodeLocatorByNode($this); - - // 3) Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unlInstance= ' . $unlInstance->__toString() . ' - EXIT!'); - return $unlInstance; - } - - /** - * "Getter" for an array of an instance of a LocateableNode class - * - * @return $unlData An array from an instance of a LocateableNode class for this node - */ - public final function getUniversalNodeLocatorArray () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Get the Universal Node Locator (UNL) instance - $unlInstance = $this->determineUniversalNodeLocator(); - - // Make sure the instance is valid - if (!$unlInstance instanceof LocateableNode) { - // No valid instance, so better debug this - $this->debugBackTrace('unlInstance[' . gettype($unlInstance) . ']=' . $unlInstance); - } // END - if - - // ... and the array from it - $unlData = $unlInstance->getUnlData(); - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - return $unlData; - } - - /** - * Updates/refreshes node data (e.g. status). - * - * @return void - * @todo Find more to do here - */ - public function updateNodeData () { - // Set some dummy configuration entries, e.g. node_status - $this->getConfigInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName()); - } - - /** - * Handles message answer by given data array - * - * @param $messageData A valid answer message data array - * @param $packageInstance An instance of a Receivable class - * @return void - * @todo Handle thrown exception - */ - public function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance) { - // Is it not empty? - assert(!empty($messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS])); - - // Construct configuration entry for handling class' name - $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]) . '_handler_class'; - - // Try to get a class - $handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry); - - // Handle it there - $handlerInstance->handleAnswerMessageData($messageData, $packageInstance); - } - - /** - * "Getter" for an array of all accepted object types - * - * @return $objectList Array of all accepted object types - */ - public function getListFromAcceptedObjectTypes () { - // Get registry instance - $objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); - - // Get all entries - $objectList = $objectRegistryInstance->getEntries(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME); - - // ... and return it - return $objectList; - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $nodeData An array with valid node data - * @return void - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $nodeData) { - // Add all data the array provides - foreach (NodeDistributedHashTableDatabaseWrapper::getAllElements() as $element) { - // Is the element there? - if (isset($nodeData[$element])) { - // Add it - $dataSetInstance->addCriteria($element, $nodeData[$element]); - } else { - // Output warning message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in nodeData array.'); - } - } // END - foreac - } -} - -// [EOF] -?> diff --git a/application/hub/main/nodes/list/.htaccess b/application/hub/main/nodes/list/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/nodes/list/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/nodes/list/class_HubListNode.php b/application/hub/main/nodes/list/class_HubListNode.php deleted file mode 100644 index ac7c92fd5..000000000 --- a/application/hub/main/nodes/list/class_HubListNode.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubListNode extends BaseHubNode implements NodeHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this hub-node class - * - * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class - */ - public static final function createHubListNode (Requestable $requestInstance) { - // Get a new instance - $nodeInstance = new HubListNode(); - - // Set the request instance - $nodeInstance->setRequestInstance($requestInstance); - - // Return the instance - return $nodeInstance; - } - - /** - * Method to "bootstrap" the node. This step does also apply provided - * command-line arguments stored in the request instance. The regular node - * should communicate with the bootstrap-nodes at this point. - * - * @return void - * @todo Implement more bootstrap steps - */ - public function doBootstrapping () { - $this->partialStub(); - } - - /** - * Add some node-specific filters - * - * @return void - */ - public function addExtraNodeFilters () { - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Get the controller from the application - $controllerInstance = $applicationInstance->getControllerInstance(); - - // Self-announcement task - $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_announcement_task_filter')); - - // @TODO Add some filters here - $this->partialStub('Add some filters here.'); - } - - /** - * Adds extra tasks to the given handler for this node - * - * @param $handlerInstance An instance of a HandleableTask class - * @return void - * @todo 0% done - */ - public function addExtraTasks (HandleableTask $handlerInstance) { - $this->partialStub('Please add some tasks or empty this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/nodes/master/.htaccess b/application/hub/main/nodes/master/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/nodes/master/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/nodes/master/class_HubMasterNode.php b/application/hub/main/nodes/master/class_HubMasterNode.php deleted file mode 100644 index 2893a05d4..000000000 --- a/application/hub/main/nodes/master/class_HubMasterNode.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubMasterNode extends BaseHubNode implements NodeHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this hub-node class - * - * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class - */ - public static final function createHubMasterNode (Requestable $requestInstance) { - // Get a new instance - $nodeInstance = new HubMasterNode(); - - // Set the request instance - $nodeInstance->setRequestInstance($requestInstance); - - // Return the instance - return $nodeInstance; - } - - /** - * Method to "bootstrap" the node. This step does also apply provided - * command-line arguments stored in the request instance. The regular node - * should communicate with the bootstrap-nodes at this point. - * - * @return void - * @todo Implement this method - */ - public function doBootstrapping () { - // Enable acceptance of announcements - $this->enableAcceptingAnnouncements(); - - // Do more steps - $this->partialStub('Please implement more boot-strapping steps!'); - } - - /** - * Add some node-specific filters - * - * @return void - */ - public function addExtraNodeFilters () { - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Get the controller from the application - $controllerInstance = $applicationInstance->getControllerInstance(); - - // Self-announcement task - $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_announcement_task_filter')); - - // @TODO Add some filters here - $this->partialStub('Add some filters here.'); - } - - /** - * Adds extra tasks to the given handler for this node - * - * @param $handlerInstance An instance of a HandleableTask class - * @return void - * @todo 0% done - */ - public function addExtraTasks (HandleableTask $handlerInstance) { - $this->partialStub('Please add some tasks or empty this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/nodes/regular/.htaccess b/application/hub/main/nodes/regular/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/nodes/regular/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/nodes/regular/class_HubRegularNode.php b/application/hub/main/nodes/regular/class_HubRegularNode.php deleted file mode 100644 index 7bfdaf899..000000000 --- a/application/hub/main/nodes/regular/class_HubRegularNode.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubRegularNode extends BaseHubNode implements NodeHelper, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this hub-node class - * - * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class - */ - public static final function createHubRegularNode (Requestable $requestInstance) { - // Get a new instance - $nodeInstance = new HubRegularNode(); - - // Set the request instance - $nodeInstance->setRequestInstance($requestInstance); - - // Return the instance - return $nodeInstance; - } - - /** - * Method to "bootstrap" the node. This step does also apply provided - * command-line arguments stored in the request instance. The regular node - * should communicate with the bootstrap-nodes at this point. - * - * @return void - * @todo Implement this method - */ - public function doBootstrapping () { - $this->partialStub(); - } - - /** - * Add some node-specific filters - * - * @return void - */ - public function addExtraNodeFilters () { - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Get the controller from the application - $controllerInstance = $applicationInstance->getControllerInstance(); - - // Self-announcement task - $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('node_activation_announcement_task_filter')); - - // @TODO Add some filters here - $this->partialStub('Add some filters here.'); - } - - /** - * Adds extra tasks to the given handler for this node - * - * @param $handlerInstance An instance of a HandleableTask class - * @return void - * @todo 0% done - */ - public function addExtraTasks (HandleableTask $handlerInstance) { - $this->partialStub('Please add some tasks or empty this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/package/.htaccess b/application/hub/main/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/package/assembler/.htaccess b/application/hub/main/package/assembler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/package/assembler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/package/assembler/class_PackageAssembler.php b/application/hub/main/package/assembler/class_PackageAssembler.php deleted file mode 100644 index 192c54fb1..000000000 --- a/application/hub/main/package/assembler/class_PackageAssembler.php +++ /dev/null @@ -1,322 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, Visitable { - /** - * Name for stacker holding raw data of multiple messages - */ - const STACKER_NAME_MULTIPLE_MESSAGE = 'multiple_message'; - - /** - * Pending data - */ - private $pendingData = ''; - - /** - * Private call-back methods - */ - private $callbacks = array(); - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $packageInstance An instance of a Receivable class - * @return $assemblerInstance An instance of an Assembler class - */ - public static final function createPackageAssembler (Receivable $packageInstance) { - // Get new instance - $assemblerInstance = new PackageAssembler(); - - // Set package instance here - $assemblerInstance->setPackageInstance($packageInstance); - - // Create an instance of a raw data input stream - $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_input_stream_class'); - - // And set it - $assemblerInstance->setInputStreamInstance($streamInstance); - - // Now get a chunk handler instance - $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); - - // Set handler instance - $assemblerInstance->setHandlerInstance($handlerInstance); - - // Get stacker instance - $stackInstance = ObjectFactory::createObjectByConfiguredName('multiple_message_stacker_class'); - - // Initialize the only one stack - $stackInstance->initStack(self::STACKER_NAME_MULTIPLE_MESSAGE); - - // And add it - $assemblerInstance->setStackInstance($stackInstance); - - // Return the prepared instance - return $assemblerInstance; - } - - /** - * Checks whether the input buffer (stacker to be more preceise) is empty. - * - * @return $isInputBufferEmpty Whether the input buffer is empty - */ - private function ifInputBufferIsEmpty () { - // Check it - $isInputBufferEmpty = $this->getPackageInstance()->getStackInstance()->isStackEmpty(NetworkPackage::STACKER_NAME_DECODED_HANDLED); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: isInputBufferEmpty=' . intval($isInputBufferEmpty)); - - // Return it - return $isInputBufferEmpty; - } - - /** - * Checks whether given package content is completed (start/end markers are found) - * - * @param $packageContent An array with two elements: 'raw_data' and 'error_code' - * @return $isCompleted Whether the given package content is completed - */ - private function isPackageContentCompleted (array $packageContent) { - // Check both - $isCompleted = $this->ifStartEndMarkersSet($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); - - // Return status - return $isCompleted; - } - - /** - * Assembles the content from $packageContent. This method does only - * initialize the whole process by creating a call-back which will then - * itself (99.9% of all cases) "explode" the decoded data stream and add - * it to a chunk assembler queue. - * - * If the call-back method or this would attempt to assemble the package - * chunks and (maybe) re-request some chunks from the sender, this would - * take to much time and therefore slow down this node again. - * - * @param $packageContent An array with two elements: 'raw_data' and 'error_code' - * @return void - * @throws UnsupportedPackageCodeHandlerException If the package code handler is not implemented - */ - public function chunkPackageContent (array $packageContent) { - // Validate the package content array again - assert( - (isset($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA])) && - (isset($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE])) - ); - - // Construct call-back name from package error code - $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]] = 'handlePackageBy' . self::convertToClassName($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]); - - // Abort if the call-back method is not there - if (!method_exists($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]])) { - // Throw an exception - throw new UnsupportedPackageCodeHandlerException(array($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]], $packageContent), BaseListener::EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER); - } // END - if - - // Call it back - call_user_func(array($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]]), $packageContent); - } - - /************************************************************************** - * Call-back methods for above method * - **************************************************************************/ - - /** - * Call-back handler to handle unhandled package data. This method - * "explodes" the string with the chunk separator from PackageFragmenter - * class, does some low checks on it and feeds it into another queue for - * verification and re-request for bad chunks. - * - * @param $packageContent An array with two elements: 'raw_data' and 'error_code' - * @return void - */ - private function handlePackageByUnhandledPackage (array $packageContent) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); - - // Check for some conditions - if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) { - // Last chunk is not valid, so wait for more - $this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]; - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)'); - } else { - // Debug message - //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': packageContent=' . print_r($packageContent, TRUE) . ',chunks='.print_r($chunks, TRUE)); - } - } - - /** - * Checks whether the assembler's pending data is empty which means it has - * no pending data left for handling ... ;-) - * - * @return $ifPendingDataIsEmpty Whether pending data is empty - */ - public function isPendingDataEmpty () { - // A simbple check - $ifPendingDataIsEmpty = empty($this->pendingData); - - // Return it - return $ifPendingDataIsEmpty; - } - - /** - * Checks whether the assembler has multiple messages pending - * - * @return $isPending Whether the assembler has multiple messages pending - */ - public function ifMultipleMessagesPending () { - // Determine it - $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_MULTIPLE_MESSAGE)); - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': isPending=' . intval($isPending)); - return $isPending; - } - - /** - * Handles the assembler's pending data - * - * @return void - */ - public function handlePendingData () { - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData); - - // Assert on condition - assert(!$this->isPendingDataEmpty()); - - // No markers set? - if (!$this->ifStartEndMarkersSet($this->pendingData)) { - // This will cause an assertition in next call, so simply wait for more data - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...'); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: this->pendingData=' . $this->pendingData); - return; - } elseif (substr_count($this->pendingData, BaseRawDataHandler::STREAM_START_MARKER) > 1) { - /* - * Multiple messages found, so split off first message as the input - * stream can only handle one message per time. - */ - foreach (explode(BaseRawDataHandler::STREAM_START_MARKER, $this->pendingData) as $message) { - // Prepend start marker again as it is needed to decode the message. - $message = BaseRawDataHandler::STREAM_START_MARKER . $message; - - // Push it on stack - $this->getStackInstance()->pushNamed(self::STACKER_NAME_MULTIPLE_MESSAGE, $message); - } // END - foreach - - // Clear pending data - $this->clearPendingData(); - - // ... and exit here - return; - } - - // Init fake array - $packageContent = array( - BaseRawDataHandler::PACKAGE_RAW_DATA => $this->getInputStreamInstance()->streamData($this->pendingData), - BaseRawDataHandler::PACKAGE_ERROR_CODE => BaseRawDataHandler::SOCKET_ERROR_UNHANDLED - ); - - /* - * Clear pending data as it has been processed and will be handled some - * lines below. - */ - $this->clearPendingData(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.'); - - // Make sure last CHUNK_SEPARATOR is not there - if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) { - // Remove it - $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1); - } // END - if - - /* - * "explode" the string from 'raw_data' with chunk separator to get an - * array of chunks. These chunks must then be verified by their - * checksums. Also the final chunk must be handled. - */ - $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); - - // Add all chunks because the last final chunk is found - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to add ' . count($chunks) . ' to chunk handler ...'); - $this->getHandlerInstance()->addAllChunksWithFinal($chunks); - } - - /** - * Handles multiple messages. - * - * @return void - */ - public function handleMultipleMessages () { - // Assert on condition - assert($this->ifMultipleMessagesPending()); - assert($this->isPendingDataEmpty()); - - // "Pop" next entry from stack and set it as new pending data - $this->pendingData = $this->getStackInstance()->popNamed(self::STACKER_NAME_MULTIPLE_MESSAGE); - - // And handle it - $this->handlePendingData(); - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit the assembler - $visitorInstance->visitAssembler($this); - } - - /** - * Clears pending data - * - * @return void - */ - public function clearPendingData () { - // Clear it - $this->pendingData = ''; - } -} - -// [EOF] -?> diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php deleted file mode 100644 index 4e4f384eb..000000000 --- a/application/hub/main/package/class_NetworkPackage.php +++ /dev/null @@ -1,1479 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Needs to add functionality for handling the object's type - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, Registerable, Visitable { - /** - * Package mask for compressing package data: - * 0: Compressor extension - * 1: Raw package data - * 2: Tags, seperated by semicolons, no semicolon is required if only one tag is needed - * 3: Checksum - * 0 1 2 3 - */ - const PACKAGE_MASK = '%s%s%s%s%s%s%s'; - - /** - * Separator for the above mask - */ - const PACKAGE_MASK_SEPARATOR = '^'; - - /** - * Size of an array created by invoking - * explode(NetworkPackage::PACKAGE_MASK_SEPARATOR, $content). - */ - const PACKAGE_CONTENT_ARRAY_SIZE = 4; - - /** - * Separator for checksum - */ - const PACKAGE_CHECKSUM_SEPARATOR = '_'; - - /** - * Array indexes for above mask, start with zero - */ - const INDEX_COMPRESSOR_EXTENSION = 0; - const INDEX_PACKAGE_DATA = 1; - const INDEX_TAGS = 2; - const INDEX_CHECKSUM = 3; - - /** - * Array indexes for raw package array - */ - const INDEX_PACKAGE_SENDER = 0; - const INDEX_PACKAGE_RECIPIENT = 1; - const INDEX_PACKAGE_CONTENT = 2; - const INDEX_PACKAGE_STATUS = 3; - const INDEX_PACKAGE_HASH = 4; - const INDEX_PACKAGE_PRIVATE_KEY_HASH = 5; - - /** - * Size of the decoded data array - */ - const DECODED_DATA_ARRAY_SIZE = 6; - - /** - * Named array elements for decoded package content - */ - const PACKAGE_CONTENT_EXTENSION = 'compressor'; - const PACKAGE_CONTENT_MESSAGE = 'message'; - const PACKAGE_CONTENT_TAGS = 'tags'; - const PACKAGE_CONTENT_CHECKSUM = 'checksum'; - const PACKAGE_CONTENT_SENDER = 'sender'; - const PACKAGE_CONTENT_HASH = 'hash'; - const PACKAGE_CONTENT_PRIVATE_KEY_HASH = 'pkhash'; - - /** - * Named array elements for package data - */ - const PACKAGE_DATA_SENDER = 'sender'; - const PACKAGE_DATA_RECIPIENT = 'recipient'; - const PACKAGE_DATA_CONTENT = 'content'; - const PACKAGE_DATA_STATUS = 'status'; - const PACKAGE_DATA_HASH = 'hash'; - const PACKAGE_DATA_PRIVATE_KEY_HASH = 'pkhash'; - - /** - * All package status - */ - const PACKAGE_STATUS_NEW = 'new'; - const PACKAGE_STATUS_FAILED = 'failed'; - const PACKAGE_STATUS_DECODED = 'decoded'; - const PACKAGE_STATUS_FAKED = 'faked'; - - /** - * Constants for message data array - */ - const MESSAGE_ARRAY_DATA = 'message_data'; - const MESSAGE_ARRAY_TYPE = 'message_type'; - const MESSAGE_ARRAY_SENDER = 'message_sender'; - const MESSAGE_ARRAY_HASH = 'message_hash'; - const MESSAGE_ARRAY_TAGS = 'message_tags'; - - /** - * Generic answer status field - */ - - /** - * Tags separator - */ - const PACKAGE_TAGS_SEPARATOR = ';'; - - /** - * Raw package data separator - */ - const PACKAGE_DATA_SEPARATOR = '#'; - - /** - * Separator for more than one recipient - */ - const PACKAGE_RECIPIENT_SEPARATOR = ':'; - - /** - * Network target (alias): 'upper nodes' - */ - const NETWORK_TARGET_UPPER = 'upper'; - - /** - * Network target (alias): 'self' - */ - const NETWORK_TARGET_SELF = 'self'; - - /** - * Network target (alias): 'dht' - */ - const NETWORK_TARGET_DHT = 'dht'; - - /** - * TCP package size in bytes - */ - const TCP_PACKAGE_SIZE = 512; - - /************************************************************************** - * Stacker for out-going packages * - **************************************************************************/ - - /** - * Stacker name for "undeclared" packages - */ - const STACKER_NAME_UNDECLARED = 'package_undeclared'; - - /** - * Stacker name for "declared" packages (which are ready to send out) - */ - const STACKER_NAME_DECLARED = 'package_declared'; - - /** - * Stacker name for "out-going" packages - */ - const STACKER_NAME_OUTGOING = 'package_outgoing'; - - /************************************************************************** - * Stacker for incoming packages * - **************************************************************************/ - - /** - * Stacker name for "incoming" decoded raw data - */ - const STACKER_NAME_DECODED_INCOMING = 'package_decoded_data'; - - /** - * Stacker name for handled decoded raw data - */ - const STACKER_NAME_DECODED_HANDLED = 'package_handled_decoded'; - - /** - * Stacker name for "chunked" decoded raw data - */ - const STACKER_NAME_DECODED_CHUNKED = 'package_chunked_decoded'; - - /************************************************************************** - * Stacker for incoming messages * - **************************************************************************/ - - /** - * Stacker name for new messages - */ - const STACKER_NAME_NEW_MESSAGE = 'package_new_message'; - - /** - * Stacker name for processed messages - */ - const STACKER_NAME_PROCESSED_MESSAGE = 'package_processed_message'; - - /************************************************************************** - * Stacker for raw data handling * - **************************************************************************/ - - /** - * Stacker for outgoing data stream - */ - const STACKER_NAME_OUTGOING_STREAM = 'outgoing_stream'; - - /** - * Array index for final hash - */ - const RAW_FINAL_HASH_INDEX = 'hash'; - - /** - * Array index for encoded data - */ - const RAW_ENCODED_DATA_INDEX = 'data'; - - /** - * Array index for sent bytes - */ - const RAW_SENT_BYTES_INDEX = 'sent'; - - /** - * Array index for socket resource - */ - const RAW_SOCKET_INDEX = 'socket'; - - /** - * Array index for buffer size - */ - const RAW_BUFFER_SIZE_INDEX = 'buffer'; - - /** - * Array index for diff between buffer and sent bytes - */ - const RAW_DIFF_INDEX = 'diff'; - - /************************************************************************** - * Protocol names * - **************************************************************************/ - const PROTOCOL_TCP = 'TCP'; - const PROTOCOL_UDP = 'UDP'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $compressorInstance A Compressor instance for compressing the content - * @return $packageInstance An instance of a Deliverable class - */ - public static final function createNetworkPackage (Compressor $compressorInstance) { - // Get new instance - $packageInstance = new NetworkPackage(); - - // Now set the compressor instance - $packageInstance->setCompressorInstance($compressorInstance); - - /* - * We need to initialize a stack here for our packages even for those - * which have no recipient address and stamp... ;-) This stacker will - * also be used for incoming raw data to handle it. - */ - $stackInstance = ObjectFactory::createObjectByConfiguredName('network_package_stacker_class'); - - // At last, set it in this class - $packageInstance->setStackInstance($stackInstance); - - // Init all stacker - $packageInstance->initStacks(); - - // Get a visitor instance for speeding up things and set it - $visitorInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_monitor_visitor_class'); - $packageInstance->setVisitorInstance($visitorInstance); - - // Get crypto instance and set it, too - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - $packageInstance->setCryptoInstance($cryptoInstance); - - // Get a singleton package assembler instance from factory and set it here, too - $assemblerInstance = PackageAssemblerFactory::createAssemblerInstance($packageInstance); - $packageInstance->setAssemblerInstance($assemblerInstance); - - // Get node instance - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Get pool instance from node - $poolInstance = $nodeInstance->getListenerPoolInstance(); - - // And set it here - $packageInstance->setListenerPoolInstance($poolInstance); - - // Return the prepared instance - return $packageInstance; - } - - /** - * Initialize all stackers - * - * @param $forceReInit Whether to force reinitialization of all stacks - * @return void - */ - protected function initStacks ($forceReInit = FALSE) { - // Initialize all - $this->getStackInstance()->initStacks(array( - self::STACKER_NAME_UNDECLARED, - self::STACKER_NAME_DECLARED, - self::STACKER_NAME_OUTGOING, - self::STACKER_NAME_DECODED_INCOMING, - self::STACKER_NAME_DECODED_HANDLED, - self::STACKER_NAME_DECODED_CHUNKED, - self::STACKER_NAME_NEW_MESSAGE, - self::STACKER_NAME_PROCESSED_MESSAGE, - self::STACKER_NAME_OUTGOING_STREAM - ), $forceReInit); - } - - /** - * Determines private key hash from given session id - * - * @param $decodedData Array with decoded data - * @return $hash Private key's hash - */ - private function determineSenderPrivateKeyHash (array $decodedData) { - // Get DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Ask DHT for session id - $senderData = $dhtInstance->findNodeLocalBySessionId($decodedData[self::PACKAGE_CONTENT_SENDER]); - - // Is an entry found? - if (count($senderData) > 0) { - // Make sure the element 'private_key_hash' is there - //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderData=' . print_r($senderData, TRUE)); - assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])); - - // Return it - return $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]; - } // END - if - - // Make sure the requested element is there - //* DEBUG-DIE */ die('decodedData=' . print_r($decodedData, TRUE)); - assert(isset($decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])); - - // There is no DHT entry so, accept the hash from decoded data - return $decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH]; - } - - /** - * "Getter" for hash from given content - * - * @param $content Raw package content - * @return $hash Hash for given package content - */ - private function getHashFromContent ($content) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); - - // Create the hash - // @TODO md5() is very weak, but it needs to be fast - $hash = md5( - $content . - self::PACKAGE_CHECKSUM_SEPARATOR . - $this->getSessionId() . - self::PACKAGE_CHECKSUM_SEPARATOR . - $this->getCompressorInstance()->getCompressorExtension() - ); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); - - // And return it - return $hash; - } - - /** - * Checks whether the checksum (sometimes called "hash") is the same - * - * @param $decodedContent Package raw content - * @param $decodedData Whole raw package data array - * @return $isChecksumValid Whether the checksum is the same - */ - private function isChecksumValid (array $decodedContent, array $decodedData) { - // Get checksum - $checksum = $this->getHashFromContentSessionId($decodedContent, $decodedData[self::PACKAGE_DATA_SENDER]); - - // Is it the same? - $isChecksumValid = ($checksum == $decodedContent[self::PACKAGE_CONTENT_CHECKSUM]); - - // Return it - return $isChecksumValid; - } - - /** - * Change the package with given status in given stack - * - * @param $packageData Raw package data in an array - * @param $stackerName Name of the stacker - * @param $newStatus New status to set - * @return void - */ - private function changePackageStatus (array $packageData, $stackerName, $newStatus) { - // Skip this for empty stacks - if ($this->getStackInstance()->isStackEmpty($stackerName)) { - // This avoids an exception after all packages has failed - return; - } // END - if - - // Pop the entry (it should be it) - $nextData = $this->getStackInstance()->popNamed($stackerName); - - // Compare both hashes - assert($nextData[self::PACKAGE_DATA_HASH] == $packageData[self::PACKAGE_DATA_HASH]); - - // Temporary set the new status - $packageData[self::PACKAGE_DATA_STATUS] = $newStatus; - - // And push it again - $this->getStackInstance()->pushNamed($stackerName, $packageData); - } - - /** - * "Getter" for hash from given content and sender's session id - * - * @param $decodedContent Raw package content - * @param $sessionId Session id of the sender - * @return $hash Hash for given package content - */ - public function getHashFromContentSessionId (array $decodedContent, $sessionId) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]); - - // Create the hash - // @TODO md5() is very weak, but it needs to be fast - $hash = md5( - $decodedContent[self::PACKAGE_CONTENT_MESSAGE] . - self::PACKAGE_CHECKSUM_SEPARATOR . - $sessionId . - self::PACKAGE_CHECKSUM_SEPARATOR . - $decodedContent[self::PACKAGE_CONTENT_EXTENSION] - ); - - // And return it - return $hash; - } - - /////////////////////////////////////////////////////////////////////////// - // Delivering packages / raw data - /////////////////////////////////////////////////////////////////////////// - - /** - * Declares the given raw package data by discovering recipients - * - * @param $packageData Raw package data in an array - * @return void - */ - private function declareRawPackageData (array $packageData) { - // Make sure the required field is there - assert(isset($packageData[self::PACKAGE_DATA_RECIPIENT])); - - /* - * We need to disover every recipient, just in case we have a - * multi-recipient entry like 'upper' is. 'all' may be a not so good - * target because it causes an overload on the network and may be - * abused for attacking the network with large packages. - */ - $discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance(); - - // Discover all recipients, this may throw an exception - $discoveryInstance->discoverRecipients($packageData); - - // Now get an iterator - $iteratorInstance = $discoveryInstance->getIterator(); - - // Make sure the iterator instance is valid - assert($iteratorInstance instanceof Iterator); - - // Rewind back to the beginning - $iteratorInstance->rewind(); - - // ... and begin iteration - while ($iteratorInstance->valid()) { - // Get current entry - $currentRecipient = $iteratorInstance->current(); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]); - - // Set the recipient - $packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient; - - // Push the declared package to the next stack. - $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package declared for recipient ' . $currentRecipient); - - // Skip to next entry - $iteratorInstance->next(); - } // END - while - - /* - * The recipient list can be cleaned up here because the package which - * shall be delivered has already been added for all entries from the - * list. - */ - $discoveryInstance->clearRecipients(); - } - - /** - * Delivers raw package data. In short, this will discover the raw socket - * resource through a discovery class (which will analyse the receipient of - * the package), register the socket with the connection (handler/helper?) - * instance and finally push the raw data on our outgoing queue. - * - * @param $packageData Raw package data in an array - * @return void - */ - private function deliverRawPackageData (array $packageData) { - /* - * This package may become big, depending on the shared object size or - * delivered message size which shouldn't be so long (to save - * bandwidth). Because of the nature of the used protocol (TCP) we need - * to split it up into smaller pieces to fit it into a TCP frame. - * - * So first we need (again) a discovery class but now a protocol - * discovery to choose the right socket resource. The discovery class - * should take a look at the raw package data itself and then decide - * which (configurable!) protocol should be used for that type of - * package. - */ - $discoveryInstance = SocketDiscoveryFactory::createSocketDiscoveryInstance(); - - // Now discover the right protocol - $socketResource = $discoveryInstance->discoverSocket($packageData, BaseConnectionHelper::CONNECTION_TYPE_OUTGOING); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after discoverSocket() has been called.'); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: stateInstance=' . $helperInstance->getStateInstance()); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.'); - - // The socket needs to be put in a special registry that can handle such data - $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); - - // Get the connection helper from registry - $helperInstance = Registry::getRegistry()->getInstance('connection'); - - // And make sure it is valid - assert($helperInstance instanceof ConnectionHelper); - - // Get connection info class - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($helperInstance->getProtocolName(), 'helper'); - - // Will the info instance with connection helper data - $infoInstance->fillWithConnectionHelperInformation($helperInstance); - - // Is it not there? - if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($infoInstance, $socketResource))) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Registering socket ' . $socketResource . ' ...'); - - // Then register it - $registryInstance->registerSocket($infoInstance, $socketResource, $packageData); - } elseif (!$helperInstance->getStateInstance()->isPeerStateConnected()) { - // Is not connected, then we cannot send - self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.'); - - // Shutdown the socket - $this->shutdownSocket($socketResource); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.'); - - // Make sure the connection is up - $helperInstance->getStateInstance()->validatePeerStateConnected(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.'); - - // Enqueue it again on the out-going queue, the connection is up and working at this point - $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after pushNamed() has been called.'); - } - - /** - * Sends waiting packages - * - * @param $packageData Raw package data - * @return void - */ - private function sendOutgoingRawPackageData (array $packageData) { - // Init sent bytes - $sentBytes = 0; - - // Get the right connection instance - $infoInstance = SocketRegistryFactory::createSocketRegistryInstance()->getInfoInstanceFromPackageData($packageData); - - // Test helper instance - assert($infoInstance instanceof ShareableInfo); - - // Get helper instance - $helperInstance = $infoInstance->getHelperInstance(); - - // Some sanity-checks on the object - //* DEBUG-DIE: */ die('[' . __METHOD__ . ':' . __LINE__ . ']: p1=' . $infoInstance->getProtocolName() . ',p2=' . $helperInstance->getProtocolName() . ',infoInstance=' . print_r($infoInstance, TRUE)); - assert($helperInstance instanceof ConnectionHelper); - assert($infoInstance->getProtocolName() == $helperInstance->getProtocolName()); - - // Is this connection still alive? - if ($helperInstance->isShuttedDown()) { - // This connection is shutting down - // @TODO We may want to do somthing more here? - return; - } // END - if - - // Sent out package data - $helperInstance->sendRawPackageData($packageData); - } - - /** - * Generates a secure hash for given raw package content and sender id - * - * @param $content Raw package data - * @param $senderId Sender id to generate a hash for - * @return $hash Hash as hex-encoded string - */ - private function generatePackageHash ($content, $senderId) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!'); - - // Is the feature enabled? - if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { - // Feature is not enabled - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...'); - return NULL; - } // END - if - - // Fake array - $data = array( - self::PACKAGE_CONTENT_SENDER => $senderId, - self::PACKAGE_CONTENT_MESSAGE => $content, - self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => '' - ); - - // Hash content and sender id together, use scrypt - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $senderId . ',content()=' . strlen($content)); - $hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array($senderId . ':' . $content . ':' . $this->determineSenderPrivateKeyHash($data))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash . ' - EXIT!'); - - // Return it - return $hash; - } - - /** - * Checks whether the hash of given package data is 'valid', here that - * means it is the same or not. - * - * @param $decodedArray An array with 'decoded' (explode() was mostly called) data - * @return $isHashValid Whether the hash is valid - * @todo Unfinished area, hashes are currently NOT fully supported - */ - private function isPackageHashValid (array $decodedArray) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!'); - - // Make sure the required array elements are there - assert(isset($decodedArray[self::PACKAGE_CONTENT_SENDER])); - assert(isset($decodedArray[self::PACKAGE_CONTENT_MESSAGE])); - assert(isset($decodedArray[self::PACKAGE_CONTENT_HASH])); - - // Is the feature enabled? - if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { - // Feature is not enabled, so hashes are always valid - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...'); - return TRUE; - } // END - if - - // Check validity - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . '),hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]); - //* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE)); - $isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH])); - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: isHashValid=' . intval($isHashValid) . ' - EXIT!'); - return $isHashValid; - } - - /** - * "Enqueues" raw content into this delivery class by reading the raw content - * from given helper's template instance and pushing it on the 'undeclared' - * stack. - * - * @param $helperInstance An instance of a HubHelper class - * @return void - */ - public function enqueueRawDataFromTemplate (HubHelper $helperInstance) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); - - // Get the raw content ... - $content = $helperInstance->getTemplateInstance()->getRawTemplateData(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('content(' . strlen($content) . ')=' . $content); - - // ... and compress it - $compressed = $this->getCompressorInstance()->compressStream($content); - - // Add magic in front of it and hash behind it, including BASE64 encoding - $packageContent = sprintf(self::PACKAGE_MASK, - // 1.) Compressor's extension - $this->getCompressorInstance()->getCompressorExtension(), - // - separator - self::PACKAGE_MASK_SEPARATOR, - // 2.) Compressed raw package content, encoded with BASE64 - base64_encode($compressed), - // - separator - self::PACKAGE_MASK_SEPARATOR, - // 3.) Tags - implode(self::PACKAGE_TAGS_SEPARATOR, $helperInstance->getPackageTags()), - // - separator - self::PACKAGE_MASK_SEPARATOR, - // 4.) Checksum - $this->getHashFromContent($compressed) - ); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...'); - - // Now prepare the temporary array and push it on the 'undeclared' stack - $this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array( - self::PACKAGE_DATA_SENDER => $this->getSessionId(), - self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(), - self::PACKAGE_DATA_CONTENT => $packageContent, - self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_NEW, - self::PACKAGE_DATA_HASH => $this->generatePackageHash($content, $this->getSessionId()), - self::PACKAGE_DATA_PRIVATE_KEY_HASH => $this->getPrivateKeyHash(), - )); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); - } - - /** - * Checks whether a package has been enqueued for delivery. - * - * @return $isEnqueued Whether a package is enqueued - */ - public function isPackageEnqueued () { - // Check whether the stacker is not empty - $isEnqueued = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED))); - - // Return the result - return $isEnqueued; - } - - /** - * Checks whether a package has been declared - * - * @return $isDeclared Whether a package is declared - */ - public function isPackageDeclared () { - // Check whether the stacker is not empty - $isDeclared = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED))); - - // Return the result - return $isDeclared; - } - - /** - * Checks whether a package should be sent out - * - * @return $isWaitingDelivery Whether a package is waiting for delivery - */ - public function isPackageWaitingForDelivery () { - // Check whether the stacker is not empty - $isWaitingDelivery = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING))); - - // Return the result - return $isWaitingDelivery; - } - - /** - * Checks whether encoded (raw) data is pending - * - * @return $isPending Whether encoded data is pending - */ - public function isEncodedDataPending () { - // Check whether the stacker is not empty - $isPending = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING_STREAM))); - - // Return the result - return $isPending; - } - - /** - * Delivers an enqueued package to the stated destination. If a non-session - * id is provided, recipient resolver is being asked (and instanced once). - * This allows that a single package is being delivered to multiple targets - * without enqueueing it for every target. If no target is provided or it - * can't be determined a NoTargetException is being thrown. - * - * @return void - * @throws NoTargetException If no target can't be determined - */ - public function declareEnqueuedPackage () { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); - - // Make sure this method isn't working if there is no package enqueued - if (!$this->isPackageEnqueued()) { - // This is not fatal but should be avoided - self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!'); - return; - } // END - if - - /* - * Now there are for sure packages to deliver, so start with the first - * one. - */ - $packageData = $this->getStackInstance()->popNamed(self::STACKER_NAME_UNDECLARED); - - // Declare the raw package data for delivery - $this->declareRawPackageData($packageData); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); - } - - /** - * Delivers the next declared package. Only one package per time will be sent - * because this may take time and slows down the whole delivery - * infrastructure. - * - * @return void - */ - public function processDeclaredPackage () { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); - - // Sanity check if we have packages declared - if (!$this->isPackageDeclared()) { - // This is not fatal but should be avoided - self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No package has been declared, but ' . __METHOD__ . ' has been called!'); - return; - } // END - if - - // Get the package - $packageData = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED); - - // Assert on it - assert(isset($packageData[self::PACKAGE_DATA_RECIPIENT])); - - // Try to deliver the package - try { - // And try to send it - $this->deliverRawPackageData($packageData); - - // And remove it finally - $this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED); - } catch (UnexpectedStateException $e) { - // The state is not excepected (shall be 'connected') - self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage()); - - // Mark the package with status failed - $this->changePackageStatus($packageData, self::STACKER_NAME_DECLARED, self::PACKAGE_STATUS_FAILED); - } - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); - } - - /** - * Sends waiting packages out for delivery - * - * @return void - */ - public function sendWaitingPackage () { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); - - // Sanity check if we have packages waiting for delivery - if (!$this->isPackageWaitingForDelivery()) { - // This is not fatal but should be avoided - self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No package is waiting for delivery, but ' . __METHOD__ . ' was called.'); - return; - } // END - if - - // Get the package - $packageData = $this->getStackInstance()->getNamed(self::STACKER_NAME_OUTGOING); - - try { - // Now try to send it - $this->sendOutgoingRawPackageData($packageData); - - // And remove it finally - $this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING); - } catch (InvalidSocketException $e) { - // Output exception message - self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package was not delivered: ' . $e->getMessage()); - - // Mark package as failed - $this->changePackageStatus($packageData, self::STACKER_NAME_OUTGOING, self::PACKAGE_STATUS_FAILED); - } - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); - } - - /** - * Sends out encoded data to a socket - * - * @return void - */ - public function sendEncodedData () { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!'); - - // Make sure there is pending encoded data - assert($this->isEncodedDataPending()); - - // Pop current data from stack - $encodedDataArray = $this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING_STREAM); - - // Init in this round sent bytes - $sentBytes = 0; - - // Assert on socket - assert(is_resource($encodedDataArray[self::RAW_SOCKET_INDEX])); - - // And deliver it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Sending out ' . strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) . ' bytes,rawBufferSize=' . $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] . ',diff=' . $encodedDataArray[self::RAW_DIFF_INDEX]); - if ($encodedDataArray[self::RAW_DIFF_INDEX] >= 0) { - // Send all out (encodedData is smaller than or equal buffer size) - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], 0, ($encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - $encodedDataArray[self::RAW_DIFF_INDEX])))); - $sentBytes = @socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], ($encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - $encodedDataArray[self::RAW_DIFF_INDEX])); - } else { - // Send buffer size out - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], 0, $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX]))); - $sentBytes = @socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX]); - } - - // If there was an error, we don't continue here - if ($sentBytes === FALSE) { - // Handle the error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $encodedDataArray[self::RAW_SOCKET_INDEX], array('0.0.0.0', '0')); - - // And throw it - throw new InvalidSocketException(array($this, $encodedDataArray[self::RAW_SOCKET_INDEX], $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } elseif (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) > 0)) { - // Nothing sent means we are done - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')'); - return; - } else { - // The difference between sent bytes and length of raw data should not go below zero - assert((strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) - $sentBytes) >= 0); - - // Add total sent bytes - $encodedDataArray[self::RAW_SENT_BYTES_INDEX] += $sentBytes; - - // Cut out the last unsent bytes - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Sent out ' . $sentBytes . ' of ' . strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) . ' bytes ...'); - $encodedDataArray[self::RAW_ENCODED_DATA_INDEX] = substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], $sentBytes); - - // Calculate difference again - $encodedDataArray[self::RAW_DIFF_INDEX] = $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]); - - // Can we abort? - if (strlen($encodedDataArray[self::RAW_ENCODED_DATA_INDEX]) <= 0) { - // Abort here, all sent! - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')'); - return; - } // END - if - } - - // Push array back in stack - $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!'); - } - - /////////////////////////////////////////////////////////////////////////// - // Receiving packages / raw data - /////////////////////////////////////////////////////////////////////////// - - /** - * Checks whether decoded raw data is pending - * - * @return $isPending Whether decoded raw data is pending - */ - private function isRawDataPending () { - // Just return whether the stack is not empty - $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING)); - - // Return the status - return $isPending; - } - - /** - * Checks whether new raw package data has arrived at a socket - * - * @return $hasArrived Whether new raw package data has arrived for processing - */ - public function isNewRawDataPending () { - // Visit the pool. This monitors the pool for incoming raw data. - $this->getListenerPoolInstance()->accept($this->getVisitorInstance()); - - // Check for new data arrival - $hasArrived = $this->isRawDataPending(); - - // Return the status - return $hasArrived; - } - - /** - * Handles the incoming decoded raw data. This method does not "convert" the - * decoded data back into a package array, it just "handles" it and pushs it - * on the next stack. - * - * @return void - */ - public function handleIncomingDecodedData () { - /* - * This method should only be called if decoded raw data is pending, - * so check it again. - */ - if (!$this->isRawDataPending()) { - // This is not fatal but should be avoided - self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!'); - return; - } // END - if - - // Very noisy debug message: - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.'); - - // "Pop" the next entry (the same array again) from the stack - $decodedData = $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING); - - // Make sure both array elements are there - assert( - (is_array($decodedData)) && - (isset($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA])) && - (isset($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE])) - ); - - /* - * Also make sure the error code is SOCKET_ERROR_UNHANDLED because we - * only want to handle unhandled packages here. - */ - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . BaseRawDataHandler::SOCKET_ERROR_UNHANDLED . ')'); - assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED); - - // Remove the last chunk SEPARATOR (because there is no need for it) - if (substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) { - // It is there and should be removed - $decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1); - } // END - if - - // This package is "handled" and can be pushed on the next stack - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...'); - $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $decodedData); - } - - /** - * Adds raw decoded data from the given handler instance to this receiver - * - * @param $handlerInstance An instance of a Networkable class - * @return void - */ - public function addRawDataToIncomingStack (Networkable $handlerInstance) { - /* - * Get the decoded data from the handler, this is an array with - * 'raw_data' and 'error_code' as elements. - */ - $decodedData = $handlerInstance->getNextRawData(); - - // Very noisy debug message: - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE)); - - // And push it on our stack - $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $decodedData); - } - - /** - * Checks whether incoming decoded data is handled. - * - * @return $isHandled Whether incoming decoded data is handled - */ - public function isIncomingRawDataHandled () { - // Determine if the stack is not empty - $isHandled = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_HANDLED)); - - // Return it - return $isHandled; - } - - /** - * Checks whether the assembler has pending data left - * - * @return $isHandled Whether the assembler has pending data left - */ - public function ifAssemblerHasPendingDataLeft () { - // Determine if the stack is not empty - $isHandled = (!$this->getAssemblerInstance()->isPendingDataEmpty()); - - // Return it - return $isHandled; - } - - /** - * Checks whether the assembler has multiple packages pending - * - * @return $isPending Whether the assembler has multiple packages pending - */ - public function ifMultipleMessagesPending () { - // Determine if the stack is not empty - $isPending = ($this->getAssemblerInstance()->ifMultipleMessagesPending()); - - // Return it - return $isPending; - } - - /** - * Handles the attached assemler's pending data queue to be finally - * assembled to the raw package data back. - * - * @return void - */ - public function handleAssemblerPendingData () { - // Handle it - $this->getAssemblerInstance()->handlePendingData(); - } - - /** - * Handles multiple messages. - * - * @return void - */ - public function handleMultipleMessages () { - // Handle it - $this->getAssemblerInstance()->handleMultipleMessages(); - } - - /** - * Assembles incoming decoded data so it will become an abstract network - * package again. The assembler does later do it's job by an other task, - * not this one to keep best speed possible. - * - * @return void - */ - public function assembleDecodedDataToPackage () { - // Make sure the raw decoded package data is handled - assert($this->isIncomingRawDataHandled()); - - // Get current package content (an array with two elements; see handleIncomingDecodedData() for details) - $packageContent = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECODED_HANDLED); - - // Assert on some elements - assert( - (is_array($packageContent)) && - (isset($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA])) && - (isset($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE])) - ); - - // Start assembling the raw package data array by chunking it - $this->getAssemblerInstance()->chunkPackageContent($packageContent); - - // Remove the package from 'handled_decoded' stack ... - $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED); - - // ... and push it on the 'chunked' stacker - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE)); - $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent); - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); - - // Visit the package - $visitorInstance->visitNetworkPackage($this); - - // Then visit the assembler to handle multiple packages - $this->getAssemblerInstance()->accept($visitorInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); - } - - /** - * Clears all stacks - * - * @return void - */ - public function clearAllStacks () { - // Call the init method to force re-initialization - $this->initStacks(TRUE); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: All stacker have been re-initialized.'); - } - - /** - * Removes the first failed outoging package from the stack to continue - * with next one (it will never work until the issue is fixed by you). - * - * @return void - * @throws UnexpectedPackageStatusException If the package status is not 'failed' - * @todo This may be enchanced for outgoing packages? - */ - public function removeFirstFailedPackage () { - // Get the package again - $packageData = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED); - - // Is the package status 'failed'? - if ($packageData[self::PACKAGE_DATA_STATUS] != self::PACKAGE_STATUS_FAILED) { - // Not failed! - throw new UnexpectedPackageStatusException(array($this, $packageData, self::PACKAGE_STATUS_FAILED), BaseListener::EXCEPTION_UNEXPECTED_PACKAGE_STATUS); - } // END - if - - // Remove this entry - $this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED); - } - - /** - * "Decode" the package content into the same array when it was sent. - * - * @param $rawPackageContent The raw package content to be "decoded" - * @return $decodedData An array with 'sender', 'recipient', 'content' and 'status' elements - */ - public function decodeRawContent ($rawPackageContent) { - // Use the separator '#' to "decode" it - $decodedArray = explode(self::PACKAGE_DATA_SEPARATOR, $rawPackageContent); - - // Assert on count (should be always 3) - assert(count($decodedArray) == self::DECODED_DATA_ARRAY_SIZE); - - /* - * Create 'decodedData' array with all assoziative array elements. - */ - $decodedData = array( - self::PACKAGE_DATA_SENDER => $decodedArray[self::INDEX_PACKAGE_SENDER], - self::PACKAGE_DATA_RECIPIENT => $decodedArray[self::INDEX_PACKAGE_RECIPIENT], - self::PACKAGE_DATA_CONTENT => $decodedArray[self::INDEX_PACKAGE_CONTENT], - self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_DECODED, - self::PACKAGE_DATA_HASH => $decodedArray[self::INDEX_PACKAGE_HASH], - self::PACKAGE_DATA_PRIVATE_KEY_HASH => $decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH] - ); - - // And return it - return $decodedData; - } - - /** - * Handles decoded data for this node by "decoding" the 'content' part of - * it. Again this method uses explode() for the "decoding" process. - * - * @param $decodedData An array with decoded raw package data - * @return void - * @throws InvalidDataChecksumException If the checksum doesn't match - */ - public function handleRawData (array $decodedData) { - /* - * "Decode" the package's content by a simple explode() call, for - * details of the array elements, see comments for constant - * PACKAGE_MASK. - */ - $decodedContent = explode(self::PACKAGE_MASK_SEPARATOR, $decodedData[self::PACKAGE_DATA_CONTENT]); - - // Assert on array count for a very basic validation - assert(count($decodedContent) == self::PACKAGE_CONTENT_ARRAY_SIZE); - - /* - * Convert the indexed array into an associative array. This is much - * better to remember than plain numbers, isn't it? - */ - $decodedContent = array( - // Compressor's extension used to compress the data - self::PACKAGE_CONTENT_EXTENSION => $decodedContent[self::INDEX_COMPRESSOR_EXTENSION], - // Package data (aka "message") in BASE64-decoded form but still compressed - self::PACKAGE_CONTENT_MESSAGE => base64_decode($decodedContent[self::INDEX_PACKAGE_DATA]), - // Tags as an indexed array for "tagging" the message - self::PACKAGE_CONTENT_TAGS => explode(self::PACKAGE_TAGS_SEPARATOR, $decodedContent[self::INDEX_TAGS]), - // Checksum of the _decoded_ data - self::PACKAGE_CONTENT_CHECKSUM => $decodedContent[self::INDEX_CHECKSUM], - // Sender's id - self::PACKAGE_CONTENT_SENDER => $decodedData[self::PACKAGE_DATA_SENDER], - // Hash from decoded raw data - self::PACKAGE_CONTENT_HASH => $decodedData[self::PACKAGE_DATA_HASH], - // Hash of private key - self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $decodedData[self::PACKAGE_DATA_PRIVATE_KEY_HASH] - ); - - // Is the checksum valid? - if (!$this->isChecksumValid($decodedContent, $decodedData)) { - // Is not the same, so throw an exception here - throw new InvalidDataChecksumException(array($this, $decodedContent, $decodedData), BaseListener::EXCEPTION_INVALID_DATA_CHECKSUM); - } // END - if - - /* - * The checksum is the same, then it can be decompressed safely. The - * original message is at this point fully decoded. - */ - $decodedContent[self::PACKAGE_CONTENT_MESSAGE] = $this->getCompressorInstance()->decompressStream($decodedContent[self::PACKAGE_CONTENT_MESSAGE]); - - // And push it on the next stack - $this->getStackInstance()->pushNamed(self::STACKER_NAME_NEW_MESSAGE, $decodedContent); - } - - /** - * Checks whether a new message has arrived - * - * @return $hasArrived Whether a new message has arrived for processing - */ - public function isNewMessageArrived () { - // Determine if the stack is not empty - $hasArrived = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_NEW_MESSAGE)); - - // Return it - return $hasArrived; - } - - /** - * Handles newly arrived messages - * - * @return void - * @todo Implement verification of all sent tags here? - */ - public function handleNewlyArrivedMessage () { - // Make sure there is at least one message - assert($this->isNewMessageArrived()); - - // Get it from the stacker, it is the full array with the decoded message - $decodedContent = $this->getStackInstance()->popNamed(self::STACKER_NAME_NEW_MESSAGE); - - // Generate the hash of comparing it - if (!$this->isPackageHashValid($decodedContent)) { - // Is not valid, so throw an exception here - exit(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . chr(10)); - } // END - if - - // Now get a filter chain back from factory with given tags array - $chainInstance = PackageFilterChainFactory::createChainByTagsArray($decodedContent[self::PACKAGE_CONTENT_TAGS]); - - /* - * Process the message through all filters, note that all other - * elements from $decodedContent are no longer needed. - */ - $chainInstance->processMessage($decodedContent, $this); - - /* - * Post-processing of message data (this won't remote the message from - * the stack). - */ - $chainInstance->postProcessMessage($this); - } - - /** - * Checks whether a processed message is pending for "interpretation" - * - * @return $isPending Whether a processed message is pending - */ - public function isProcessedMessagePending () { - // Check it - $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PROCESSED_MESSAGE)); - - // Return it - return $isPending; - } - - /** - * Handle processed messages by "interpreting" the 'message_type' element - * - * @return void - */ - public function handleProcessedMessage () { - // Get it from the stacker, it is the full array with the processed message - $messageArray = $this->getStackInstance()->popNamed(self::STACKER_NAME_PROCESSED_MESSAGE); - - // Add type for later easier handling - $messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE]; - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: messageArray=' . print_r($messageArray, TRUE)); - - // Create a handler instance from given message type - $handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]); - - // Handle message data - $handlerInstance->handleMessageData($messageArray[self::MESSAGE_ARRAY_DATA], $this); - - // Post-handling of message data - $handlerInstance->postHandleMessageData($messageArray, $this); - } - - /** - * Feeds the hash and sender (as recipient for the 'sender' reward) to the - * miner's queue, unless the message is not a "reward claim" message as this - * leads to an endless loop. You may wish to run the miner to get some - * reward ("Hubcoins") for "mining" this hash. - * - * @param $messageData Array with message data - * @return void - * @todo ~10% done? - */ - public function feedHashToMiner (array $messageData) { - // Is the feature enabled? - if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { - /* - * Feature is not enabled, don't feed the hash to the miner as it - *may be invalid. - */ - return; - } // END - if - - // Make sure the required elements are there - assert(isset($messageData[self::MESSAGE_ARRAY_SENDER])); - assert(isset($messageData[self::MESSAGE_ARRAY_HASH])); - assert(isset($messageData[self::MESSAGE_ARRAY_TAGS])); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE)); - - // Resolve session id ('sender' is a session id) into node id - $nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]); - - // Is 'claim_reward' the message type? - if (in_array('claim_reward', $messageData[self::MESSAGE_ARRAY_TAGS])) { - /* - * Then don't feed this message to the miner as this causes an - * endless loop of mining. - */ - return; - } // END - if - - $this->partialStub('@TODO nodeId=' . $nodeId . ',messageData=' . print_r($messageData, TRUE)); - } -} - -// [EOF] -?> diff --git a/application/hub/main/package/fragmenter/.htaccess b/application/hub/main/package/fragmenter/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/package/fragmenter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/package/fragmenter/class_PackageFragmenter.php b/application/hub/main/package/fragmenter/class_PackageFragmenter.php deleted file mode 100644 index a816686c8..000000000 --- a/application/hub/main/package/fragmenter/class_PackageFragmenter.php +++ /dev/null @@ -1,542 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registerable { - /** - * Cached chunk size in bits - */ - private $chunkSize = 0; - - /** - * Array for chunks - */ - private $chunks = array(); - - /** - * Array for chunk hashes - */ - private $chunkHashes = array(); - - /** - * Array for chunk pointers - */ - private $chunkPointers = array(); - - /** - * Array for processed packages - */ - private $processedPackages = array(); - - /** - * Serial numbers (array key is final hash) - */ - private $serialNumber = array(); - - /** - * Maximum possible serial number, "cache" for speeding up things - */ - private $maxSerialNumber = 0; - - /** - * Length of largest possible serial number - */ - const MAX_SERIAL_LENGTH = 8; - - /** - * Separator between chunk data, serial number and chunk hash - */ - const CHUNK_DATA_HASH_SEPARATOR = '@'; - - /** - * SEPARATOR for all chunk hashes - */ - const CHUNK_HASH_SEPARATOR = ';'; - - /** - * SEPARATOR between two chunks - */ - const CHUNK_SEPARATOR = '|'; - - /** - * Identifier for hash chunk - */ - const HASH_CHUNK_IDENTIFIER = 'HASH-CHUNK:'; - - /** - * Identifier for end-of-package marker - */ - const END_OF_PACKAGE_IDENTIFIER = 'EOP:'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init this fragmenter - $this->initFragmenter(); - } - - /** - * Creates an instance of this class - * - * @return $fragmenterInstance An instance of a Fragmentable class - */ - public static final function createPackageFragmenter () { - // Get new instance - $fragmenterInstance = new PackageFragmenter(); - - // Get a crypto instance and set it here - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - $fragmenterInstance->setCryptoInstance($cryptoInstance); - - // Return the prepared instance - return $fragmenterInstance; - } - - /** - * Initializes this fragmenter - * - * @return void - */ - private function initFragmenter () { - // Load some configuration entries and "cache" them: - // - Chunk size in bits - $this->chunkSize = $this->getConfigInstance()->getConfigEntry('package_chunk_size'); - - // - Maximum serial number - $this->maxSerialNumber = $this->hex2dec(str_repeat('f', self::MAX_SERIAL_LENGTH)); - } - - /** - * Initializes the pointer for given final hash - * - * @param $finalHash Final hash to initialize pointer for - * @return void - */ - private function initPointer ($finalHash) { - $this->chunkPointers[$finalHash] = 0; - } - - /** - * "Getter" for processedPackages array index - * - * @param $packageData Raw package data array - * @return $index Array index for processedPackages - */ - private function getProcessedPackagesIndex (array $packageData) { - return ( - $packageData[NetworkPackage::PACKAGE_DATA_SENDER] . NetworkPackage::PACKAGE_DATA_SEPARATOR . - $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . NetworkPackage::PACKAGE_DATA_SEPARATOR . - $packageData[NetworkPackage::PACKAGE_DATA_CONTENT] . NetworkPackage::PACKAGE_DATA_SEPARATOR - ); - } - - /** - * Checks whether the given package data is already processed by this fragmenter - * - * @param $packageData Raw package data array - * @return $isProcessed Whether the package has been fragmented - */ - private function isPackageProcessed (array $packageData) { - // Get array index - $index = $this->getProcessedPackagesIndex($packageData); - - // Is the array index there? - $isProcessed = ( - (isset($this->processedPackages[$index])) - && - ($this->processedPackages[$index] === TRUE) - ); - - // Return it - return $isProcessed; - } - - /** - * Marks the given package data as processed by this fragmenter - * - * @param $packageData Raw package data array - * @return void - */ - private function markPackageDataProcessed (array $packageData) { - // Remember it (until we may remove it) - $this->processedPackages[$this->getProcessedPackagesIndex($packageData)] = TRUE; - } - - /** - * Getter for final hash from given package data - * - * @param $packageData Raw package data array - * @return $finalHash Final hash for package data - */ - private function getFinalHashFromPackageData (array $packageData) { - // Make sure it is there - assert(isset($this->processedPackages[$this->getProcessedPackagesIndex($packageData)])); - - // Return it - return $this->processedPackages[$this->getProcessedPackagesIndex($packageData)]; - } - - /** - * Get next chunk pointer for given final hash - * - * @param $finalHash Final hash to get current pointer for - */ - private function getCurrentChunkPointer ($finalHash) { - // Is the final hash valid? - assert(strlen($finalHash) > 0); - - // Is the pointer already initialized? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); - assert(isset($this->chunkPointers[$finalHash])); - - // Return it - return $this->chunkPointers[$finalHash]; - } - - /** - * Advance the chunk pointer for given final hash - * - * @param $finalHash Final hash to advance the pointer for - */ - private function nextChunkPointer ($finalHash) { - // Is the pointer already initialized? - assert(isset($this->chunkPointers[$finalHash])); - - // Count one up - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); - $this->chunkPointers[$finalHash]++; - } - - /** - * "Getter" for data chunk size of given hash. - * - * @param $hash Hash to substract it's length - * @return $dataChunkSize The chunk size - */ - private function getDataChunkSizeFromHash ($hash) { - // Calculate real (data) chunk size - $dataChunkSize = ( - // Real chunk size - ($this->chunkSize / 8) - - // Hash size - strlen($hash) - - // Length of sperators - (strlen(self::CHUNK_DATA_HASH_SEPARATOR) * 2) - - // Length of max serial number - self::MAX_SERIAL_LENGTH - ); - - // This should be larger than zero bytes - assert($dataChunkSize > 0); - - // Return it - return $dataChunkSize; - } - - /** - * Generates a hash from raw data - * - * @param $rawData Raw data bytes to hash - * @return $hash Hash from the raw data - * @todo Implement a way to send non-announcement packages with extra-salt - */ - private function generateHashFromRawData ($rawData) { - /* - * Get the crypto instance and hash the data with no extra salt because - * the other peer doesn't have *this* peer's salt. - */ - $hash = $this->getCryptoInstance()->hashString($rawData, '', FALSE); - - // Return it - return $hash; - } - - /** - * Appends an end-of-package chunk to the chunk list for given chunk and - * final hash. As of 23-March-2012 the format of this chunk will be as any - * regular one to keep things easy (KISS) in ChunkHandler class. - * - * @param $lastChunk Last chunk raw data - * @param $finalHash Final hash for raw (unencoded) data - * @return void - */ - private function appendEndOfPackageChunk ($lastChunk, $finalHash) { - // Generate end-of-package marker - $chunkData = - self::END_OF_PACKAGE_IDENTIFIER . - $finalHash . self::CHUNK_HASH_SEPARATOR . - $this->generateHashFromRawData($lastChunk); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...'); - - // Add it as regular chunk - $this->addChunkData($finalHash, $chunkData); - } - - /** - * Splits the given encoded data into smaller chunks, the size of the final - * and the SEPARATOR is being subtracted from chunk size to fit it into a - * TCP package (512 bytes). - * - * @param $rawData Raw data string - * @param $finalHash Final hash from the raw data - * @return void - */ - private function splitEncodedDataIntoChunks ($rawData, $finalHash) { - // Make sure final hashes with at least 32 bytes can pass - assert(strlen($finalHash) >= 32); - - // Calculate real (data) chunk size - $dataChunkSize = $this->getDataChunkSizeFromHash($finalHash); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: dataChunkSize=' . $dataChunkSize); - - // Init variables - $chunkHash = ''; - $chunkData = ''; - - // Now split it up - for ($idx = 0; $idx < strlen($rawData); $idx += $dataChunkSize) { - // Get the next chunk - $chunkData = substr($rawData, $idx, $dataChunkSize); - - // Add the chunk to the propper array and do all the stuff there - $this->addChunkData($finalHash, $chunkData); - } // END - for - - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).'); - - // Add end-of-package chunk - $this->appendEndOfPackageChunk($chunkData, $finalHash); - } - - /** - * Adds the given chunk (raw data) to the proper array and hashes it for - * later verfication. - * - * @param $finalHash Final hash for faster processing - * @param $chunkData Raw chunk data - * @param $prepend Whether append (default) or prepend the chunk - * @return void - */ - private function addChunkData ($finalHash, $chunkData, $prepend = FALSE) { - // Hash it - $rawDataHash = $this->getCryptoInstance()->hashString($chunkData, '', FALSE); - - // Prepend the hash to the chunk - $rawData = ( - $rawDataHash . self::CHUNK_DATA_HASH_SEPARATOR . - $this->getNextHexSerialNumber($finalHash) . self::CHUNK_DATA_HASH_SEPARATOR . - $chunkData . self::CHUNK_SEPARATOR - ); - - // Make sure the chunk is not larger than a TCP package can hold - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...'); - // @TODO This assert broke packages where the hash chunk was very large: assert(strlen($rawData) <= NetworkPackage::TCP_PACKAGE_SIZE); - - // Add it to the array - if ($prepend === TRUE) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); - array_unshift($this->chunkHashes[$finalHash], $rawDataHash); - array_unshift($this->chunks[$finalHash] , $rawData); - } else { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); - - // Is the array there? - if (!isset($this->chunks[$finalHash])) { - // Then initialize it - $this->chunks[$finalHash] = array(); - $this->chunkHashes[$finalHash] = array(); - } // END - if - - // Add both - array_push($this->chunks[$finalHash] , $rawData); - array_push($this->chunkHashes[$finalHash], $rawDataHash); - } - } - - /** - * Prepends a chunk (or more) with all hashes from all chunks + final chunk. - * - * @param $finalHash Final hash from the raw data - * @return void - */ - private function prependHashChunk ($finalHash) { - // "Implode" the whole array of hashes into one string - $rawData = self::HASH_CHUNK_IDENTIFIER . implode(self::CHUNK_HASH_SEPARATOR, $this->chunkHashes[$finalHash]); - - // Prepend chunk - $this->addChunkData($finalHash, $rawData, TRUE); - } - - /** - * "Getter" for the next hexadecimal-encoded serial number - * - * @param $finalHash Final hash - * @return $encodedSerialNumber The next hexadecimal-encoded serial number - */ - public function getNextHexSerialNumber ($finalHash) { - // Assert on maximum serial number length - assert(isset($this->serialNumber[$finalHash])); - assert($this->serialNumber[$finalHash] <= $this->maxSerialNumber); - - // Encode the current serial number - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]); - $encodedSerialNumber = $this->dec2Hex($this->serialNumber[$finalHash], self::MAX_SERIAL_LENGTH); - - // Count one up - $this->serialNumber[$finalHash]++; - - // Return the encoded serial number - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: encodedSerialNumber=' . $encodedSerialNumber); - return $encodedSerialNumber; - } - - /** - * This method does "implode" the given package data array into one long - * string, splits it into small chunks, adds a serial number and checksum - * to all chunks and prepends a chunk with all hashes only in it. It will - * return the final hash for faster processing of packages. - * - * @param $packageData Raw package data array - * @param $helperInstance An instance of a ConnectionHelper class - * @return $finalHash Final hash for faster processing - * @todo $helperInstance is unused - */ - public function fragmentPackageArray (array $packageData, ConnectionHelper $helperInstance) { - // Is this package already fragmented? - if (!$this->isPackageProcessed($packageData)) { - // First we need to "implode" the array - $rawData = implode(NetworkPackage::PACKAGE_DATA_SEPARATOR, $packageData); - - // Generate the final hash from the raw data (not encoded!) - $finalHash = $this->generateHashFromRawData($rawData); - - // Remember it - $this->processedPackages[$this->getProcessedPackagesIndex($packageData)] = $finalHash; - - // Init pointer and reset serial number - $this->initPointer($finalHash); - $this->resetSerialNumber($finalHash); - - // Split the encoded data into smaller chunks - $this->splitEncodedDataIntoChunks($rawData, $finalHash); - - // Prepend a chunk with all hashes together - $this->prependHashChunk($finalHash); - - // Mark the package as fragmented - $this->markPackageDataProcessed($packageData); - } else { - // Get the final hash from the package data - $finalHash = $this->getFinalHashFromPackageData($packageData); - } - - // Return final hash - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); - return $finalHash; - } - - /** - * This method gets the next chunk from the internal FIFO which should be - * sent to the given recipient. It will return an associative array where - * the key is the chunk hash and value the raw chunk data. - * - * @param $finalHash Final hash for faster lookup - * @return $rawDataChunk Raw package data chunk - * @throws AssertionException If $finalHash was not 'TRUE' - */ - public function getNextRawDataChunk ($finalHash) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash); - - try { - // Get current chunk index - $current = $this->getCurrentChunkPointer($finalHash); - } catch (AssertionException $e) { - // This may happen when the final hash is TRUE - if ($finalHash === TRUE) { - // Set current to null - $current = NULL; - } else { - // Throw the exception - throw $e; - } - } - - // If there is no entry left, return an empty array - if ((!isset($this->chunkHashes[$finalHash][$current])) || (!isset($this->chunks[$finalHash][$current]))) { - // No more entries found - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ' - No more entries found!'); - return array(); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ',chunkHashes()=' . count($this->chunkHashes[$finalHash]) .' - Entry choosen ...'); - - // Generate the array - $rawDataChunk = array( - $this->chunkHashes[$finalHash][$current] => $this->chunks[$finalHash][$current] - ); - - // Count one index up - $this->nextChunkPointer($finalHash); - - // Return the chunk array - return $rawDataChunk; - } - - /** - * Resets the serial number to zero for given final hash - * - * @param $finalHash Final hash to reset counter for - * @return void - */ - public function resetSerialNumber ($finalHash) { - // Final hash must be set - assert((is_string($finalHash)) && (!empty($finalHash))); - - // Reset/set serial number - $this->serialNumber[$finalHash] = 0; - } -} - -// [EOF] -?> diff --git a/application/hub/main/pools/.htaccess b/application/hub/main/pools/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/pools/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/pools/class_ b/application/hub/main/pools/class_ deleted file mode 100644 index 3a37f6987..000000000 --- a/application/hub/main/pools/class_ +++ /dev/null @@ -1,65 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Pool extends BasePool implements Poolable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listenerInstance A Listenable instance - * @return $poolInstance An instance a Poolable class - */ - public final static function create???Pool (Listenable $listenerInstance) { - // Get new instance - $poolInstance = new ???Pool(); - - // Set the application instance - $poolInstance->setListenerInstance($listenerInstance); - - // Return the prepared instance - return $poolInstance; - } - - /** - * Adds a listener instance to this pool - * - * @param $poolInstance An instance of a Listenable class - * @return void - * @todo 0% done - */ - public function addListener (Listenable $poolInstance) { - $this->partialStub('Need to implement this method. listenerInstance=' . $poolInstance->__toString()); - } -} - -// -?> diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php deleted file mode 100644 index b03caebb8..000000000 --- a/application/hub/main/pools/class_BasePool.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BasePool extends BaseHubSystem implements Visitable { - /** - * Socket array elements - */ - const SOCKET_ARRAY_RESOURCE = 'resource'; - const SOCKET_ARRAY_CONN_TYPE = 'connection_type'; - - /** - * A list of pool entries - */ - private $poolEntriesInstance = NULL; - - /** - * An array with all valid connection types - */ - private $connectionTypes = array(); - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init the pool entries - $this->poolEntriesInstance = ObjectFactory::createObjectByConfiguredName('pool_entries_list_class'); - - // Init array of connection types - $this->connectionTypes = array( - BaseConnectionHelper::CONNECTION_TYPE_INCOMING, - BaseConnectionHelper::CONNECTION_TYPE_OUTGOING, - BaseConnectionHelper::CONNECTION_TYPE_SERVER - ); - } - - /** - * Getter for pool entries instance - * - * @return $poolEntriesInstance An instance for pool entries (list) - */ - public final function getPoolEntriesInstance () { - return $this->poolEntriesInstance; - } - - /** - * Adds an instance to a pool segment - * - * @param $group Name of the pool group - * @param $poolSegment Name of the pool segment - * @param $visitableInstance An instance of a class that should bed added to the pool - * @return void - */ - protected final function addInstance ($group, $poolName, Visitable $visitableInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); - - // Make sure the group is not 'invalid' - assert($group != 'invalid'); - - // Is the pool group there? - if (!$this->getPoolEntriesInstance()->isGroupSet($group)) { - // Create the missing pool group - $this->getPoolEntriesInstance()->addGroup($group); - } // END - if - - // Add it to given pool group - $this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Adds an entry to the pool - * - * @param $poolEntry The new pool entry that should be added - * @return void - */ - protected final function addPoolEntry ($poolEntry) { - $this->getPoolEntriesInstance()->addEntry('pool', $poolEntry); - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); - - // Visit this pool - $visitorInstance->visitPool($this); - - // Do we have a registry instance for this visitor's iterator? - if (Registry::getRegistry()->instanceExists($visitorInstance->getVisitorMode() . '_pool_iterator')) { - // Get the instance from registry - $iteratorInstance = Registry::getRegistry()->getInstance($visitorInstance->getVisitorMode() . '_pool_iterator'); - } else { - // Get a new iterator instance - $iteratorInstance = ObjectFactory::createObjectByConfiguredName($visitorInstance->getVisitorMode() . '_pool_iterator_class', array($this->getPoolEntriesInstance())); - - // Add it to the registry - Registry::getRegistry()->addInstance($visitorInstance->getVisitorMode() . '_pool_iterator', $iteratorInstance); - } - - // Reset the counter - $iteratorInstance->rewind(); - - // Visit all registered entries - while ($iteratorInstance->valid()) { - // Get current entry - $poolEntry = $iteratorInstance->current(); - - // Is this entry visitable? - if ($poolEntry instanceof Visitable) { - // Visit this entry as well - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...'); - $poolEntry->accept($visitorInstance); - } else { - // Cannot visit this entry - $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . ', reason: not implementing Visitable.'); - } - - // Advance to next entry - $iteratorInstance->next(); - } // END - while - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); - } - - /** - * Gets the array from specified list - * - * @param $list The list identifier we should return - * @return $array The requested array - */ - protected final function getArrayFromList ($list) { - // Get the array - $array = $this->getPoolEntriesInstance()->getArrayFromList($list); - - // Return it - return $array; - } - - /** - * Checks whether the given connection type is valid - * - * @param $connectionType Type of connection, can be 'incoming', 'outgoing' or 'server' - * @return $isValid Whether the provided connection type is valid - */ - protected function isValidConnectionType ($connectionType) { - // Is it valid? - $isValid = in_array($connectionType, $this->connectionTypes, TRUE); - - // Return result - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/pools/listener/.htaccess b/application/hub/main/pools/listener/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/pools/listener/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/pools/listener/class_DefaultListenerPool.php b/application/hub/main/pools/listener/class_DefaultListenerPool.php deleted file mode 100644 index 82e5ced4a..000000000 --- a/application/hub/main/pools/listener/class_DefaultListenerPool.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DefaultListenerPool extends BasePool implements PoolableListener { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance A NodeHelper instance - * @return $listenerInstance An instance a prepared listener class - */ - public static final function createDefaultListenerPool (NodeHelper $nodeInstance) { - // Get new instance - $listenerInstance = new DefaultListenerPool(); - - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Adds a listener instance to this pool - * - * @param $listenerInstance An instance of a Listenable class - * @return void - */ - public function addListener (Listenable $listenerInstance) { - // Add this listener instance to the instance list - parent::addInstance($listenerInstance->getProtocolName(), 'listener', $listenerInstance); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput( - 'POOL[' . __METHOD__ . ':' . __LINE__ . ']: Listener ' . $listenerInstance->__toString() . - ' listening to ' . $listenerInstance->getListenAddress() . ':' . - $listenerInstance->getListenPort() . ' added to listener pool.' - ); - } - - /** - * Run the shutdown seqeuence by a Visitor Pattern - * - * @return void - */ - public function doShutdown () { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down listener pool - CALLED!'); - - // Get a new visitor - $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_listener_pool_visitor_class'); - - // Start visiting - $this->accept($visitorInstance); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down listener pool - EXIT!'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/pools/peer/.htaccess b/application/hub/main/pools/peer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/pools/peer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/pools/peer/class_DefaultPeerPool.php b/application/hub/main/pools/peer/class_DefaultPeerPool.php deleted file mode 100644 index 90e76fde8..000000000 --- a/application/hub/main/pools/peer/class_DefaultPeerPool.php +++ /dev/null @@ -1,283 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DefaultPeerPool extends BasePool implements PoolablePeer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listenerInstance A Listenable instance - * @return $poolInstance An instance a Poolable class - */ - public static final function createDefaultPeerPool (Listenable $listenerInstance) { - // Get new instance - $poolInstance = new DefaultPeerPool(); - - // Set the application instance - $poolInstance->setListenerInstance($listenerInstance); - - // Return the prepared instance - return $poolInstance; - } - - /** - * Validates given socket - * - * @param $socketResource A valid socket resource - * @return void - * @throws InvalidSocketException If the given socket has an error - */ - private function validateSocket ($socketResource) { - // Is it a valid resource? - if (!is_resource($socketResource)) { - // Throw an exception - throw new InvalidSocketException(array($this, $socketResource), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Get error code - $errorCode = socket_last_error($socketResource); - - // Is it without any errors? - if ($errorCode > 0) { - // Handle the socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); - /* - // Get error message - $errorMessage = socket_strerror($errorCode); - - // Shutdown this socket - $this->getListenerInstance()->shutdownSocket($socketResource); - - // And throw again - throw new InvalidSocketException(array($this, $socketResource, $errorCode, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - } - - /** - * Adds a socket resource to the peer pool - * - * @param $socketResource A valid (must be!) socket resource - * @param $connectionType Type of connection, can only be 'incoming', 'outgoing' or 'server' - * @return void - * @throws InvalidSocketException If the given resource is invalid or errorous - * @throws InvalidConnectionTypeException If the provided connection type is not valid - */ - public function addPeer ($socketResource, $connectionType) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DEFAULT-PEER-POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',connectionType=' . $connectionType . ' - CALLED!'); - - // Validate the socket - $this->validateSocket($socketResource); - - // Is the connection type valid? - if (!$this->isValidConnectionType($connectionType)) { - // Is not a valid connection type! - throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); - } // END - if - - // Default is this peer's IP - $peerName = '0.0.0.0'; - - // The socket resource should not match server socket - if ($socketResource != $this->getListenerInstance()->getSocketResource()) { - // Try to determine the peer's IP number - if (!socket_getpeername($socketResource, $peerName)) { - // Handle the socket error with a faked recipientData array - $this->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0')); - /* - // Get last error - $lastError = socket_last_error($socketResource); - - // Doesn't work! - throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET); - */ - } // END - if - } else { - // Server sockets won't work with socket_getpeername() - self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Socket resource is server socket (' . $socketResource . '). This is not a bug.'); - } - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Adding peer ' . $peerName . ',socketResource=' . $socketResource . ',type=' . $connectionType); - - // Construct the array - $socketArray = array( - self::SOCKET_ARRAY_RESOURCE => $socketResource, - self::SOCKET_ARRAY_CONN_TYPE => $connectionType - ); - - // Add it finally to the pool - $this->addPoolEntry($socketArray); - } - - /** - * Getter for array of all socket resources - * - * @return $sockets An array with all sockets - */ - public final function getAllSockets () { - // Get the list - $sockets = $this->getArrayFromList('pool'); - - // Return it - return $sockets; - } - - /** - * Getter for array of all socket arrays - * - * @return $sockets An array with all socket arrays - */ - public final function getAllSingleSockets () { - // Get the array list - $socketArrays = $this->getArrayFromList('pool'); - - // Init socket array - $sockets = array(); - - // "Walk" through all socket arrays - foreach ($socketArrays as $socketArray) { - // Add the socket - array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]); - } // END - foreach - - // Return it - return $sockets; - } - - /** - * "Getter" for all sockets of specified type - * - * @param $connectionType Type of connection, can only be 'incoming', 'outgoing' or 'server' - * @return $sockets An array with sockets of given type - * @throws InvalidConnectionTypeException If the provided connection type is not valid - */ - public function getSocketsByConnectionType ($connectionType) { - // Is the connection type valid? - if (!$this->isValidConnectionType($connectionType)) { - // Is not a valid connection type! - throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); - } // END - if - - // Get the array list - $socketArrays = $this->getArrayFromList('pool'); - - // Init socket array - $sockets = array(); - - // "Walk" through all socket arrays - foreach ($socketArrays as $socketArray) { - // Does it match? - if ($socketArray[self::SOCKET_ARRAY_CONN_TYPE] === $connectionType) { - // Add the socket - array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]); - } // END - if - } // END - foreach - - // Return it - return $sockets; - } - - /** - * "Getter" for a valid socket resource from given packae data. - * - * @param $packageData Raw package data - * @param $connectionType Type of connection, can be 'incoming', 'outgoing', 'server' or default - * @return $socketResource Socket resource - * @throws InvalidConnectionTypeException If the provided connection type is not valid - */ - public function getSocketFromPackageData (array $packageData, $connectionType = NULL) { - // Default is no socket - $socketResource = FALSE; - - // Resolve recipient (UNL) into a handler instance - $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData); - - // Get UNL data - $unlData = $handlerInstance->getUniversalNodeLocatorDataArray(); - - // Make sure it is a valid Universal Node Locator array (3 elements) - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS])); - assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT])); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),unlData[' . UniversalNodeLocator::UNL_PART_ADDRESS . ']=' . $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] . ',unlData[' . UniversalNodeLocator::UNL_PART_PORT . ']=' . $unlData[UniversalNodeLocator::UNL_PART_PORT] . ' ...'); - - // Default is all sockets - $sockets = $this->getAllSockets(); - - // Is connection type set? - if ((is_string($connectionType)) && ($this->isValidConnectionType($connectionType))) { - // Then get a list of this type - $sockets = $this->getSocketsByConnectionType($connectionType); - } elseif (is_string($connectionType)) { - // Is not a valid connection type! - throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); - } - - // Get all sockets and check them, skip the server socket - foreach ($sockets as $socketArray) { - // Is this a server socket? - if ($socketArray[self::SOCKET_ARRAY_RESOURCE] === $this->getListenerInstance()->getSocketResource()) { - // Skip 'server' sockets (local socket) - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Skipping server socket ' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ' ...'); - continue; - } // END - if - - // Try to get the "peer"'s name - if (!socket_getpeername($socketArray[self::SOCKET_ARRAY_RESOURCE], $peerIp)) { - // Handle the socket error with given package data - $this->handleSocketError(__METHOD__, __LINE__, $socketArray[self::SOCKET_ARRAY_RESOURCE], explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); - } // END - if - - // Get - // If the "peer" IP and recipient is same, use it - if ($peerIp == $unlData[UniversalNodeLocator::UNL_PART_ADDRESS]) { - // IPs match, so take the socket and quit this loop - $socketResource = $socketArray[self::SOCKET_ARRAY_RESOURCE]; - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: peerIp=' . $peerIp . ' matches with recipient IP address. Taking socket=' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[self::SOCKET_ARRAY_CONN_TYPE]); - break; - } // END - if - } // END - foreach - - // Return the determined socket resource - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource); - return $socketResource; - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/.htaccess b/application/hub/main/producer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/producer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/producer/class_ b/application/hub/main/producer/class_ deleted file mode 100644 index 52778e9e5..000000000 --- a/application/hub/main/producer/class_ +++ /dev/null @@ -1,59 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Producer extends BaseProducer implements Producer, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $producerInstance An instance of a Producer class - */ - public final static function create???Producer () { - // Get new instance - $producerInstance = new ???Producer(); - - // Return the prepared instance - return $producerInstance; - } - - /** - * Initializes the producer - * - * @return void - */ - protected function initProducer () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/class_BaseProducer.php b/application/hub/main/producer/class_BaseProducer.php deleted file mode 100644 index 8ac4cdfa1..000000000 --- a/application/hub/main/producer/class_BaseProducer.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseProducer extends BaseFrameworkSystem { - /** - * Outgoing work-queue - */ - private $outgoingQueueInstance = NULL; - - /** - * Incoming raw data/items queue - */ - private $incomingQueueInstance = NULL; - - /** - * Stacker name for incoming work - */ - const STACKER_NAME_IN_QUEUE = 'incoming_queue'; - - /** - * Stacker name for outgoing work - */ - const STACKER_NAME_OUT_QUEUE = 'outgoing_queue'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Initialize all producers - $this->initProducer(); - - // Get miner instance - $minerInstance = Registry::getRegistry()->getInstance('miner'); - - // Change state to next state - $minerInstance->blockProducerHasInitialized($this); - - // Initialize work queue (out-going, produced items) - $this->initWorkQueue(); - } - - /** - * Getter for outgoing work queue - * - * @param $outgoingQueueInstance The outgoing work queue instance - */ - protected final function getOutgoingQueueInstance () { - return $this->outgoingQueueInstance; - } - - /** - * Setter for outgoing work queue - * - * @param $outgoingQueueInstance The outgoing work queue instance - * @return void - */ - private final function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) { - $this->outgoingQueueInstance = $outgoingQueueInstance; - } - - /** - * Getter for incoming raw data/items queue - * - * @param $incomingQueueInstance The incoming raw data/items queue instance - */ - protected final function getIncomingQueueInstance () { - return $this->incomingQueueInstance; - } - - /** - * Setter for incoming raw data/items queue - * - * @param $incomingQueueInstance The incoming raw data/items queue instance - * @return void - */ - private final function setIncomingQueueInstance (Stackable $incomingQueueInstance) { - $this->incomingQueueInstance = $incomingQueueInstance; - } - - /** - * Initializes this producer, this method must be overwritten. - * - * @return void - */ - abstract protected function initProducer(); - - /** - * Initializes the work queue which is being used for outgoing, produced - * items. - * - * @return void - */ - protected function initWorkQueue () { - // Get an instance and set it in this producer - $this->setOutgoingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_outgoing_queue')); - - // Init the queue - $this->initOutgoingQueue(); - - // Get an instance and set it in this producer - $this->setIncomingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_incoming_queue')); - - // Init the queue - $this->initIncomingQueue(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: All queues have been initialized.'); - } - - /** - * Inits the out-going queue stack - * - * @return void - */ - protected function initOutgoingQueue () { - $this->getOutgoingQueueInstance()->initStack(self::STACKER_NAME_OUT_QUEUE, TRUE); - } - - /** - * Adds an entry to the out-going work queue - * - * @param $value The value to be added to the out-going work queue - * @return void - */ - protected function addValueToOutgoingQueue ($value) { - $this->getOutgoingQueueInstance()->pushNamed(self::STACKER_NAME_OUT_QUEUE, $value); - } - - /** - * Checks whether a configurable out-going queue limit has been reached - * - * @param $configEntry Configuration entry where the limit is stored - * @return $isReached Whether the limit is reached - */ - protected function isOutgoingQueueLimitReached ($configEntry) { - return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getOutgoingQueueInstance()->getStackCount(self::STACKER_NAME_OUT_QUEUE)); - } - - /** - * Inits the incoming queue stack - * - * @return void - */ - protected function initIncomingQueue () { - $this->getIncomingQueueInstance()->initStack(self::STACKER_NAME_IN_QUEUE, TRUE); - } - - /** - * Adds an entry to the incoming work queue - * - * @param $value The value to be added to the incoming work queue - * @return void - */ - protected function addValueToIncomingQueue ($value) { - $this->getIncomingQueueInstance()->pushNamed(self::STACKER_NAME_IN_QUEUE, $value); - } - - /** - * Checks whether a configurable incoming queue limit has been reached - * - * @param $configEntry Configuration entry where the limit is stored - * @return $isReached Whether the limit is reached - */ - protected function isIncomingQueueLimitReached($configEntry) { - return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getIncomingQueueInstance()->getStackCount(self::STACKER_NAME_IN_QUEUE)); - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/cruncher/.htaccess b/application/hub/main/producer/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/producer/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/producer/cruncher/class_BaseKeyProducer.php b/application/hub/main/producer/cruncher/class_BaseKeyProducer.php deleted file mode 100644 index 857193062..000000000 --- a/application/hub/main/producer/cruncher/class_BaseKeyProducer.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseKeyProducer extends BaseProducer { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init key producer - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/cruncher/class_BaseUnitProducer.php b/application/hub/main/producer/cruncher/class_BaseUnitProducer.php deleted file mode 100644 index c8fac2e5a..000000000 --- a/application/hub/main/producer/cruncher/class_BaseUnitProducer.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseUnitProducer extends BaseProducer { - /** - * Work/test unit status - */ - const UNIT_STATUS_AVAILABLE = 'available'; // Available for crunching - const UNIT_STATUS_PENDING = 'pending'; // Is being crunched at the moment - const UNIT_STATUS_DONE = 'done'; // Is already crunched/finished - - /** - * Work or test unit? - */ - const UNIT_TYPE_TEST_UNIT = 'test_unit'; - const UNIT_TYPE_TEST_WORK = 'work_unit'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/cruncher/keys/.htaccess b/application/hub/main/producer/cruncher/keys/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/producer/cruncher/keys/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php b/application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php deleted file mode 100644 index 4850d5e5d..000000000 --- a/application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $producerInstance An instance of a Producer class - */ - public final static function createCruncherKeyProducer () { - // Get new instance - $producerInstance = new CruncherKeyProducer(); - - // Get a helper instance, we now only need this for the key iterator - $helperInstance = ObjectFactory::createObjectByConfiguredName('crypto_random_message_helper_class', array('test')); - - // Next get an iterator, again the helper will do that for us - $iteratorInstance = $helperInstance->getKeyIterator(); - - // Set it in the producer - $producerInstance->setIteratorInstance($iteratorInstance); - - // Return the prepared instance - return $producerInstance; - } - - /** - * Initializes the producer. This method satisfies the abstract BaseProducer - * class. - * - * @return void - * @todo Find something for init phase of this key producer - */ - protected function initProducer () { - } - - /** - * Initializes the executor, whatever it does. - * - * @return void - * @todo 0% done - */ - public function initExecutor (Stateable $stateInstance) { - $this->partialStub('Maybe implement this method?'); - } - - /** - * Produces some keys and pushes them onto the queue - * - * @param $stateInstance An instance of a Stateable instance - * @return void - * @todo ~30% done - */ - public function produceKeys (Stateable $stateInstance) { - // Is this cruncher virgin? - if (!$stateInstance->isCruncherStateVirgin()) { - // This cruncher is not virgin, so skip it - self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: The cruncher is not virgin. stateInstance=' . $stateInstance->__toString() . ''); - return; - } elseif (!$this->getIteratorInstance()->valid()) { - // This producer's iterator has finished its assignment - self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: Finished creating keys. iteratorInstance=' . $this->getIteratorInstance()->__toString() . ''); - return; - } - - /* - * Now we need to create an iterator, just as for the work units, - * to create new keys from the encrypted message. The iterator will - * not iterate over an object nor a collection. It will instead - * encapsulate the "key production" into a class and not in a simple - * for() loop. These keys then needs to be bundled into test units - * and stored to database for later re-usage. - */ - - /* - * Get current key (which is not the key of the iterator) This is always - * an ASCII string. - */ - $currentKey = $this->getIteratorInstance()->current(); - - // Add it to the out-going work queue - $this->addValueToOutgoingQueue($currentKey); - - // Is the per-work unit limit reached? - if ($this->isOutgoingQueueLimitReached('cruncher_per_unit_key_limit')) { - // @TODO Send the produced key bundle to the unit producer's input queue - self::createDebugInstance(__CLASS__)->debugOutput('currentKey(b64)="' . base64_encode($currentKey) . '" needs to be processed.'); - - // At last re-init the stack - $this->initOutgoingQueue(); - } // END - if - - // Continue with next one - $this->getIteratorInstance()->next(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/cruncher/work_units/.htaccess b/application/hub/main/producer/cruncher/work_units/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/producer/cruncher/work_units/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php deleted file mode 100644 index 4014b5f79..000000000 --- a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $producerInstance An instance of a Producer class - */ - public final static function createCruncherTestUnitProducer () { - // Get new instance - $producerInstance = new CruncherTestUnitProducer(); - - // Test units have a helper class that wraps the source - $helperInstance = ObjectFactory::createObjectByConfiguredName('crypto_random_message_helper_class', array('test')); - - // So set it in the producer - $producerInstance->setHelperInstance($helperInstance); - - // Return the prepared instance - return $producerInstance; - } - - /** - * Initializes the producer. This method satisfies the abstract BaseProducer - * class. - * - * @return void - */ - protected function initProducer () { - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('cruncher_test_unit_producer_template_class'); - - // Load the template - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - - // And set it in this cruncher - $this->setTemplateInstance($templateInstance); - } - - /** - * Prepares the produces of some test units and pushes them onto the queue - * - * @param $stateInstance An instance of a Stateable instance - * @return void - * @todo ~60% done - */ - public function initUnitProduction (Stateable $stateInstance) { - // First get a database wrapper because we want to permanently store test units - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('cruncher_unit_db_wrapper_class'); - - // Do we have some entries? - if ($wrapperInstance->isTestUnitProduced()) { - // Entries found - // @TODO Unfinished work here - $this->debugInstance(); - - // The state must be changed because ... - $stateInstance->someFooStateChange(); - } else { - // Get an encrypted, random message from our source - $encryptedMessage = $this->getHelperInstance()->generateRandomMessage(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: An encrypted, random message has been generated. Generating keys ...'); - - // Set the encrypted message in the template instance - $this->getTemplateInstance()->assignVariable('encrypted_message', $encryptedMessage); - - // The state must be changed because we have a new message - $stateInstance->encryptedMessageGenerated(); - } - } - - /** - * Initializes the executor, whatever it does. - * - * @return void - * @todo Maybe unfinished - */ - public function initExecutor (Stateable $stateInstance) { - $this->partialStub('Maybe implement this method?'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/miner/.htaccess b/application/hub/main/producer/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/producer/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/producer/miner/blocks/.htaccess b/application/hub/main/producer/miner/blocks/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/producer/miner/blocks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/producer/miner/blocks/class_MinerRealGenesisBlockProducer.php b/application/hub/main/producer/miner/blocks/class_MinerRealGenesisBlockProducer.php deleted file mode 100644 index 0abd16c37..000000000 --- a/application/hub/main/producer/miner/blocks/class_MinerRealGenesisBlockProducer.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerRealGenesisBlockProducer extends BaseBlockProducer implements BlockProducer, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $producerInstance An instance of a Producer class - */ - public final static function createMinerRealGenesisBlockProducer () { - // Get new instance - $producerInstance = new MinerRealGenesisBlockProducer(); - - // Get a (minable) hash block instance - $minableInstance = ObjectFactory::createObjectByConfiguredName('miner_real_hash_block_class'); - - // Set it here - $producerInstance->setMinableInstance($minableInstance); - - // Return the prepared instance - return $producerInstance; - } - - /** - * Initializes the producer. This method satisfies the abstract BaseProducer - * class. - * - * @return void - * @todo 0% done - */ - protected function initProducer () { - $this->partialStub('Please implement this method.'); - } - - /** - * Initializes the executor, whatever it does. - * - * @return void - * @todo 0% done - */ - public function initExecutor (Stateable $stateInstance) { - $this->partialStub('Please implement this method.'); - } - - /** - * Prepares the produces of some test units and pushes them onto the queue - * - * @param $stateInstance An instance of a Stateable instance - * @return void - * @todo ~5% done - */ - public function prepareBlockProduction (Stateable $stateInstance) { - // The state must be 'booting' - $stateInstance->validateMinerStateIsBooting(); - - /* - * Now that the miner is booting a genesis block for real mining can be - * created. - */ - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/miner/blocks/class_MinerTestGenesisBlockProducer.php b/application/hub/main/producer/miner/blocks/class_MinerTestGenesisBlockProducer.php deleted file mode 100644 index fbf80a39f..000000000 --- a/application/hub/main/producer/miner/blocks/class_MinerTestGenesisBlockProducer.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerTestGenesisBlockProducer extends BaseBlockProducer implements BlockProducer, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $producerInstance An instance of a Producer class - */ - public final static function createMinerTestGenesisBlockProducer () { - // Get new instance - $producerInstance = new MinerTestGenesisBlockProducer(); - - // Get a (minable) hash block instance - $minableInstance = ObjectFactory::createObjectByConfiguredName('miner_test_hash_block_class'); - - // Set it here - $producerInstance->setMinableInstance($minableInstance); - - // Return the prepared instance - return $producerInstance; - } - - /** - * Initializes the producer. This method satisfies the abstract BaseProducer - * class. - * - * @return void - * @todo 0% done - */ - protected function initProducer () { - $this->partialStub('Please implement this method.'); - } - - /** - * Initializes the executor, whatever it does. - * - * @return void - * @todo 0% done - */ - public function initExecutor (Stateable $stateInstance) { - $this->partialStub('Please implement this method.'); - } - - /** - * Prepares the produces of some test units and pushes them onto the queue - * - * @param $stateInstance An instance of a Stateable instance - * @return void - * @todo ~5% done - */ - public function prepareBlockProduction (Stateable $stateInstance) { - // The state must be 'booting' - $stateInstance->validateMinerStateIsBooting(); - - /* - * Now that the miner is booting a "genesis" block for testing purposes - * can be created. The real "genesis" block will be created differently - * to this. - */ - } -} - -// [EOF] -?> diff --git a/application/hub/main/producer/miner/class_BaseBlockProducer.php b/application/hub/main/producer/miner/class_BaseBlockProducer.php deleted file mode 100644 index 4ed231824..000000000 --- a/application/hub/main/producer/miner/class_BaseBlockProducer.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseBlockProducer extends BaseProducer { - /** - * Block status - */ - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/queries/.htaccess b/application/hub/main/queries/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/queries/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/queries/class_ b/application/hub/main/queries/class_ deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/queries/class_ +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/queries/local/.htaccess b/application/hub/main/queries/local/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/queries/local/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/queues/.htaccess b/application/hub/main/queues/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/queues/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/queues/class_ b/application/hub/main/queues/class_ deleted file mode 100644 index f551ef47b..000000000 --- a/application/hub/main/queues/class_ +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/application/hub/main/queues/peer/.htaccess b/application/hub/main/queues/peer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/queues/peer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/recipient/.htaccess b/application/hub/main/recipient/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/recipient/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/recipient/class_ b/application/hub/main/recipient/class_ deleted file mode 100644 index d85e73e9c..000000000 --- a/application/hub/main/recipient/class_ +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Recipient extends BaseRecipient implements Recipient { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $recipientInstance An instance of a Recipient class - */ - public final static function create???Recipient () { - // Get new instance - $recipientInstance = new ???Recipient(); - - // Return the prepared instance - return $recipientInstance; - } - - /** - * Tries to resolve given recipient into session ids or Universal Node Locator - * depending on implementation (hint: Template Method Pattern) - * - * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) - * @param $listInstance An instance of a Listable class - * @return $resolved Resolved recipient or VOID if only the set list has been filled - * @throws FrameworkException Could throw different exceptions back depending on implementation - * @todo 0% done - */ - public function resolveRecipient ($recipient, Listable $listInstance) { - // Make sure the recipient is valid - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('!!!-RECIPIENT: recipient=' . $recipient); - assert($recipient == '|||'); - $this->partialStub('Please implement this method. recipient=' . $recipient); - } -} - -// [EOF] -?> diff --git a/application/hub/main/recipient/class_BaseRecipient.php b/application/hub/main/recipient/class_BaseRecipient.php deleted file mode 100644 index bdcf99319..000000000 --- a/application/hub/main/recipient/class_BaseRecipient.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseRecipient extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/recipient/dht/.htaccess b/application/hub/main/recipient/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/recipient/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/recipient/dht/class_DhtRecipient.php b/application/hub/main/recipient/dht/class_DhtRecipient.php deleted file mode 100644 index e8f213966..000000000 --- a/application/hub/main/recipient/dht/class_DhtRecipient.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtRecipient extends BaseRecipient implements Recipient { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $recipientInstance An instance of a Recipient class - */ - public final static function createDhtRecipient () { - // Get new instance - $recipientInstance = new DhtRecipient(); - - // Return the prepared instance - return $recipientInstance; - } - - /** - * Tries to resolve given recipient into session ids or Universal Node Locator - * depending on implementation (hint: Template Method Pattern). This - * implementation will add more than one recipient to the list as a DHT is - * distributed and the package might go to more than one recipient. - * - * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) - * @param $listInstance An instance of a Listable class - * @param $packageData Valid package data array - * @return void - * @throws FrameworkException Could throw different exceptions depending on implementation - */ - public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient . ' - CALLED!'); - - // Make sure the recipient is valid - assert($recipient == NetworkPackage::NETWORK_TARGET_DHT); - - // Get recipient discovery instance - $discoverInstance = ObjectFactory::createObjectByConfiguredName('dht_recipient_discovery_class'); - - // "Discover" recipients by given package data - $recipients = $discoverInstance->resolveRecipientsByPackageData($packageData); - - // Now "walk" through all elements and add them to the list - foreach ($recipients as $recipient) { - // These array elements must exist for this loop: - // @TODO Unfinished - die(__METHOD__ . ':recipient=' . print_r($recipient, TRUE)); - assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])); - - // Put ip and port both together - $unl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]; - - // Add it to the list - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: Calling listInstance->addEntry(' . $unl . ') ...'); - $listInstance->addEntry('unl', $unl); - } // END - foreach - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient . ' - EXIT!'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/recipient/direct/.htaccess b/application/hub/main/recipient/direct/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/recipient/direct/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/recipient/direct/class_DirectRecipient.php b/application/hub/main/recipient/direct/class_DirectRecipient.php deleted file mode 100644 index 2c26a97c1..000000000 --- a/application/hub/main/recipient/direct/class_DirectRecipient.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DirectRecipient extends BaseRecipient implements Recipient { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $recipientInstance An instance of a Recipient class - */ - public final static function createDirectRecipient () { - // Get new instance - $recipientInstance = new DirectRecipient(); - - // Return the prepared instance - return $recipientInstance; - } - - /** - * Tries to resolve given recipient into session ids or Universal Node Locator - * depending on implementation (hint: Template Method Pattern) - * - * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) - * @param $listInstance An instance of a Listable class - * @param $packageData Valid package data array - * @return $resolved Resolved recipient or VOID if only the set list has been filled - * @throws FrameworkException Could throw different exceptions depending on implementation - */ - public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient); - - // "Explode" all recipients - $recipients = explode(NetworkPackage::PACKAGE_RECIPIENT_SEPARATOR, $recipient); - - // Is maximum reached? - assert(count($recipients) <= $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')); - - // Try it on all - foreach ($recipients as $recipient) { - // Try to sole a single recipient - $unlData = HubTools::resolveSessionId($recipient); - - // Add it as recipient - $listInstance->addEntry('unl', $unlData); - } // END - foreach - } -} - -// [EOF] -?> diff --git a/application/hub/main/recipient/self/.htaccess b/application/hub/main/recipient/self/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/recipient/self/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/recipient/self/class_SelfRecipient.php b/application/hub/main/recipient/self/class_SelfRecipient.php deleted file mode 100644 index 2f83c757b..000000000 --- a/application/hub/main/recipient/self/class_SelfRecipient.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SelfRecipient extends BaseRecipient implements Recipient { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $recipientInstance An instance of a Recipient class - */ - public final static function createSelfRecipient () { - // Get new instance - $recipientInstance = new SelfRecipient(); - - // Return the prepared instance - return $recipientInstance; - } - - /** - * Tries to resolve given recipient into session ids or Universal Node Locator - * depending on implementation (hint: Template Method Pattern) - * - * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) - * @param $listInstance An instance of a Listable class - * @param $packageData Valid package data array - * @return $resolved Resolved recipient or VOID if only the set list has been filled - * @throws FrameworkException Could throw different exceptions depending on implementation - */ - public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { - // Make sure the recipient is valid - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SELF-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient); - // @TODO Add more checks on data - assert($recipient == NetworkPackage::NETWORK_TARGET_SELF); - - // Determine IP or 'external_address' if set - $unl = HubTools::determineOwnExternalAddress(); - - // Is it not empty? - if (!empty($unl)) { - // Add it to the list - $listInstance->addEntry('unl', $unl); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/recipient/upper/.htaccess b/application/hub/main/recipient/upper/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/recipient/upper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/recipient/upper/class_UpperRecipient.php b/application/hub/main/recipient/upper/class_UpperRecipient.php deleted file mode 100644 index 026c6eeae..000000000 --- a/application/hub/main/recipient/upper/class_UpperRecipient.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UpperRecipient extends BaseRecipient implements Recipient { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $recipientInstance An instance of a Recipient class - */ - public final static function createUpperRecipient () { - // Get new instance - $recipientInstance = new UpperRecipient(); - - // Return the prepared instance - return $recipientInstance; - } - - /** - * Tries to resolve given recipient into session ids or Universal Node Locator - * depending on implementation (hint: Template Method Pattern) - * - * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) - * @param $listInstance An instance of a Listable class - * @param $packageData Valid package data array - * @return $resolved Resolved recipient or VOID if only the set list has been filled - * @throws FrameworkException Could throw different exceptions depending on implementation - */ - public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { - // Make sure the recipient is valid - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UPPER-RECIPIENT: recipient=' . $recipient); - assert($recipient == NetworkPackage::NETWORK_TARGET_UPPER); - - // Get all bootstrap nodes - foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlData) { - // Is maximum reached? - if ($listInstance->count() == $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')) { - // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER[' . __METHOD__ . ':' . __LINE__ . ']: Going to abort at maximum of ' . $this->getConfigInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!'); - - // Then stop adding more - break; - } // END - if - - // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER[' . __METHOD__ . ':' . __LINE__ . ']: Adding node ' . print_r($unlData, TRUE) . ' as recipient.'); - - // Add the entry - $listInstance->addEntry('unl', $unlData); - } // END - foreach - } -} - -// [EOF] -?> diff --git a/application/hub/main/registry/.htaccess b/application/hub/main/registry/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/registry/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/registry/objects/.htaccess b/application/hub/main/registry/objects/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/registry/objects/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/registry/objects/class_ObjectTypeRegistry.php b/application/hub/main/registry/objects/class_ObjectTypeRegistry.php deleted file mode 100644 index 8df6eb9dc..000000000 --- a/application/hub/main/registry/objects/class_ObjectTypeRegistry.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ObjectTypeRegistry extends BaseRegistry implements Register { - /** - * Instance of this class - */ - private static $registryInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Singleton method, we really only need one instance of this class. - * - * @return $registryInstance Instance of this class - */ - public static final function createObjectTypeRegistry () { - // Is an instance there? - if (is_null(self::$registryInstance)) { - // Not yet, so create one - self::$registryInstance = new ObjectTypeRegistry(); - } // END - if - - // Return the instance - return self::$registryInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/registry/socket/.htaccess b/application/hub/main/registry/socket/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/registry/socket/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/registry/socket/class_SocketRegistry.php b/application/hub/main/registry/socket/class_SocketRegistry.php deleted file mode 100644 index a420ecaa5..000000000 --- a/application/hub/main/registry/socket/class_SocketRegistry.php +++ /dev/null @@ -1,338 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketRegistry extends BaseRegistry implements Register, RegisterableSocket { - // Exception constants - const SOCKET_NOT_REGISTERED = 0xd200; - - /** - * Instance of this class - */ - private static $registryInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates a singleton instance of this registry class - * - * @return $registryInstance An instance of this class - */ - public static final function createSocketRegistry () { - // Is an instance there? - if (is_null(self::$registryInstance)) { - // Not yet, so create one - self::$registryInstance = new SocketRegistry(); - } // END - if - - // Return the instance - return self::$registryInstance; - } - - /** - * "Getter" to get a string respresentation for a key for the sub-registry - * in this format: class:type:port - * - * @param $infoInstance An instance of a ShareableInfo class - * @return $key A string representation of the socket for the registry - */ - private function getSubRegistryKey (ShareableInfo $infoInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); - - // Get address and port - $address = $infoInstance->getAddress(); - $port = $infoInstance->getPort(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: address=' . $address . ',port=' . $port); - - // Get connection type and port number and add both together - $key = sprintf('%s:%s:%s:%s', - $infoInstance->__toString(), - $infoInstance->getProtocolName(), - $address, - $port - ); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!'); - - // Return resulting key - return $key; - } - - /** - * "Getter" to get a string respresentation of the listener - * - * @param $infoInstance An instance of a ShareableInfo class - * @return $key A string representation of the listener for the registry - */ - private function getRegistryKeyFromInfo (ShareableInfo $infoInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); - - // Get the key - $key = $infoInstance->getProtocolName(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!'); - - // Return resulting key - return $key; - } - - /** - * Checks whether the shared connection info is registered - * - * @param $infoInstance An instance of a ShareableInfo class - * @return $isRegistered Whether the listener is registered - */ - private function isInfoRegistered (ShareableInfo $infoInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ' - CALLED!'); - - // Get the key - $key = $this->getRegistryKeyFromInfo($infoInstance); - - // Determine it - $isRegistered = $this->instanceExists($key); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); - - // Return result - return $isRegistered; - } - - /** - * Checks whether given socket resource is registered. If $socketResource is - * FALSE only the instance will be checked. - * - * @param $infoInstance An instance of a ShareableInfo class - * @param $socketResource A valid socket resource - * @return $isRegistered Whether the given socket resource is registered - */ - public function isSocketRegistered (ShareableInfo $infoInstance, $socketResource) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - CALLED!'); - - // Default is not registered - $isRegistered = FALSE; - - // First, check for the instance, there can be only once - if ($this->isInfoRegistered($infoInstance)) { - // That one is found so "get" a registry key from it - $key = $this->getRegistryKeyFromInfo($infoInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...'); - - // Get the registry - $registryInstance = $this->getInstance($key); - - // "Get" a key for the socket - $socketKey = $this->getSubRegistryKey($infoInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...'); - - // Is it there? - if ($registryInstance->instanceExists($socketKey)) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey)); - - // Get the instance - $registeredInstance = $registryInstance->getInstance($socketKey); - - // Is it SocketContainer and same socket? - $isRegistered = (($registeredInstance instanceof SocketContainer) && ($registeredInstance->ifSocketResourceMatches($socketResource))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Final result: isRegistered(' . $socketResource . ')=' . intval($isRegistered)); - } // END - if - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); - - // Return the result - return $isRegistered; - } - - /** - * Registeres given socket for listener or throws an exception if it is already registered - * - * @param $infoInstance An instance of a ShareableInfo class - * @param $socketResource A valid socket resource - * @param $packageData Optional raw package data - * @throws SocketAlreadyRegisteredException If the given socket is already registered - * @return void - */ - public function registerSocket (ShareableInfo $infoInstance, $socketResource, array $packageData = array()) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:info=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - CALLED!'); - - // Is the socket already registered? - if ($this->isSocketRegistered($infoInstance, $socketResource)) { - // Throw the exception - throw new SocketAlreadyRegisteredException(array($infoInstance, $socketResource), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED); - } // END - if - - // Does the instance exist? - if (!$this->isInfoRegistered($infoInstance)) { - // No, not found so we create a sub registry (not needed to configure!) - $registryInstance = SubRegistry::createSubRegistry(); - - // Now we can create the sub-registry for this info - $this->addInstance($this->getRegistryKeyFromInfo($infoInstance), $registryInstance); - } else { - // Get the sub-registry back - $registryInstance = $this->getInstance($this->getRegistryKeyFromInfo($infoInstance)); - } - - // Get a key for sub-registries - $socketKey = $this->getSubRegistryKey($infoInstance); - - // Get a socket container - $socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $infoInstance, $packageData)); - - // We have a sub-registry, the socket key and the socket, now we need to put all together - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...'); - $registryInstance->addInstance($socketKey, $socketInstance); - } - - /** - * Getter for given listener's socket resource - * - * @param $listenerInstance An instance of a Listenable class - * @return $socketResource A valid socket resource - * @throws NoSocketRegisteredException If the requested socket is not registered - */ - public function getRegisteredSocketResource (Listenable $listenerInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ' - CALLED!'); - - // The socket must be registered before we can return it - if (!$this->isInfoRegistered($listenerInstance)) { - // Throw the exception - throw new NoSocketRegisteredException ($listenerInstance, self::SOCKET_NOT_REGISTERED); - } // END - if - - // Now get the key from the listener - $key = $this->getRegistryKeyFromInfo($listenerInstance); - - // And get the registry - $registryInstance = $this->getInstance($key); - - // Get a socket key - $socketKey = $this->getSubRegistryKey($listenerInstance); - - // And the final socket resource - $socketResource = $registryInstance->getInstance($socketKey)->getSocketResource(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!'); - - // Return the resource - return $socketResource; - } - - /** - * "Getter" for info instance from given package data - * - * @param $packageData Raw package data - * @return $infoInstance An instance of a ShareableInfo class - */ - public function getInfoInstanceFromPackageData (array $packageData) { - // Init info instance - $infoInstance = NULL; - //* DEBUG-DIE: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE)); - - // Get all keys and check them - foreach ($this->getInstanceRegistry() as $key => $registryInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString()); - - // This is always a SubRegistry instance - foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString()); - - // Is this a SocketContainer instance and is the address the same? - if (($containerInstance instanceof SocketContainer) && ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]))) { - // Debug die - //* DEBUG-DIE: */ die(__METHOD__ . ': containerInstance=' . print_r($containerInstance, TRUE)); - - // Get listener and helper instances - $listenerInstance = $containerInstance->getListenerInstance(); - $helperInstance = $containerInstance->getHelperInstance(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance)); - - // Is a listener or helper set? - if ($listenerInstance instanceof Listenable) { - // Found a listener, so get the info instance first - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($listenerInstance->getProtocolName(), 'helper'); - - // Fill info instance with listener data - $infoInstance->fillWithListenerInformation($listenerInstance); - } elseif ($helperInstance instanceof ConnectionHelper) { - // Found a helper, so get the info instance first - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($helperInstance->getProtocolName(), 'helper'); - - // Helper is found - $infoInstance->fillWithConnectionHelperInformation($helperInstance); - } else { - // Not supported state! - $this->debugInstance('[' . __METHOD__ . ':' . __LINE__ . ']: Invalid state found, please report this to the developers with full debug infos.' . PHP_EOL); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',infoInstance[' . gettype($infoInstance) . ']=' . $infoInstance->__toString() . ' with protocol ' . $infoInstance->getProtocolName() . ' - FOUND!'); - break; - } // END - if - } // END - foreach - - // Is no longer NULL set? - if (!is_null($infoInstance)) { - // Then skip here, too - break; - } // END - if - } // END - foreach - - // Return the info instance - return $infoInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/.htaccess b/application/hub/main/resolver/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/command/.htaccess b/application/hub/main/resolver/command/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/command/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/command/console/.htaccess b/application/hub/main/resolver/command/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/command/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php b/application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php deleted file mode 100644 index 2343d40c4..000000000 --- a/application/hub/main/resolver/command/console/class_HubConsoleCommandResolver.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleCommandResolver extends BaseCommandResolver implements CommandResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "HubConsole" - $this->setClassPrefix('hub_console'); - } - - /** - * Creates an instance of a HubConsole command resolver with a given default command - * - * @param $commandName The default command we shall execute - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidCommandException Thrown if default command is invalid - */ - public static final function createHubConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new HubConsoleCommandResolver(); - - // Is the variable $commandName set and the command is valid? - if (empty($commandName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { - // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/controller/.htaccess b/application/hub/main/resolver/controller/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/controller/console/.htaccess b/application/hub/main/resolver/controller/console/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php b/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php deleted file mode 100644 index 2a73ee255..000000000 --- a/application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "HubConsole" - $this->setClassPrefix('hub_console'); - } - - /** - * Creates an instance of a resolver class with a given command - * - * @param $controllerName The controller we shall resolve - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidControllerException Thrown if default controller is invalid - */ - public static final function createHubConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new HubConsoleControllerResolver(); - - // Is the variable $controllerName set and the command is valid? - if (empty($controllerName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid command found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Set command name - $resolverInstance->setControllerName($controllerName); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/controller/html/.htaccess b/application/hub/main/resolver/controller/html/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/controller/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/controller/html/class_HubHtmlControllerResolver.php b/application/hub/main/resolver/controller/html/class_HubHtmlControllerResolver.php deleted file mode 100644 index 738aa3a2c..000000000 --- a/application/hub/main/resolver/controller/html/class_HubHtmlControllerResolver.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubHtmlControllerResolver extends BaseControllerResolver implements ControllerResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to 'Web' - $this->setClassPrefix('Web'); - } - - /** - * Creates an instance of a resolver class with a given command - * - * @param $controllerName The controller we shall resolve - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidControllerException Thrown if default controller is invalid - */ - public static final function createHubHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new HubHtmlControllerResolver(); - - // Is the variable $controllerName set and the command is valid? - if (empty($controllerName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid command found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Set command name - $resolverInstance->setControllerName($controllerName); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/protocol/.htaccess b/application/hub/main/resolver/protocol/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/protocol/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/protocol/class_ b/application/hub/main/resolver/protocol/class_ deleted file mode 100644 index ccc83ffcc..000000000 --- a/application/hub/main/resolver/protocol/class_ +++ /dev/null @@ -1,84 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class !!!ProtocolResolver extends BaseProtocolResolver implements ProtocolResolver, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of a !!! protocol resolver - * - * @return $resolverInstance The prepared command resolver instance - */ - public static final function create!!!ProtocolResolver () { - // Create the new instance - $resolverInstance = new !!!ProtocolResolver(); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an instance of a LocateableNode class for a given NodeHelper - * instance or null if it was not found. - * - * @param $nodeInstance An instance of a NodeHelper class - * @return $unlInstance An instance of a LocateableNode class - * @todo 0% done - */ - public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) { - $this->partialStub('Please implement this method. nodeInstance=' . $nodeInstance->__toString()); - } - - /** - * Returns the UNL as string from given configuration key. - * - * @param $configKey Configuration key for UNL address (valid: internal,external) - * @return $unl Universal node locator - * @todo 90% done - */ - public function resolveUniversalNodeLocatorFromConfigKey ($configKey) { - // Put all together - $unl = sprintf('%s://%s', - $this->getProtocolName(), - $this->getConfigInstance()->getConfigEntry($configKey . '_address') - ); - - /* - * And return it. Please note that e.g. a FaxProtocolResolver will - * return a different UNL and therefore all protocol resolvers must do - * it on their own way. - */ - return $unl; - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/protocol/class_BaseProtocolResolver.php b/application/hub/main/resolver/protocol/class_BaseProtocolResolver.php deleted file mode 100644 index 966971b08..000000000 --- a/application/hub/main/resolver/protocol/class_BaseProtocolResolver.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseProtocolResolver extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/protocol/tcp/.htaccess b/application/hub/main/resolver/protocol/tcp/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/protocol/tcp/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php b/application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php deleted file mode 100644 index a7f79e98c..000000000 --- a/application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolver, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set protocol type - $this->setProtocolName('tcp'); - } - - /** - * Creates an instance of a TCP protocol resolver - * - * @return $resolverInstance The prepared command resolver instance - */ - public static final function createTcpProtocolResolver () { - // Create the new instance - $resolverInstance = new TcpProtocolResolver(); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an instance of a LocateableNode class for a given NodeHelper - * instance or null if it was not found. - * - * @param $nodeInstance An instance of a NodeHelper class - * @return $unlInstance An instance of a LocateableNode class - * @todo 0% done - */ - public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) { - // Get search instance (to lookup database result) - $searchInstance = $nodeInstance->getSearchInstance(); - - // Make sure the in stance is valid - assert($searchInstance instanceof SearchCriteria); - - // Refetch and rewind iterator - $resultInstance = $nodeInstance->getWrapperInstance()->doSelectByCriteria($searchInstance); - - // Is the result valid? - if ((!$resultInstance->valid()) || (!$resultInstance->next())) { - // Node not found in database, this could mean that your database file is damaged. - return NULL; - } // END - if - - // Get current entry - $current = $resultInstance->current(); - - // This should always be the case, if not your database file might be damaged. - assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]); - - // Get UNL instance and handle over all data - $unlInstance = ObjectFactory::createObjectByConfiguredName('universal_node_locator_class', array($current)); - - // Return resolved instance - return $unlInstance; - } - - /** - * Returns the UNL as string from given configuration key. - * - * @param $configKey Configuration key for UNL address (valid: internal,external) - * @return $unl Universal node locator - */ - public function resolveUniversalNodeLocatorFromConfigKey ($configKey) { - // Get address - $address = $this->getConfigInstance()->getConfigEntry($configKey . '_address'); - - // Is the address empty? - if (empty($address)) { - // Okay, then find it - switch ($configKey) { - case 'external': // External IP - $address = ConsoleTools::determineExternalAddress(); - break; - - case 'internal': // Internal IP - $address = ConsoleTools::acquireSelfIPAddress(); - break; - } // END - switch - } // END - if - - // Put all together - $unl = sprintf('%s://%s:%s', - $this->getProtocolName(), - $address, - $this->getConfigInstance()->getConfigEntry('node_listen_port') - ); - - /* - * And return it. Please note that e.g. a FaxProtocolResolver will - * return a different UNL and therefore all protocol resolvers must do - * it on their own way. - */ - return $unl; - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/state/.htaccess b/application/hub/main/resolver/state/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/state/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/state/class_BaseStateResolver.php b/application/hub/main/resolver/state/class_BaseStateResolver.php deleted file mode 100644 index 8744b7156..000000000 --- a/application/hub/main/resolver/state/class_BaseStateResolver.php +++ /dev/null @@ -1,165 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseStateResolver extends BaseResolver { - /** - * Prefix for local, remote or other resolver - */ - private $statePrefix = ''; - - /** - * Validated state name - */ - private $stateName = ''; - - /** - * Protected constructor - * - * @param $className Name of the real class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for state prefix - * - * @param $statePrefix Last validated statePrefix - * @return void - */ - protected final function setStatePrefix ($statePrefix) { - $this->statePrefix = $statePrefix; - } - - /** - * Getter for state prefix - * - * @param $statePrefix Last validated statePrefix - * @return void - */ - protected final function getStatePrefix () { - return $this->statePrefix; - } - - /** - * Setter for state name - * - * @param $stateName Last validated state name - * @return void - */ - protected final function setStateName ($stateName) { - $this->stateName = $stateName; - } - - /** - * Getter for state name - * - * @return $stateName Last validated state name - */ - public final function getStateName () { - return $this->stateName; - } - - /** - * "Loads" a given state and instances it if not yet cached. If the - * state was not found an UnresolveableStateException is thrown - * - * @param $stateName A state name we shall look for - * @return $stateInstance A loaded state instance - * @throws UnresolveableStateException Thrown if even the requested - * state class is missing (bad!) - */ - protected function loadState ($stateName) { - // Init state instance - $stateInstance = NULL; - - // Create state class name - $className = $this->getStatePrefix() . '' . self::convertToClassName($stateName) . 'State'; - - // ... and set it - $this->setClassName($className); - - // Is this class loaded? - if (!class_exists($this->getClassName())) { - // Throw an exception here - throw new UnresolveableStateException(array($this, $stateName), self::EXCEPTION_INVALID_STATE); - } // END - if - - // Initialize the state - $stateInstance = ObjectFactory::createObjectByName( - $this->getClassName(), - array($this) - ); - - // Return the result - return $stateInstance; - } - - /** - * Checks whether the given state is valid - * - * @param $stateName The default state we shall execute - * @return $isValid Whether the given state is valid - * @throws EmptyVariableException Thrown if given state is not set - * @throws DefaultStateException Thrown if default state was not found - */ - public function isStateValid ($stateName) { - // By default nothing shall be valid - $isValid = FALSE; - - // Is a state set? - if (empty($stateName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($this, 'stateName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - - // Create class name - $className = $this->statePrefix . self::convertToClassName($stateName) . 'State'; - - // Now, let us create the full name of the state class - $this->setClassName($className); - - // Try it hard to get an state - while ($isValid === FALSE) { - // Is this class already loaded? - if (class_exists($this->getClassName())) { - // This class does exist. :-) - $isValid = TRUE; - } elseif ($this->getClassName() != $this->statePrefix . 'DefaultState') { - // Set default state - $this->setClassName($this->statePrefix . 'DefaultState'); - } else { - // All is tried, give it up here - throw new DefaultStateException($this, self::EXCEPTION_DEFAULT_STATE_GONE); - } - } // END - while - - // Return the result - return $isValid; - } -} - -// [EOF] -?> diff --git a/application/hub/main/resolver/state/network/.htaccess b/application/hub/main/resolver/state/network/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/state/network/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/state/peer/.htaccess b/application/hub/main/resolver/state/peer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/resolver/state/peer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/resolver/state/peer/class_PeerStateResolver.php b/application/hub/main/resolver/state/peer/class_PeerStateResolver.php deleted file mode 100644 index 4429f1b91..000000000 --- a/application/hub/main/resolver/state/peer/class_PeerStateResolver.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PeerStateResolver extends BaseStateResolver implements StateResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to 'Peer' - $this->setStatePrefix('Peer'); - } - - /** - * Creates an instance of a resolver class with a given state - * - * @return $resolverInstance The prepared state resolver instance - */ - public static final function createPeerStateResolver () { - // Create the new instance - $resolverInstance = new PeerStateResolver(); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an state instance for a given raw package data and socket resource - * - * @param $helperInstance An instance of a ConnectionHelper class - * @param $packageData Raw package data - * @param $socketResource A valid socket resource - * @return $stateInstance An instance of the resolved state - * @throws InvalidSocketException If socketResource, even from getSocketResource() is no valid resource - * @todo ~30% done - */ - public static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource) { - // Get temporary resolver instance - $resolverInstance = self::createPeerStateResolver(); - - // Init state instance - $stateInstance = NULL; - - // Is the socket resource valid? - if (!is_resource($socketResource)) { - // No, so get socket resource from helper - $socketResource = $helperInstance->getSocketResource(); - - // Still no socket resource? - if (!is_resource($socketResource)) { - // Then abort here with an exception (may happen after socket_shutdown()) - throw new InvalidSocketException(array($helperInstance, $socketResource, 'unknown', 'unknown'), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - } // END - if - - // Get error code from it - $errorCode = socket_last_error($socketResource); - - // Translate the error code to an own name - $errorCode = $helperInstance->translateSocketErrorCodeToName($errorCode); - - // Create a state instance based on $errorCode. This factory does the hard work for us - $stateInstance = PeerStateFactory::createPeerStateInstanceBySocketStatusCode($helperInstance, $packageData, $socketResource, $errorCode); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/scanner/.htaccess b/application/hub/main/scanner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/scanner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/scanner/class_ b/application/hub/main/scanner/class_ deleted file mode 100644 index 5cc29c9e5..000000000 --- a/application/hub/main/scanner/class_ +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Scanner extends BaseScanner implements Scanner, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $scannerInstance An instance of a Scanner class - */ - public final static function create???Scanner () { - // Get new instance - $scannerInstance = new ???Scanner(); - - // Return the prepared instance - return $scannerInstance; - } - - /** - * Runs the scanner (please no loops here) - * - * @return void - * @todo 0% done - */ - public function execute () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/scanner/class_BaseScanner.php b/application/hub/main/scanner/class_BaseScanner.php deleted file mode 100644 index a890efa8c..000000000 --- a/application/hub/main/scanner/class_BaseScanner.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseScanner extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/scanner/crawler/.htaccess b/application/hub/main/scanner/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/scanner/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/scanner/crawler/class_Crawler b/application/hub/main/scanner/crawler/class_Crawler deleted file mode 100644 index d02f28cd4..000000000 --- a/application/hub/main/scanner/crawler/class_Crawler +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Crawler???Scanner extends BaseScanner implements Scanner, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $scannerInstance An instance of a Scanner class - */ - public final static function createCrawler???Scanner () { - // Get new instance - $scannerInstance = new Crawler???Scanner(); - - // Return the prepared instance - return $scannerInstance; - } - - /** - * Runs the scanner (please no loops here) - * - * @return void - * @todo 0% done - */ - public function execute () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/scanner/crawler/uploaded_list/.htaccess b/application/hub/main/scanner/crawler/uploaded_list/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/scanner/crawler/uploaded_list/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php b/application/hub/main/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php deleted file mode 100644 index 1dfac0f40..000000000 --- a/application/hub/main/scanner/crawler/uploaded_list/class_CrawlerUploadedListScanner.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUploadedListScanner extends BaseScanner implements Scanner, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $scannerInstance An instance of a Scanner class - */ - public final static function createCrawlerUploadedListScanner () { - // Get new instance - $scannerInstance = new CrawlerUploadedListScanner(); - - // Return the prepared instance - return $scannerInstance; - } - - /** - * Runs the scanner (please no loops here) - * - * @return void - * @todo 0% done - */ - public function execute () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/.htaccess b/application/hub/main/source/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/source/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/source/class_ b/application/hub/main/source/class_ deleted file mode 100644 index 0f70d7fe7..000000000 --- a/application/hub/main/source/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Source extends BaseSource implements Source!!! { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $sourceInstance An instance of a Source class - */ - public final static function create???Source () { - // Get new instance - $sourceInstance = new ???Source(); - - // Return the prepared instance - return $sourceInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/class_BaseSource.php b/application/hub/main/source/class_BaseSource.php deleted file mode 100644 index d15fd2369..000000000 --- a/application/hub/main/source/class_BaseSource.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseSource extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/class_BaseUrlSource.php b/application/hub/main/source/class_BaseUrlSource.php deleted file mode 100644 index c4ef08404..000000000 --- a/application/hub/main/source/class_BaseUrlSource.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseUrlSource extends BaseSource { - // Stack name for all URLs - const STACKER_NAME_URLS = 'urls'; - - // Array elements for CSV data array - const CRAWL_JOB_ARRAY_START_URL = 'start_url'; - const CRAWL_JOB_ARRAY_DEPTH = 'start_depth'; - const CRAWL_JOB_ARRAY_EXTERNAL_DEPTH = 'external_depth'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Initalizes this source - * - * @param $prefix Prefix for this source - * @param $sourceName Name of this source - * @return void - */ - protected function initSource ($prefix, $sourceName) { - // Use another object factory - $stackInstance = FileStackFactory::createFileStackInstance($prefix . '_url', $sourceName); - - // Set the stack here - $this->setStackInstance($stackInstance); - } - - /** - * Determines whether the stack 'urls' is empty. - * - * @return $isEmpty Whether the stack 'urls' is empty. - */ - public function isUrlStackEmpty () { - // Determine it - $isEmpty = $this->getStackInstance()->isStackEmpty(self::STACKER_NAME_URLS); - - // Return result - return $isEmpty; - } - - /** - * Enriches the given associative array with more data, now at least 2 - * elements are required: - * - * 'start_url' - Starting URL - * 'start_depth' - Crawl depth for starting URL - * - * @param $crawlData Array with partial data for being queued - * @return void - * @todo ~10% done - */ - protected function enrichCrawlerQueueData (array &$crawlData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: crawlData()=' . count($crawlData) . ' - CALLED!'); - - // Check for minimum array elements - assert(isset($crawlData[self::CRAWL_JOB_ARRAY_START_URL])); - assert(isset($crawlData[self::CRAWL_JOB_ARRAY_DEPTH])); - - // @TODO Add more elements - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Enqueues given crawler array in assigned file-based stack - * - * @param $crawlData Array with partial data for being queued - * @return void - */ - protected function enqueueInFileStack (array $crawlData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: crawlData()=' . count($crawlData) . ' - CALLED!'); - - // Get the stack instance and enqueue it - $this->getStackInstance()->pushNamed(self::STACKER_NAME_URLS, $crawlData); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/units/.htaccess b/application/hub/main/source/units/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/source/units/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/source/units/class_TestUnitSource.php b/application/hub/main/source/units/class_TestUnitSource.php deleted file mode 100644 index eef01ff2a..000000000 --- a/application/hub/main/source/units/class_TestUnitSource.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TestUnitSource extends BaseSource implements UnitSource, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $sourceInstance An instance of a Source class - */ - public final static function createTestUnitSource () { - // Get new instance - $sourceInstance = new TestUnitSource(); - - // Create a RNG instance and set it in this class - $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); - $sourceInstance->setRngInstance($rngInstance); - - // And also a crypto instance (for our encrypted messages) - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - $sourceInstance->setCryptoInstance($cryptoInstance); - - // Return the prepared instance - return $sourceInstance; - } - - /** - * Generates an encrypted random message - * - * @return $encryptedMessage The encrypted random message - */ - public function generateMessageFromSource () { - // Get a very secret message by encoding and random string with BASE64 - $secretMessage = base64_encode($this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_message_length'))); - - // Get a random, secret key - $secretKey = $this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length') / 8); - - // Now encrypt the message with our key and a good (strong) cipher - $encryptedMessage = base64_encode($this->getCryptoInstance()->encryptString($secretMessage, $secretKey)); - - // Return it - return $encryptedMessage; - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/urls/.htaccess b/application/hub/main/source/urls/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/source/urls/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/source/urls/class_Crawler b/application/hub/main/source/urls/class_Crawler deleted file mode 100644 index 5ef38a60a..000000000 --- a/application/hub/main/source/urls/class_Crawler +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Crawler???UrlSource extends BaseUrlSource implements UrlSource, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $sourceInstance An instance of a Source class - */ - public final static function createCrawler???UrlSource () { - // Get new instance - $sourceInstance = new Crawler???UrlSource(); - - // Init source - $sourceInstance->initSource('crawler', '!!!'); - - // Return the prepared instance - return $sourceInstance; - } - - /** - * Processes entries in the stack. - * - * @return void - * @todo ~ 10% done - */ - public function processStack () { - // Does the stack have some entries left? - if ($this->isUrlStackEmpty()) { - // Nothing to handle here - return; - } // END - if - - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/urls/class_CrawlerFoundRssUrlSource.php b/application/hub/main/source/urls/class_CrawlerFoundRssUrlSource.php deleted file mode 100644 index cad4691e7..000000000 --- a/application/hub/main/source/urls/class_CrawlerFoundRssUrlSource.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerFoundRssUrlSource extends BaseUrlSource implements UrlSource, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $sourceInstance An instance of a Source class - */ - public final static function createCrawlerFoundRssUrlSource () { - // Get new instance - $sourceInstance = new CrawlerFoundRssUrlSource(); - - // Init source - $sourceInstance->initSource('crawler', 'found_rss'); - - // Return the prepared instance - return $sourceInstance; - } - - /** - * Fills the URL stack with new entries from source - * - * @return void - * @todo 0% done - */ - public function fillUrlStack () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/urls/class_CrawlerLocalStartUrlSource.php b/application/hub/main/source/urls/class_CrawlerLocalStartUrlSource.php deleted file mode 100644 index fdabe0642..000000000 --- a/application/hub/main/source/urls/class_CrawlerLocalStartUrlSource.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerLocalStartUrlSource extends BaseUrlSource implements UrlSource, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $sourceInstance An instance of a Source class - */ - public final static function createCrawlerLocalStartUrlSource () { - // Get new instance - $sourceInstance = new CrawlerLocalStartUrlSource(); - - // Init source - $sourceInstance->initSource('crawler', 'local_start'); - - // Return the prepared instance - return $sourceInstance; - } - - /** - * Fills the URL stack with new entries from source - * - * @return void - * @todo 0% done - */ - public function fillUrlStack () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/urls/class_CrawlerRssStartUrlSource.php b/application/hub/main/source/urls/class_CrawlerRssStartUrlSource.php deleted file mode 100644 index ef6ade1bd..000000000 --- a/application/hub/main/source/urls/class_CrawlerRssStartUrlSource.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerRssStartUrlSource extends BaseUrlSource implements UrlSource, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $sourceInstance An instance of a Source class - */ - public final static function createCrawlerRssStartUrlSource () { - // Get new instance - $sourceInstance = new CrawlerRssStartUrlSource(); - - // Init source - $sourceInstance->initSource('crawler', 'rss_start'); - - // Return the prepared instance - return $sourceInstance; - } - - /** - * Fills the URL stack with new entries from source - * - * @return void - * @todo 0% done - */ - public function fillUrlStack () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php b/application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php deleted file mode 100644 index 33caffaf8..000000000 --- a/application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php +++ /dev/null @@ -1,369 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, Registerable { - /** - * Stack name for a CSV file - */ - const STACK_NAME_CSV_FILE = 'csv_file'; - - /** - * Stack name for a CSV entry - */ - const STACK_NAME_CSV_ENTRY = 'csv_entry'; - - /** - * Size of crawl (CSV) entry which is an indexed array: - * - * 0 = URL to crawl - * 1 = Crawl depth of URL - * 2 = Crawl depth of linked URLs (same other host only) - */ - const CRAWL_ENTRY_SIZE = 3; - - /** - * "Cached" CSV path - */ - private $csvFilePath = ''; - - /** - * Last CSV file instance - */ - private $lastCsvFileInstance = NULL; - - /** - * Stack for pushing data from this clas to another - */ - private $stackSourceInstance = NULL; - - /** - * "Imported" CSV files - */ - private $csvFileImported = array(); - - /** - * "Cached" separator for columns - */ - private $columnSeparator = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // "Cache" CSV path for faster usage - $this->csvFilePath = $this->getConfigInstance()->getConfigEntry('base_path') . '/' . $this->getConfigInstance()->getConfigEntry('crawler_csv_file_path'); - - // Initialize directory instance - $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($this->csvFilePath)); - - // Set it here - $this->setDirectoryInstance($directoryInstance); - - // Init stack instance - $this->stackSourceInstance = ObjectFactory::createObjectByConfiguredName('crawler_uploaded_list_url_source_stack_class'); - - // Init stacks - $this->getStackSourceInstance()->initStack(self::STACK_NAME_CSV_FILE); - $this->getStackSourceInstance()->initStack(self::STACK_NAME_CSV_ENTRY); - - // "Cache" column separator - $this->columnSeparator = $this->getConfigInstance()->getConfigEntry('crawler_url_list_column_separator'); - } - - /** - * Checks whether a CSV file is found in configured path - * - * @return $isFound Whether a CSV file is found - */ - private function isCsvFileFound () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Is it valid? - if (!$this->getDirectoryInstance()->getDirectoryIteratorInstance()->valid()) { - // Rewind to start - $this->getDirectoryInstance()->getDirectoryIteratorInstance()->rewind(); - } // END - if - - // Read next entry - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: this->csvFileImported=' . print_r($this->csvFileImported, TRUE)); - $directoryEntry = $this->getDirectoryInstance()->readDirectoryExcept(array_merge(array('.htaccess', '.', '..'), $this->csvFileImported)); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry); - - // Is it empty or wrong file extension? - if ((empty($directoryEntry)) || (substr($directoryEntry, -4, 4) != '.csv')) { - // Skip further processing - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - SKIPPED!'); - return FALSE; - } // END - if - - // Initialize CSV file instance - $this->lastCsvFileInstance = ObjectFactory::createObjectByConfiguredName('csv_input_file_class', array($this->csvFilePath . '/' . $directoryEntry)); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - Instance created - EXIT!'); - - // Found an entry - return TRUE; - } - - /** - * Creates an instance of this class - * - * @return $sourceInstance An instance of a Source class - */ - public final static function createCrawlerUploadedListUrlSource () { - // Get new instance - $sourceInstance = new CrawlerUploadedListUrlSource(); - - // Init source - $sourceInstance->initSource('crawler', 'uploaded_list'); - - // Return the prepared instance - return $sourceInstance; - } - - /** - * Enriches and saves the given CSV entry (array) in the assigned - * file-based stack. To such entry a lot more informations are added, such - * as which files shall be crawled and many more. - * - * @param $csvData Array with data from a CSV file - * @return void - */ - private function saveCsvDataInCrawlerQueue (array $csvData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData()=' . count($csvData) . ' - CALLED!'); - - // The array must have a fixed amount of elements, later enhancements may accept more - assert(count($csvData) == self::CRAWL_ENTRY_SIZE); - - /* - * First converted the indexed array into an assoziative array. Don't - * forget to expand this array as well when you want to add another - * column to the CSV file. - */ - $csvArray = array( - self::CRAWL_JOB_ARRAY_START_URL => $csvData[0], - self::CRAWL_JOB_ARRAY_DEPTH => $csvData[1], - self::CRAWL_JOB_ARRAY_EXTERNAL_DEPTH => $csvData[2] - ); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvArray()=' . count($csvArray) . ' - BEFORE!'); - - // Then add more data to it - $this->enrichCrawlerQueueData($csvArray); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvArray()=' . count($csvArray) . ' - AFTER!'); - - /* - * Then enqueue it in the file stack. The local crawler "task" will - * then pick this up. - */ - $this->enqueueInFileStack($csvArray); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Checks whether a CSV file has been loaded (added to the stack) - * - * @return $isAdded Whether a CSV file has been loaded - */ - private function isCsvFileAdded () { - // Check whether the stacker is not empty - $isAdded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_FILE)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_FILE))); - - // Return the result - return $isAdded; - } - - /** - * Checks whether a CSV entry has been added to the stack - * - * @return $isAdded Whether a CSV entry has been added - */ - private function isCsvEntryAdded () { - // Check whether the stacker is not empty - $isAdded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_ENTRY)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_ENTRY))); - - // Return the result - return $isAdded; - } - - /** - * Initializes the import of the CSV file which is being processed by other task - * - * @return void - * @throws NullPointerException If lastCsvFileInstance is not set - */ - private function addCsvFile () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Is the instance set? - if (is_null($this->lastCsvFileInstance)) { - // This should not happen - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Stack this file - $this->getStackSourceInstance()->pushNamed(self::STACK_NAME_CSV_FILE, $this->lastCsvFileInstance); - - // ... and mark it as "imported" - array_push($this->csvFileImported, basename($this->lastCsvFileInstance->getFileName())); - - // ... and finally NULL it (to save some RAM) - $this->lastCsvFileInstance = NULL; - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Parses the next stacked CSV file by reading only one line from it. Then - * the read line is being validated and if found good being feed to the next - * stack. The file is removed from stack only if it has been fully parsed. - * - * @return void - */ - private function parseCsvFile () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Get next entry - $csvFileInstance = $this->getStackSourceInstance()->popNamed(self::STACK_NAME_CSV_FILE); - - // Read full "CSV line" - $csvData = $csvFileInstance->readCsvFileLine($this->columnSeparator); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData[' . gettype($csvData) . ']=' . print_r($csvData, TRUE)); - - // Expect always an array - assert(is_array($csvData)); - - // Is the array empty? - if (count($csvData) == 0) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: File ' . $csvFileInstance->getFileName() . ' has been fully read.'); - - // Try to close it by actually unsetting (destructing) it - unset($csvFileInstance); - - // This file as been fully read, so don't push it back on stack. - return; - } // END - if - - // ... with a fixed amount of elements, later enhancements may accept more - assert(count($csvData) == self::CRAWL_ENTRY_SIZE); - - /* - * Push the file back on stack as it may contain more entries. This way - * all files got rotated on stack which may improve crawler performance. - */ - $this->getStackSourceInstance()->pushNamed(self::STACK_NAME_CSV_FILE, $csvFileInstance); - - // Push array on next stack - $this->getStackSourceInstance()->pushNamed(self::STACK_NAME_CSV_ENTRY, $csvData); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Parses the next stacked CSV entry. - * - * @return void - */ - private function parseCsvEntry () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Pop it from stack - $csvData = $this->getStackSourceInstance()->popNamed(self::STACK_NAME_CSV_ENTRY); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData[' . gettype($csvData) . ']=' . print_r($csvData, TRUE)); - - // It must have a fixed amount of elements (see method parseCsvFile() for details) - assert(count($csvData) == self::CRAWL_ENTRY_SIZE); - - // Save it in crawler queue (which will enrich it with way more informations - $this->saveCsvDataInCrawlerQueue($csvData); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); - } - - /** - * Getter for stackSourceInstance variable - * - * @return $stackSourceInstance An instance of an additional stack - */ - public final function getStackSourceInstance () { - return $this->stackSourceInstance; - } - - /** - * Fills the URL stack with new entries from source - * - * @return void - * @todo ~40% done - */ - public function fillUrlStack () { - // Does the stack have some entries left? - if ($this->isCsvEntryAdded()) { - /* - * A CSV file has been found and "imported" (added to stack). Now - * the file can be read line by line and checked every one of it. - */ - $this->parseCsvEntry(); - } elseif ($this->isCsvFileAdded()) { - /* - * A CSV file has been found and "imported" (added to stack). Now - * the file can be read line by line and checked every one of it. - */ - $this->parseCsvFile(); - } elseif ($this->isCsvFileFound()) { - /* - * A file containing an URL list is found. Please note the format is - * CSV-like as you may wish to provide meta data such as crawl - * depth, handling of 3rd-party URLs and such. - */ - $this->addCsvFile(); - } - - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/.htaccess b/application/hub/main/states/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/communicator/.htaccess b/application/hub/main/states/communicator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/communicator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/communicator/active/.htaccess b/application/hub/main/states/communicator/active/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/communicator/active/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/communicator/active/class_CommunicatorActiveState.php b/application/hub/main/states/communicator/active/class_CommunicatorActiveState.php deleted file mode 100644 index 64267457d..000000000 --- a/application/hub/main/states/communicator/active/class_CommunicatorActiveState.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CommunicatorActiveState extends BaseCommunicatorState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructo - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('active'); - } - - /** - * Creates an instance of this class - * - * @param $communicatorInstance An instance of a Communicator class - * @return $stateInstance An instance of a Stateable class - */ - public static final function createCommunicatorActiveState (Communicator $communicatorInstance) { - // Get new instance - $stateInstance = new CommunicatorActiveState(); - - // Set the communicator instance - $stateInstance->setCommunicatorInstance($communicatorInstance); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/communicator/class_ b/application/hub/main/states/communicator/class_ deleted file mode 100644 index c50b5408a..000000000 --- a/application/hub/main/states/communicator/class_ +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014, 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Communicator???State extends BaseCommunicatorState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('!!!'); - } - - /** - * Creates an instance of this class - * - * @param $communicatorInstance An instance of a Communicator class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createCommunicator???State (Communicator $communicatorInstance) { - // Get new instance - $stateInstance = new Communicator???State(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE: Has changed from ' . $communicatorInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the communicator instance - $stateInstance->setCommunicatorInstance($communicatorInstance); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/communicator/class_BaseCommunicatorState.php b/application/hub/main/states/communicator/class_BaseCommunicatorState.php deleted file mode 100644 index 32a055406..000000000 --- a/application/hub/main/states/communicator/class_BaseCommunicatorState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014, 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCommunicatorState extends BaseState { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Validates whether the state is 'active' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' - */ - public function validateCommunicatorStateIsActive () { - // Just compare it... - if (!$this instanceof CommunicatorActiveState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/communicator/init/.htaccess b/application/hub/main/states/communicator/init/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/communicator/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/communicator/init/class_CommunicatorInitState.php b/application/hub/main/states/communicator/init/class_CommunicatorInitState.php deleted file mode 100644 index 30d3a628d..000000000 --- a/application/hub/main/states/communicator/init/class_CommunicatorInitState.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CommunicatorInitState extends BaseCommunicatorState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructo - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('init'); - } - - /** - * Creates an instance of this class - * - * @param $communicatorInstance An instance of a Communicator class - * @return $stateInstance An instance of a Stateable class - */ - public static final function createCommunicatorInitState (Communicator $communicatorInstance) { - // Get new instance - $stateInstance = new CommunicatorInitState(); - - // Set the communicator instance - $stateInstance->setCommunicatorInstance($communicatorInstance); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - * @todo 0% done? - */ - public function executeState (Executor $executorInstance) { - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/crawler/.htaccess b/application/hub/main/states/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/crawler/active/.htaccess b/application/hub/main/states/crawler/active/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/crawler/active/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/crawler/active/class_CrawlerActiveState.php b/application/hub/main/states/crawler/active/class_CrawlerActiveState.php deleted file mode 100644 index 5abe58723..000000000 --- a/application/hub/main/states/crawler/active/class_CrawlerActiveState.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerActiveState extends BaseCrawlerState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructo - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('active'); - } - - /** - * Creates an instance of this class - * - * @param $crawlerInstance An instance of a Crawler class - * @return $stateInstance An instance of a Stateable class - */ - public static final function createCrawlerActiveState () { - // Get new instance - $stateInstance = new CrawlerActiveState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - * @todo 0% done - */ - public function executeState (Executor $executorInstance) { - $this->partialStub('Unfinished method, executorInstance=' . $executorInstance->__toString()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/crawler/booting/.htaccess b/application/hub/main/states/crawler/booting/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/crawler/booting/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/crawler/booting/class_CrawlerBootingState.ph b/application/hub/main/states/crawler/booting/class_CrawlerBootingState.ph deleted file mode 100644 index ffb733e30..000000000 --- a/application/hub/main/states/crawler/booting/class_CrawlerBootingState.ph +++ /dev/null @@ -1,14 +0,0 @@ - - /** - * State change if the communicator has fully initialized. - * - * @return void - * @todo ~30% done - */ - public function communicatorHasInitialized () { - // Please implement - $this->partialStub('Unfinished method.'); - - // Change state to 'active' - CrawlerStateFactory::createCrawlerStateInstanceByName('active'); - } diff --git a/application/hub/main/states/crawler/booting/class_CrawlerBootingState.php b/application/hub/main/states/crawler/booting/class_CrawlerBootingState.php deleted file mode 100644 index 6edbdbbd7..000000000 --- a/application/hub/main/states/crawler/booting/class_CrawlerBootingState.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerBootingState extends BaseCrawlerState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructo - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('booting'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public static final function createCrawlerBootingState () { - // Get new instance - $stateInstance = new CrawlerBootingState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - * @todo 0% done - */ - public function executeState (Executor $executorInstance) { - $this->partialStub('Unfinished method, executorInstance=' . $executorInstance->__toString()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/crawler/class_ b/application/hub/main/states/crawler/class_ deleted file mode 100644 index 7579778ab..000000000 --- a/application/hub/main/states/crawler/class_ +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Crawler???State extends BaseCrawlerState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('!!!'); - } - - /** - * Creates an instance of this class - * - * @param $crawlerInstance An instance of a Crawler class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createCrawler???State (Crawler $crawlerInstance) { - // Get new instance - $stateInstance = new Crawler???State(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE: Has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the crawler instance - $stateInstance->setCrawlerInstance($crawlerInstance); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/crawler/class_BaseCrawlerState.php b/application/hub/main/states/crawler/class_BaseCrawlerState.php deleted file mode 100644 index fbb75fda4..000000000 --- a/application/hub/main/states/crawler/class_BaseCrawlerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCrawlerState extends BaseState { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Validates whether the state is 'active' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' - */ - public function validateCrawlerStateIsActive () { - // Just compare it... - if (!$this instanceof CrawlerActiveState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/crawler/init/.htaccess b/application/hub/main/states/crawler/init/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/crawler/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/crawler/init/class_CrawlerInitState.php b/application/hub/main/states/crawler/init/class_CrawlerInitState.php deleted file mode 100644 index fffd219ed..000000000 --- a/application/hub/main/states/crawler/init/class_CrawlerInitState.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerInitState extends BaseCrawlerState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructo - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('init'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public static final function createCrawlerInitState () { - // Get new instance - $stateInstance = new CrawlerInitState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - */ - public function executeState (Executor $executorInstance) { - // Initialize the executor (can be a Communicator instance) - $executorInstance->initExecutor($this); - } - - /** - * State change if the communicator has fully initialized. - * - * @return void - * @todo ~30% done - */ - public function communicatorHasInitialized () { - // Please implement - $this->partialStub('Unfinished method.'); - - // Change state to 'booting' - CrawlerStateFactory::createCrawlerStateInstanceByName('booting'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/cruncher/.htaccess b/application/hub/main/states/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/cruncher/class_ b/application/hub/main/states/cruncher/class_ deleted file mode 100644 index 03b5bc2df..000000000 --- a/application/hub/main/states/cruncher/class_ +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Cruncher???State extends BaseCruncherState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('!!!'); - } - - /** - * Creates an instance of this class - * - * @param $cruncherInstance An instance of a CruncherHelper class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createCruncher???State (CruncherHelper $cruncherInstance) { - // Get new instance - $stateInstance = new Cruncher???State(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER-STATE: Has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the cruncher instance - $stateInstance->setCruncherInstance($cruncherInstance); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - */ - public function executeState (Executor $executorInstance) { - $this->partialStub('This state needs implementation. executorInstance=' . $executorInstance->__toString()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/cruncher/class_BaseCruncherState.php b/application/hub/main/states/cruncher/class_BaseCruncherState.php deleted file mode 100644 index 246bd812e..000000000 --- a/application/hub/main/states/cruncher/class_BaseCruncherState.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCruncherState extends BaseState { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Validates whether the state is 'active' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' - */ - public function validateCruncherStateIsActive () { - // Just compare it... - if (!$this instanceof CruncherActiveState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Checks if this state is 'virgin' - * - * @return $isVirgin Whether this state is 'virgin' - */ - public function isCruncherStateVirgin () { - // Just compare it... - return ($this instanceof CruncherVirginState); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/cruncher/init/.htaccess b/application/hub/main/states/cruncher/init/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/cruncher/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/cruncher/init/class_CruncherInitState.php b/application/hub/main/states/cruncher/init/class_CruncherInitState.php deleted file mode 100644 index 8c1938590..000000000 --- a/application/hub/main/states/cruncher/init/class_CruncherInitState.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherInitState extends BaseCruncherState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('init'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public final static function createCruncherInitState () { - // Get new instance - $stateInstance = new CruncherInitState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - */ - public function executeState (Executor $executorInstance) { - // Initialize the unit production to maybe become 'virgin' or 'active' if work/test units are there - $executorInstance->initUnitProduction($this); - } - - /** - * An encrypted message has been generated so we change the state to - * 'virgin'. - * - * @return void - */ - public function encryptedMessageGenerated () { - // Change the state now to 'virgin' - CruncherStateFactory::createCruncherStateInstanceByName('virgin'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/cruncher/virgin/.htaccess b/application/hub/main/states/cruncher/virgin/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/cruncher/virgin/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php b/application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php deleted file mode 100644 index a5d2f15de..000000000 --- a/application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherVirginState extends BaseCruncherState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('virgin'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public final static function createCruncherVirginState () { - // Get new instance - $stateInstance = new CruncherVirginState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - */ - public function executeState (Executor $executorInstance) { - // Produce some keys now - $executorInstance->produceKeys($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/dht/.htaccess b/application/hub/main/states/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/dht/active/.htaccess b/application/hub/main/states/dht/active/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/dht/active/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/dht/active/class_DhtActiveState.php b/application/hub/main/states/dht/active/class_DhtActiveState.php deleted file mode 100644 index 549f0fd03..000000000 --- a/application/hub/main/states/dht/active/class_DhtActiveState.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtActiveState extends BaseDhtState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('active'); - } - - /** - * Creates an instance of this class - * - * @param $dhtInstance An instance of a Distributable class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createDhtActiveState (Distributable $dhtInstance) { - // Get new instance - $stateInstance = new DhtActiveState(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/dht/booting/.htaccess b/application/hub/main/states/dht/booting/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/dht/booting/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/dht/booting/class_DhtBootingState.php b/application/hub/main/states/dht/booting/class_DhtBootingState.php deleted file mode 100644 index f6f05cdc5..000000000 --- a/application/hub/main/states/dht/booting/class_DhtBootingState.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtBootingState extends BaseDhtState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('booting'); - } - - /** - * Creates an instance of this class - * - * @param $dhtInstance An instance of a Distributable class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createDhtBootingState (Distributable $dhtInstance) { - // Get new instance - $stateInstance = new DhtBootingState(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - - // Get node instance and enable DHT bootstrap requests - NodeObjectFactory::createNodeInstance()->enableAcceptDhtBootstrap(); - - // Update DHT node info as well - $dhtInstance->enableAcceptDhtBootstrap(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/dht/class_ b/application/hub/main/states/dht/class_ deleted file mode 100644 index 01bb0c505..000000000 --- a/application/hub/main/states/dht/class_ +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Dht???State extends BaseDhtState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('!!!'); - } - - /** - * Creates an instance of this class - * - * @param $dhtInstance An instance of a Distributable class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createDht???State (Distributable $dhtInstance) { - // Get new instance - $stateInstance = new Dht???State(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/dht/class_BaseDhtState.php b/application/hub/main/states/dht/class_BaseDhtState.php deleted file mode 100644 index 44e0b5584..000000000 --- a/application/hub/main/states/dht/class_BaseDhtState.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Create generic DHT interface - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseDhtState extends BaseState { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Validates whether the DHT state is 'virgin' or throws an exception if it - * is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'virgin' - */ - public function validateDhtStateIsVirginOrInit () { - // Just compare it... - if ((!$this instanceof DhtVirginState) && (!$this instanceof DhtInitState)) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Checks whether the DHT's state is 'booting' by comparing it with the - * state's class name. - * - * @return $isBooting Whether this DHT's state is 'booting' - */ - public function ifDhtIsBooting () { - // Check state - $isBooting = ($this instanceof DhtBootingState); - - // Return status - return $isBooting; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/dht/init/.htaccess b/application/hub/main/states/dht/init/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/dht/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/dht/init/class_DhtInitState.php b/application/hub/main/states/dht/init/class_DhtInitState.php deleted file mode 100644 index 25e6a8262..000000000 --- a/application/hub/main/states/dht/init/class_DhtInitState.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtInitState extends BaseDhtState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('init'); - } - - /** - * Creates an instance of this class - * - * @param $dhtInstance An instance of a Distributable class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createDhtInitState (Distributable $dhtInstance) { - // Get new instance - $stateInstance = new DhtInitState(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $stateInstance; - } - - /** - * The DHT has been initialized. This means that the state can be changed - * to the next one: virgin. - * - * @return void - */ - public function dhtHasInitialized () { - // Create a new instance - DhtStateFactory::createDhtStateInstanceByName('virgin', $this->getDhtInstance()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/dht/virgin/.htaccess b/application/hub/main/states/dht/virgin/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/dht/virgin/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/dht/virgin/class_DhtVirginState.php b/application/hub/main/states/dht/virgin/class_DhtVirginState.php deleted file mode 100644 index e9998fa4a..000000000 --- a/application/hub/main/states/dht/virgin/class_DhtVirginState.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DhtVirginState extends BaseDhtState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('virgin'); - } - - /** - * Creates an instance of this class - * - * @param $dhtInstance An instance of a Distributable class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createDhtVirginState (Distributable $dhtInstance) { - // Get new instance - $stateInstance = new DhtVirginState(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE[' . __METHOD__ . ':' . __LINE__ . ']: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Called when the DHT is booting. This means that the bootstrap message - * has been queued. - * - * @return void - */ - public function dhtIsBooting () { - // Get new instance and set it - DhtStateFactory::createDhtStateInstanceByName('booting', $this->getDhtInstance()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/generic/.htaccess b/application/hub/main/states/generic/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/generic/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/hub/.htaccess b/application/hub/main/states/hub/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/hub/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/miner/.htaccess b/application/hub/main/states/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/miner/booting/.htaccess b/application/hub/main/states/miner/booting/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/miner/booting/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/miner/booting/class_MinerBootingState.php b/application/hub/main/states/miner/booting/class_MinerBootingState.php deleted file mode 100644 index a30e8a641..000000000 --- a/application/hub/main/states/miner/booting/class_MinerBootingState.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerBootingState extends BaseMinerState implements Stateable { - /** - * Array of booted producers - */ - private $bootedProducer = array(); - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('booting'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public final static function createMinerBootingState () { - // Get new instance - $stateInstance = new MinerBootingState(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - */ - public function executeState (Executor $executorInstance) { - // Has this executor (producer) run? - if (isset($this->bootedProducer[$executorInstance->__toString()])) { - // Then silently skip this - return; - } // END - if - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Calling prepareBlockProduction() on ' . $executorInstance->__toString() . ' ...'); - - // Now prepare the unit production to maybe become 'virgin' or 'active' if work/test units are there - $executorInstance->prepareBlockProduction($this); - - // Mark producer as booted - $this->bootedProducer[$executorInstance->__toString()] = TRUE; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/miner/class_BaseMinerState.php b/application/hub/main/states/miner/class_BaseMinerState.php deleted file mode 100644 index cf53991ee..000000000 --- a/application/hub/main/states/miner/class_BaseMinerState.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseMinerState extends BaseState { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Validates whether the state is 'active' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' - */ - public function validateMinerStateIsActive () { - // Just compare it... - if (!$this instanceof MinerActiveState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Validates whether the state is 'init' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'init' - */ - public function validateMinerStateIsInit () { - // Just compare it... - if (!$this instanceof MinerInitState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Validates whether the state is 'booting' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'booting' - */ - public function validateMinerStateIsBooting () { - // Just compare it... - if (!$this instanceof MinerBootingState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Checks if this state is 'virgin' - * - * @return $isVirgin Whether this state is 'virgin' - */ - public function isMinerStateVirgin () { - // Just compare it... - return ($this instanceof MinerVirginState); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/miner/class_Miner b/application/hub/main/states/miner/class_Miner deleted file mode 100644 index b2020ce94..000000000 --- a/application/hub/main/states/miner/class_Miner +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Miner???State extends BaseMinerState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('!!!'); - } - - /** - * Creates an instance of this class - * - * @param $minerInstance An instance of a MinerHelper class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createMiner???State (MinerHelper $minerInstance) { - // Get new instance - $stateInstance = new Miner???State(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the miner instance - $stateInstance->setMinerInstance($minerInstance); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - */ - public function executeState (Executor $executorInstance) { - $this->partialStub('This state needs implementation. executorInstance=' . $executorInstance->__toString()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/miner/init/.htaccess b/application/hub/main/states/miner/init/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/miner/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/miner/init/class_MinerInitState.php b/application/hub/main/states/miner/init/class_MinerInitState.php deleted file mode 100644 index 1b687ebd5..000000000 --- a/application/hub/main/states/miner/init/class_MinerInitState.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerInitState extends BaseMinerState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('init'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public final static function createMinerInitState () { - // Get new instance - $stateInstance = new MinerInitState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - * @todo 0% done? - */ - public function executeState (Executor $executorInstance) { - } - - /** - * An encrypted message has been generated so we change the state to - * 'virgin'. - * - * @return void - */ - public function encryptedMessageGenerated () { - // Change the state now to 'virgin' - MinerStateFactory::createMinerStateInstanceByName('virgin'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/miner/virgin/.htaccess b/application/hub/main/states/miner/virgin/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/miner/virgin/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/miner/virgin/class_MinerVirginState.php b/application/hub/main/states/miner/virgin/class_MinerVirginState.php deleted file mode 100644 index 40340a67d..000000000 --- a/application/hub/main/states/miner/virgin/class_MinerVirginState.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerVirginState extends BaseMinerState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('virgin'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public final static function createMinerVirginState () { - // Get new instance - $stateInstance = new MinerVirginState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - */ - public function executeState (Executor $executorInstance) { - // Produce some keys now - $executorInstance->produceKeys($this); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/.htaccess b/application/hub/main/states/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/node/active/.htaccess b/application/hub/main/states/node/active/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/node/active/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/node/active/class_NodeActiveState.php b/application/hub/main/states/node/active/class_NodeActiveState.php deleted file mode 100644 index 0352ff754..000000000 --- a/application/hub/main/states/node/active/class_NodeActiveState.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeActiveState extends BaseNodeState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('active'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public static final function createNodeActiveState () { - // Get new instance - $stateInstance = new NodeActiveState(); - - // Get node instance and set 'active' flag - NodeObjectFactory::createNodeInstance()->enableIsActive(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * State change for if the node got announced to it's upper hubs - * - * @return void - */ - public function nodeAnnouncingToUpperHubs () { - // Create the new state instance - NodeStateFactory::createNodeStateInstanceByName('announcing'); - } - - /** - * State change for if the node has just connected to itself and - * node/session id are both equal. The self-connect means that - * the node possibly reachable from outside. This may require - * confirmation by other peers. - * - * @return void - * @todo We might want to move some calls to this method to fill it with life - */ - public function nodeHasSelfConnected () { - // Create the new state instance - NodeStateFactory::createNodeStateInstanceByName('reachable'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/announced/.htaccess b/application/hub/main/states/node/announced/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/node/announced/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php b/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php deleted file mode 100644 index f9fdba626..000000000 --- a/application/hub/main/states/node/announced/class_NodeAnnouncementCompletedState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeAnnouncementCompletedState extends BaseNodeState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('announcement_completed'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public static final function createNodeAnnouncementCompletedState () { - // Get new instance - $stateInstance = new NodeAnnouncementCompletedState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/announced/class_NodeAnnouncingState.php b/application/hub/main/states/node/announced/class_NodeAnnouncingState.php deleted file mode 100644 index d8b114eaa..000000000 --- a/application/hub/main/states/node/announced/class_NodeAnnouncingState.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeAnnouncingState extends BaseNodeState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('announcing'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public static final function createNodeAnnouncingState () { - // Get new instance - $stateInstance = new NodeAnnouncingState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Changes the state if the announcement (to bootstrap node) was - * successful. - * - * @return void - */ - public function nodeAnnouncementSuccessful () { - // The node's announcement was successful - NodeStateFactory::createNodeStateInstanceByName('announcement_completed'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/class_ b/application/hub/main/states/node/class_ deleted file mode 100644 index 82f1903d9..000000000 --- a/application/hub/main/states/node/class_ +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Node???State extends BaseNodeState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('!!!'); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance An instance of a NodeHelper class - * @return $stateInstance An instance of a Stateable class - */ - public final static function createNode???State (NodeHelper $nodeInstance) { - // Get new instance - $stateInstance = new Node???State(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - - // Set the node instance - $stateInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/class_BaseNodeState.php b/application/hub/main/states/node/class_BaseNodeState.php deleted file mode 100644 index 171331df8..000000000 --- a/application/hub/main/states/node/class_BaseNodeState.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseNodeState extends BaseState { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Validates whether the state is 'active' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' - */ - public function validateNodeStateIsActive () { - // Just compare it... - if (!$this instanceof NodeActiveState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Validates whether the state is 'active' or 'announcing' or throws an - * exception if it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' and not 'announcing' - */ - public function validateNodeStateIsActiveOrAnnouncing () { - // Just compare it... - if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeAnnouncingState)) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Validates whether the state is 'active' or 'reachable' or throws an - * exception if it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' and not 'reachable' - */ - public function validateNodeStateIsActiveOrReachable () { - // Just compare it... - if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeReachableState)) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Validates if the state is 'announcement_completed' or throws an - * exception if it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'active' and not 'announcing' - */ - public function validateNodeStateIsAnnouncementCompleted () { - // Just compare it... - if (!$this instanceof NodeAnnouncementCompletedState) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/init/.htaccess b/application/hub/main/states/node/init/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/node/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/node/init/class_NodeInitState.php b/application/hub/main/states/node/init/class_NodeInitState.php deleted file mode 100644 index 6f4014f17..000000000 --- a/application/hub/main/states/node/init/class_NodeInitState.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeInitState extends BaseNodeState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructo - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('init'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public static final function createNodeInitState () { - // Get new instance - $stateInstance = new NodeInitState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * State change for if the node has just generated a session id. This makes - * nodes with current state 'init' now 'virgin'. - * - * @return void - * @todo We might want to move some calls to this method to fill it with life - */ - public function nodeGeneratedSessionId () { - // Create the new state instance - NodeStateFactory::createNodeStateInstanceByName('virgin'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/seniors/.htaccess b/application/hub/main/states/node/seniors/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/node/seniors/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/node/seniors/class_NodeReachableState.php b/application/hub/main/states/node/seniors/class_NodeReachableState.php deleted file mode 100644 index 424198877..000000000 --- a/application/hub/main/states/node/seniors/class_NodeReachableState.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeReachableState extends BaseNodeState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('reachable'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public final static function createNodeReachableState () { - // Get new instance - $stateInstance = new NodeReachableState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * State change for if the node got announced to it's upper hubs - * - * @return void - */ - public function nodeAnnouncingToUpperHubs () { - // Create the new state instance - NodeStateFactory::createNodeStateInstanceByName('announcing'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/node/virgin/.htaccess b/application/hub/main/states/node/virgin/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/node/virgin/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/node/virgin/class_NodeVirginState.php b/application/hub/main/states/node/virgin/class_NodeVirginState.php deleted file mode 100644 index 2d83f58e1..000000000 --- a/application/hub/main/states/node/virgin/class_NodeVirginState.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeVirginState extends BaseNodeState implements Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('virgin'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a Stateable class - */ - public static final function createNodeVirginState () { - // Get new instance - $stateInstance = new NodeVirginState(); - - // Return the prepared instance - return $stateInstance; - } - - /** - * Change the state to 'active' when the hub has initialized all - * listeners, tasks, queues, etc. An active hub does not imply that it - * can be reached from outside so we have to deal with that state with - * yet another state class. - * - * @return void - */ - public function nodeIsActivated () { - // Create the new state instance - NodeStateFactory::createNodeStateInstanceByName('active'); - } - -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/.htaccess b/application/hub/main/states/peer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/peer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/peer/class_ b/application/hub/main/states/peer/class_ deleted file mode 100644 index 850482bc8..000000000 --- a/application/hub/main/states/peer/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???PeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_!!!); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function create???PeerState () { - // Get new instance - $stateInstance = new ???PeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/class_BasePeerState.php b/application/hub/main/states/peer/class_BasePeerState.php deleted file mode 100644 index cbbc183f2..000000000 --- a/application/hub/main/states/peer/class_BasePeerState.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BasePeerState extends BaseState { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Validates whether the state is 'connected' or throws an exception if - * it is every other state. - * - * @return void - * @throws UnexpectedStateException If the state is not 'connected' - */ - public function validatePeerStateConnected () { - // Just compare it... - if (!$this->isPeerStateConnected()) { - // Throw the exception - throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if - } - - /** - * Checks whether the peer's state is 'connected' - * - * @return $isConnected Whether the state is 'connected' - */ - public function isPeerStateConnected () { - // Just compare it... - return ($this instanceof ConnectedPeerState); - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/connected/.htaccess b/application/hub/main/states/peer/connected/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/peer/connected/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/peer/connected/class_ConnectedPeerState.php b/application/hub/main/states/peer/connected/class_ConnectedPeerState.php deleted file mode 100644 index 5080888d2..000000000 --- a/application/hub/main/states/peer/connected/class_ConnectedPeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConnectedPeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_CONNECTED); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createConnectedPeerState () { - // Get new instance - $stateInstance = new ConnectedPeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/errors/.htaccess b/application/hub/main/states/peer/errors/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/peer/errors/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/peer/errors/class_ConnectionRefusedPeerState.php b/application/hub/main/states/peer/errors/class_ConnectionRefusedPeerState.php deleted file mode 100644 index 813a703cb..000000000 --- a/application/hub/main/states/peer/errors/class_ConnectionRefusedPeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConnectionRefusedPeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_CONNECTION_REFUSED); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createConnectionRefusedPeerState () { - // Get new instance - $stateInstance = new ConnectionRefusedPeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/errors/class_ConnectionTimedOutPeerState.php b/application/hub/main/states/peer/errors/class_ConnectionTimedOutPeerState.php deleted file mode 100644 index 40f91a6c8..000000000 --- a/application/hub/main/states/peer/errors/class_ConnectionTimedOutPeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConnectionTimedOutPeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_CONNECTION_TIMED_OUT); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createConnectionTimedOutPeerState () { - // Get new instance - $stateInstance = new ConnectionTimedOutPeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/errors/class_NoRouteToHostPeerState.php b/application/hub/main/states/peer/errors/class_NoRouteToHostPeerState.php deleted file mode 100644 index a8c69784f..000000000 --- a/application/hub/main/states/peer/errors/class_NoRouteToHostPeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoRouteToHostPeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_NO_ROUTE_TO_HOST); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createNoRouteToHostPeerState () { - // Get new instance - $stateInstance = new NoRouteToHostPeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/errors/class_OperationAlreadyProgressPeerState.php b/application/hub/main/states/peer/errors/class_OperationAlreadyProgressPeerState.php deleted file mode 100644 index 9491ef79e..000000000 --- a/application/hub/main/states/peer/errors/class_OperationAlreadyProgressPeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class OperationAlreadyProgressPeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createOperationAlreadyProgressPeerState () { - // Get new instance - $stateInstance = new OperationAlreadyProgressPeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/errors/class_ProblemPeerState.php b/application/hub/main/states/peer/errors/class_ProblemPeerState.php deleted file mode 100644 index 06dbb9d57..000000000 --- a/application/hub/main/states/peer/errors/class_ProblemPeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ProblemPeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_UNKNOWN); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createProblemPeerState () { - // Get new instance - $stateInstance = new ProblemPeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/errors/class_TransportEndpointGonePeerState.php b/application/hub/main/states/peer/errors/class_TransportEndpointGonePeerState.php deleted file mode 100644 index 375cf7bf4..000000000 --- a/application/hub/main/states/peer/errors/class_TransportEndpointGonePeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TransportEndpointGonePeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createTransportEndpointGonePeerState () { - // Get new instance - $stateInstance = new TransportEndpointGonePeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/init/.htaccess b/application/hub/main/states/peer/init/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/peer/init/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/peer/init/class_InitPeerState.php b/application/hub/main/states/peer/init/class_InitPeerState.php deleted file mode 100644 index 2a1490725..000000000 --- a/application/hub/main/states/peer/init/class_InitPeerState.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InitPeerState extends BasePeerState implements PeerStateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('init'); - } - - /** - * Creates an instance of this class - * - * @return $stateInstance An instance of a PeerStateable class - */ - public final static function createInitPeerState () { - // Get new instance - $stateInstance = new InitPeerState(); - - // Return the prepared instance - return $stateInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/states/peer/new/.htaccess b/application/hub/main/states/peer/new/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/peer/new/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/states/peer/transport_endpoint/.htaccess b/application/hub/main/states/peer/transport_endpoint/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/states/peer/transport_endpoint/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/statistics/.htaccess b/application/hub/main/statistics/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/statistics/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/statistics/connection/.htaccess b/application/hub/main/statistics/connection/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/statistics/connection/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php b/application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php deleted file mode 100644 index a624e8dd5..000000000 --- a/application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConnectionStatisticsHelper extends BaseHubSystem { - /** - * Statistics array - * @TODO Add more protocols to use - */ - private static $connectionStatistics = array( - // Statistics for TCP connections - 'tcp' => array( - // Tried TCP connection attempts - 'retry_count' => array(), - ), - // Statistics for UDP connections - 'udp' => array( - // Tried UDP connection attempts - 'retry_count' => array(), - ) - ); - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - parent::__construct(__CLASS__); - } - - /** - * Checks whether the retry count has reached a configured limit for given - * connection. - * - * @param $helperInstance An instance of a ConnectionHelper class - * @return $isExhausted Whether the retry count has been reached - */ - public static function isConnectRetryExhausted (ConnectionHelper $helperInstance) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - CALLED!'); - // Construct config entry - $configEntry = $helperInstance->getProtocolName() . '_connect_retry_max'; - - // Check it out - $isExhausted = ( - ( - isset(self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count']) - ) && ( - self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] >= $helperInstance->getConfigInstance()->getConfigEntry($configEntry) - ) - ); - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ',isExhausted=' . intval($isExhausted) . ' - EXIT!'); - return $isExhausted; - } - - /** - * Increaes connect-retry count for given connection - * - * @param $helperInstance An instance of a ConnectionHelper class - * @return void - */ - public static function increaseConnectRetry (ConnectionHelper $helperInstance) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - CALLED!'); - // Is the counter there - if (!isset(self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'])) { - // First attempt - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - FIRST!'); - self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] = 1; - } else { - // Next attempt - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - INCREMENT!'); - self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count']++; - } - - // Create/update 'last_update' for purging - // @TODO last_update is not being used at the moment - self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['last_update'] = time(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/streams/.htaccess b/application/hub/main/streams/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/streams/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/streams/package/.htaccess b/application/hub/main/streams/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/streams/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/streams/package/input/.htaccess b/application/hub/main/streams/package/input/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/streams/package/input/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/streams/package/output/.htaccess b/application/hub/main/streams/package/output/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/streams/package/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/streams/raw_data/.htaccess b/application/hub/main/streams/raw_data/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/streams/raw_data/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/streams/raw_data/input/.htaccess b/application/hub/main/streams/raw_data/input/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/streams/raw_data/input/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/streams/raw_data/input/class_RawDataInputStream.php b/application/hub/main/streams/raw_data/input/class_RawDataInputStream.php deleted file mode 100644 index dcd58ca37..000000000 --- a/application/hub/main/streams/raw_data/input/class_RawDataInputStream.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RawDataInputStream extends BaseStream implements InputStream { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this node class - * - * @return $streamInstance An instance of this node class - */ - public final static function createRawDataInputStream () { - // Get a new instance - $streamInstance = new RawDataInputStream(); - - // Return the instance - return $streamInstance; - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @todo Do we need to do something more here? - * @throws Base64EncodingModuloException If the data's length modulo 4 is not zero - * @throws Base64EncodingBadException If the data contains characters which are not in the "alphabet" of BASE64 messages. - * @throws MultipleMessageSentException If the sender has sent two messages and both end up here - */ - public function streamData ($data) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-INPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ': data(' . strlen($data) . ')=' . $data); - - // Do we have start and end marker again? - assert($this->ifStartEndMarkersSet($data)); - - // Count of start and end markers must be the same - assert(substr_count($data, BaseRawDataHandler::STREAM_START_MARKER) == substr_count($data, BaseRawDataHandler::STREAM_END_MARKER)); - - // Check if more than two start markers exist and if so, split it. - if (substr_count($data, BaseRawDataHandler::STREAM_START_MARKER) > 1) { - // Please do it outside this method - throw new MultipleMessageSentException(array($this, $data), BaseHubSystem::EXCEPTION_MULTIPLE_MESSAGE_SENT); - } // END - if - - // Remove both - $data = substr($data, strlen(BaseRawDataHandler::STREAM_START_MARKER), -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER)); - - // Can it be validated? - if ((strlen($data) % 4) != 0) { - // Length modulo 4 must be zero, else it is an invalid Base64 message - throw new Base64EncodingModuloException(array($this, $data), BaseHubSystem::EXCEPTION_BASE64_ENCODING_NOT_MODULO_4); - } elseif (!$this->isBase64Encoded($data)) { - // Is not a valid Base64-encoded message - throw new Base64EncodingBadException(array($this, $data), BaseHubSystem::EXCEPTION_BASE64_BAD_ENCODING); - } else { - // Decode the data with BASE64-encoding - $data = base64_decode($data); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-INPUT-STREAM: Length of data is now ' . strlen($data) . ' Bytes.'); - - // Return it - return $data; - } -} - -// [EOF] -?> diff --git a/application/hub/main/streams/raw_data/output/.htaccess b/application/hub/main/streams/raw_data/output/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/streams/raw_data/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/streams/raw_data/output/class_RawDataOutputStream.php b/application/hub/main/streams/raw_data/output/class_RawDataOutputStream.php deleted file mode 100644 index 97ce0ae21..000000000 --- a/application/hub/main/streams/raw_data/output/class_RawDataOutputStream.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RawDataOutputStream extends BaseStream implements OutputStream { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this node class - * - * @return $streamInstance An instance of this node class - */ - public final static function createRawDataOutputStream () { - // Get a new instance - $streamInstance = new RawDataOutputStream(); - - // Return the instance - return $streamInstance; - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - */ - public function streamData ($data) { - /* - * Encode the data with BASE64 encoding and put it in a "frame": - * - * [[S]] - Start marker - * [[E]] - End marker - */ - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-OUTPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ']: data()=' . strlen($data) . ' - BEFORE!'); - $data = BaseRawDataHandler::STREAM_START_MARKER . base64_encode($data) . BaseRawDataHandler::STREAM_END_MARKER; - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-OUTPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ']: data(' . strlen($data) . ')=' . $data); - - // Return it - return $data; - } -} - -// [EOF] -?> diff --git a/application/hub/main/tags/.htaccess b/application/hub/main/tags/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tags/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tags/class_ b/application/hub/main/tags/class_ deleted file mode 100644 index 919141fab..000000000 --- a/application/hub/main/tags/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Tags extends BaseTags implements Tagable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $tagsInstance An instance of a Tagable class - */ - public final static function create???Tags () { - // Get new instance - $tagsInstance = new ???Tags(); - - // Return the prepared instance - return $tagsInstance; - } -} - -// [EOF] -?> diff --git a/application/hub/main/tags/class_BaseTags.php b/application/hub/main/tags/class_BaseTags.php deleted file mode 100644 index f48581776..000000000 --- a/application/hub/main/tags/class_BaseTags.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseTags extends BaseHubSystem implements Registerable { - /** - * An array with all tags - */ - private $tags = array(); - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for whole tags array - * - * @param $tags A new simple array with tags - * @return void - */ - protected final function setTags (array $tags) { - $this->tags = $tags; - } - - /** - * Getter for whole tags array - * - * @return $tags A new simple array with tags - */ - protected final function getTags () { - return $this->tags; - } -} - -// [EOF] -?> diff --git a/application/hub/main/tags/package/.htaccess b/application/hub/main/tags/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tags/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tags/package/class_PackageTags.php b/application/hub/main/tags/package/class_PackageTags.php deleted file mode 100644 index b2985f766..000000000 --- a/application/hub/main/tags/package/class_PackageTags.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PackageTags extends BaseTags implements Tagable { - // Exception codes - const EXCEPTION_INVALID_TAG = 0x160; - - /** - * Last found protocol instance - */ - private $lastProtocol = NULL; - - /** - * Last found recipient type - */ - private $lastRecipientType = 'invalid'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init the object registry - $this->initObjectRegistry(); - } - - /** - * Creates an instance of this class - * - * @return $tagsInstance An instance of a Tagable class - */ - public static final function createPackageTags () { - // Get new instance - $tagsInstance = new PackageTags(); - - // Return the prepared instance - return $tagsInstance; - } - - /** - * Loads the XML file (our "object registry") and saves an instance for - * faster re-use. - * - * @return void - */ - private function initObjectRegistry () { - // Output debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Initializing object registry - CALLED!'); - - // Get the application instance - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_object_registry_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML file - $this->getTemplateInstance()->loadXmlTemplate(); - - // Render the XML content - $this->getTemplateInstance()->renderXmlContent(); - - // Output debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Initializing object registry - EXIT!'); - } - - /** - * Extracts the tags from given package data - * - * @param $packageData Raw package data - * @return void - */ - private function extractTagsFromPackageData (array $packageData) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE)); - - /* - * We take a look at the tags (in most cases only one is needed) so - * first we need the content data splitted up into all it's parts. - */ - $contentData = explode(NetworkPackage::PACKAGE_MASK_SEPARATOR, $packageData[NetworkPackage::PACKAGE_DATA_CONTENT]); - - // Get the tags and store them locally - $this->setTags(explode(NetworkPackage::PACKAGE_TAGS_SEPARATOR, $contentData[NetworkPackage::INDEX_TAGS])); - } - - /** - * Verifies all tags by looking them up in an XML file. This method is - * the key method to make sure only known objects are being distributed and - * shared over the whole hub-network. So if the "tag" (let's better say - * object type) isn't found in that XML the package won't be distributed. - * - * @param $packageData Raw package data - * @return void - * @throws InvalidTagException If a provided tag from the package data is invalid - */ - private function verifyAllTags (array $packageData) { - // Get the registry - $objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); - - // "Walk" over all tags - foreach ($this->getTags() as $tag) { - // Debug output - self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Validating tag ' . $tag . ' ...'); - - // Get an array from this tag - $entry = $objectRegistryInstance->getArrayFromKey(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME, $tag); - - /* - * If it is no array or the array is empty or an entry is missing - * the entry is invalid. - */ - if ((!is_array($entry)) || (count($entry) == 0) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_PROTOCOL])) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]))) { - // Invalid entry found - throw new InvalidTagException(array($this, $tag), self::EXCEPTION_INVALID_TAG); - } // END - if - - // Now save the last discovered protocol/recipient type - $this->lastProtocol = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData); - $this->lastRecipientType = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]; - } // END - foreach - } - - /** - * Chooses the right protocol from given package data - * - * @param $packageData Raw package data - * @return $lastProtocol An instance of the last used HandleableProtocol class - */ - public function chooseProtocolFromPackageData (array $packageData) { - // Extract the tags - $this->extractTagsFromPackageData($packageData); - - // Now we need to verify every single tag - $this->verifyAllTags($packageData); - - // Return the last (and only) found protocol (e.g. 'tcp' is very usual) - return $this->lastProtocol; - } - - /** - * Checks whether the given package data is accepted by the listener - * - * @param $packageData Raw package data - * @param $listenerInstance A Listenable instance - * @return $accepts Whether it is accepted - */ - public function ifPackageDataIsAcceptedByListener (array $packageData, Listenable $listenerInstance) { - // Extract the tags - $this->extractTagsFromPackageData($packageData); - - // Now we need to verify every single tag - $this->verifyAllTags($packageData); - - // Now simply check it out - $accepts = (($this->lastRecipientType == $listenerInstance->getListenerType()) && ($listenerInstance->getListenerType() != 'invalid')); - - // And return the result - return $accepts; - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/.htaccess b/application/hub/main/tasks/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/apt-proxy/.htaccess b/application/hub/main/tasks/apt-proxy/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/apt-proxy/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/apt-proxy/class_ b/application/hub/main/tasks/apt-proxy/class_ deleted file mode 100644 index 51bc2a853..000000000 --- a/application/hub/main/tasks/apt-proxy/class_ +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Apt-Proxy Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxy???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createAptProxy???Task () { - // Get new instance - $taskInstance = new AptProxy???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/apt-proxy/class_AptProxyListenerTask.php b/application/hub/main/tasks/apt-proxy/class_AptProxyListenerTask.php deleted file mode 100644 index 8b9b3f5dd..000000000 --- a/application/hub/main/tasks/apt-proxy/class_AptProxyListenerTask.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AptProxyListenerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createAptProxyListenerTask () { - // Get new instance - $taskInstance = new AptProxyListenerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/chat/.htaccess b/application/hub/main/tasks/chat/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/chat/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/chat/class_ b/application/hub/main/tasks/chat/class_ deleted file mode 100644 index dec772a49..000000000 --- a/application/hub/main/tasks/chat/class_ +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Chat???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createChat???Task () { - // Get new instance - $taskInstance = new Chat???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php b/application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php deleted file mode 100644 index 81e19043e..000000000 --- a/application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2012 Chat Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ChatTelnetListenerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createChatTelnetListenerTask () { - // Get new instance - $taskInstance = new ChatTelnetListenerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/.htaccess b/application/hub/main/tasks/crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/class_BaseUrlSourceTask.php b/application/hub/main/tasks/crawler/class_BaseUrlSourceTask.php deleted file mode 100644 index 9399ae89c..000000000 --- a/application/hub/main/tasks/crawler/class_BaseUrlSourceTask.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseUrlSourceTask extends BaseTask { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Initializes URL source task (to keep the constructor small) - * - * @return void - */ - protected function initUrlSourceTask () { - // Get source instance - $sourceInstance = UrlSourceObjectFactory::createUrlSourceInstance($this); - - // And set it here - $this->setUrlSourceInstance($sourceInstance); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/class_Crawler b/application/hub/main/tasks/crawler/class_Crawler deleted file mode 100644 index f4d0f010b..000000000 --- a/application/hub/main/tasks/crawler/class_Crawler +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Crawler???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawler???Task () { - // Get new instance - $taskInstance = new Crawler???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/communicator/.htaccess b/application/hub/main/tasks/crawler/communicator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/communicator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php b/application/hub/main/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php deleted file mode 100644 index 3befcd344..000000000 --- a/application/hub/main/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerNodeCommunicatorTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerNodeCommunicatorTask () { - // Get new instance - $taskInstance = new CrawlerNodeCommunicatorTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the communicator instance - $communicatorInstance = CommunicatorFactory::createCommunicatorInstance('crawler_node_communicator_class', 'node'); - - // Get the current crawler state from registry - $stateInstance = Registry::getRegistry()->getInstance('crawler')->getStateInstance(); - - // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); - - // We can now invoke that state instance and pass our communicator instance for generating some test units - $stateInstance->executeState($communicatorInstance); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/document_parser/.htaccess b/application/hub/main/tasks/crawler/document_parser/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/document_parser/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/document_parser/class_CrawlerDocumentParserTask.php b/application/hub/main/tasks/crawler/document_parser/class_CrawlerDocumentParserTask.php deleted file mode 100644 index 2091ecc4e..000000000 --- a/application/hub/main/tasks/crawler/document_parser/class_CrawlerDocumentParserTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerDocumentParserTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerDocumentParserTask () { - // Get new instance - $taskInstance = new CrawlerDocumentParserTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/mime_sniffer/.htaccess b/application/hub/main/tasks/crawler/mime_sniffer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/mime_sniffer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/mime_sniffer/class_CrawlerMimeSnifferTask.php b/application/hub/main/tasks/crawler/mime_sniffer/class_CrawlerMimeSnifferTask.php deleted file mode 100644 index 976835caf..000000000 --- a/application/hub/main/tasks/crawler/mime_sniffer/class_CrawlerMimeSnifferTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerMimeSnifferTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerMimeSnifferTask () { - // Get new instance - $taskInstance = new CrawlerMimeSnifferTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/ping/.htaccess b/application/hub/main/tasks/crawler/ping/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/ping/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/ping/class_CrawlerPingTask.php b/application/hub/main/tasks/crawler/ping/class_CrawlerPingTask.php deleted file mode 100644 index 879bb94c6..000000000 --- a/application/hub/main/tasks/crawler/ping/class_CrawlerPingTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerPingTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerPingTask () { - // Get new instance - $taskInstance = new CrawlerPingTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/publisher/.htaccess b/application/hub/main/tasks/crawler/publisher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/publisher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/publisher/class_CrawlerRemoteJobPublisherTask.php b/application/hub/main/tasks/crawler/publisher/class_CrawlerRemoteJobPublisherTask.php deleted file mode 100644 index 73c5830d6..000000000 --- a/application/hub/main/tasks/crawler/publisher/class_CrawlerRemoteJobPublisherTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerRemoteJobPublisherTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerRemoteJobPublisherTask () { - // Get new instance - $taskInstance = new CrawlerRemoteJobPublisherTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/scanner/.htaccess b/application/hub/main/tasks/crawler/scanner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/scanner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/scanner/class_Crawler b/application/hub/main/tasks/crawler/scanner/class_Crawler deleted file mode 100644 index 4418af42f..000000000 --- a/application/hub/main/tasks/crawler/scanner/class_Crawler +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Crawler???ScannerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawler???ScannerTask () { - // Get new instance - $taskInstance = new Crawler???ScannerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Call factory for a scanner instance and execute it - ScannerFactory::createScannerInstance($this)->execute(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/scanner/uploaded_list/.htaccess b/application/hub/main/tasks/crawler/scanner/uploaded_list/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/scanner/uploaded_list/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/scanner/uploaded_list/class_CrawlerUploadedListScannerTask.php b/application/hub/main/tasks/crawler/scanner/uploaded_list/class_CrawlerUploadedListScannerTask.php deleted file mode 100644 index 14bde83b3..000000000 --- a/application/hub/main/tasks/crawler/scanner/uploaded_list/class_CrawlerUploadedListScannerTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUploadedListScannerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerUploadedListScannerTask () { - // Get new instance - $taskInstance = new CrawlerUploadedListScannerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Call factory for a scanner instance and execute it - ScannerObjectFactory::createScannerInstance($this)->execute(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/snippet_extractor/.htaccess b/application/hub/main/tasks/crawler/snippet_extractor/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/snippet_extractor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/snippet_extractor/class_CrawlerSnippetExtractorTask.php b/application/hub/main/tasks/crawler/snippet_extractor/class_CrawlerSnippetExtractorTask.php deleted file mode 100644 index e884207b9..000000000 --- a/application/hub/main/tasks/crawler/snippet_extractor/class_CrawlerSnippetExtractorTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerSnippetExtractorTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerSnippetExtractorTask () { - // Get new instance - $taskInstance = new CrawlerSnippetExtractorTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/structure_analyzer/.htaccess b/application/hub/main/tasks/crawler/structure_analyzer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/structure_analyzer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/structure_analyzer/class_CrawlerStructureAnalyzerTask.php b/application/hub/main/tasks/crawler/structure_analyzer/class_CrawlerStructureAnalyzerTask.php deleted file mode 100644 index 70215e802..000000000 --- a/application/hub/main/tasks/crawler/structure_analyzer/class_CrawlerStructureAnalyzerTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerStructureAnalyzerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerStructureAnalyzerTask () { - // Get new instance - $taskInstance = new CrawlerStructureAnalyzerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/url_crawler/.htaccess b/application/hub/main/tasks/crawler/url_crawler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/url_crawler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/url_crawler/local/.htaccess b/application/hub/main/tasks/crawler/url_crawler/local/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/url_crawler/local/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/url_crawler/local/class_CrawlerLocalUrlCrawlerTask.php b/application/hub/main/tasks/crawler/url_crawler/local/class_CrawlerLocalUrlCrawlerTask.php deleted file mode 100644 index df4828a06..000000000 --- a/application/hub/main/tasks/crawler/url_crawler/local/class_CrawlerLocalUrlCrawlerTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerLocalUrlCrawlerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerLocalUrlCrawlerTask () { - // Get new instance - $taskInstance = new CrawlerLocalUrlCrawlerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/url_crawler/remote/.htaccess b/application/hub/main/tasks/crawler/url_crawler/remote/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/url_crawler/remote/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/url_crawler/remote/class_CrawlerRemoteUrlCrawlerTask.php b/application/hub/main/tasks/crawler/url_crawler/remote/class_CrawlerRemoteUrlCrawlerTask.php deleted file mode 100644 index 6eebf1045..000000000 --- a/application/hub/main/tasks/crawler/url_crawler/remote/class_CrawlerRemoteUrlCrawlerTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerRemoteUrlCrawlerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerRemoteUrlCrawlerTask () { - // Get new instance - $taskInstance = new CrawlerRemoteUrlCrawlerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/url_source/.htaccess b/application/hub/main/tasks/crawler/url_source/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/crawler/url_source/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSource b/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSource deleted file mode 100644 index 7134efc27..000000000 --- a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSource +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUrlSource???Task extends BaseUrlSourceTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawler???Task () { - // Get new instance - $taskInstance = new Crawler???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); - - // Is it not set? - if (is_null($sourceInstance)) { - // Initialize it - $this->initUrlSourceTask(); - - // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); - } // END - if - - // Get the URL source instance and fill the stack with crawl entries - $sourceInstance->fillUrlStack(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php b/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php deleted file mode 100644 index 6059c56f5..000000000 --- a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUrlSourceFoundRssTask extends BaseUrlSourceTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerUrlSourceFoundRssTask () { - // Get new instance - $taskInstance = new CrawlerUrlSourceFoundRssTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); - - // Is it not set? - if (is_null($sourceInstance)) { - // Initialize it - $this->initUrlSourceTask(); - - // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); - } // END - if - - // Get the URL source instance and fill the stack with crawl entries - $sourceInstance->fillUrlStack(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php b/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php deleted file mode 100644 index 04131e44d..000000000 --- a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUrlSourceLocalStartTask extends BaseUrlSourceTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerUrlSourceLocalStartTask () { - // Get new instance - $taskInstance = new CrawlerUrlSourceLocalStartTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); - - // Is it not set? - if (is_null($sourceInstance)) { - // Initialize it - $this->initUrlSourceTask(); - - // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); - } // END - if - - // Get the URL source instance and fill the stack with crawl entries - $sourceInstance->fillUrlStack(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php b/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php deleted file mode 100644 index 5626afd80..000000000 --- a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUrlSourceRssStartTask extends BaseUrlSourceTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerUrlSourceRssStartTask () { - // Get new instance - $taskInstance = new CrawlerUrlSourceRssStartTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); - - // Is it not set? - if (is_null($sourceInstance)) { - // Initialize it - $this->initUrlSourceTask(); - - // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); - } // END - if - - // Get the URL source instance and fill the stack with crawl entries - $sourceInstance->fillUrlStack(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php b/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php deleted file mode 100644 index 0b6b89176..000000000 --- a/application/hub/main/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Crawler Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CrawlerUrlSourceUploadedListTask extends BaseUrlSourceTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCrawlerUrlSourceUploadedListTask () { - // Get new instance - $taskInstance = new CrawlerUrlSourceUploadedListTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get source instance - $sourceInstance = $this->getUrlSourceInstance(); - - // Is it not set? - if (is_null($sourceInstance)) { - // Initialize it - $this->initUrlSourceTask(); - - // And re-get it - $sourceInstance = $this->getUrlSourceInstance(); - } // END - if - - // Get the URL source instance and fill the stack with crawl entries - $sourceInstance->fillUrlStack(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/cruncher/.htaccess b/application/hub/main/tasks/cruncher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/cruncher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/cruncher/class_Cruncher b/application/hub/main/tasks/cruncher/class_Cruncher deleted file mode 100644 index 2c9cbf859..000000000 --- a/application/hub/main/tasks/cruncher/class_Cruncher +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2012 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Cruncher???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createCruncher???Task () { - // Get new instance - $taskInstance = new Cruncher???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/cruncher/class_CruncherKeyProducerTask.php b/application/hub/main/tasks/cruncher/class_CruncherKeyProducerTask.php deleted file mode 100644 index a19428218..000000000 --- a/application/hub/main/tasks/cruncher/class_CruncherKeyProducerTask.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherKeyProducerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public final static function createCruncherKeyProducerTask () { - // Get new instance - $taskInstance = new CruncherKeyProducerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the instance - $producerInstance = ProducerFactory::createProducerInstance('cruncher_key_producer_class', 'key'); - - // Get the current cruncher state from registry - $stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); - - // We can now invoke that state instance and pass our producer instance for generating some test units - $stateInstance->executeState($producerInstance); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php b/application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php deleted file mode 100644 index dc5aeb72c..000000000 --- a/application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherTestUnitProducerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public final static function createCruncherTestUnitProducerTask () { - // Get new instance - $taskInstance = new CruncherTestUnitProducerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the producer instance - $producerInstance = ProducerFactory::createProducerInstance('cruncher_test_unit_producer_class', 'test_unit'); - - // Get the current cruncher state from registry - $stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); - - // We can now invoke that state instance and pass our producer instance for generating some test units - $stateInstance->executeState($producerInstance); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php b/application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php deleted file mode 100644 index 87068b0b2..000000000 --- a/application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CruncherWorkUnitFetcherTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public final static function createCruncherWorkUnitFetcherTask () { - // Get new instance - $taskInstance = new CruncherWorkUnitFetcherTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - /* - * Get the cruncher instance and call a method which should check if - * the in-buffer is going to depleted. If so, new WUs are fetched from - * network or (if enabled in config) a random test WU is being - * generated. This test WU is for developing only or, if you like, to - * test your cruncher loop. - * - * Please report any bugs you encounter to me. - */ - Registry::getRegistry()->getInstance('cruncher')->doFetchWorkUnits(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/miner/.htaccess b/application/hub/main/tasks/miner/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/miner/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/miner/block_fetcher/.htaccess b/application/hub/main/tasks/miner/block_fetcher/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/miner/block_fetcher/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php b/application/hub/main/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php deleted file mode 100644 index 22de1ae89..000000000 --- a/application/hub/main/tasks/miner/block_fetcher/class_MinerBlockFetcherTask.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerBlockFetcherTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public final static function createMinerBlockFetcherTask () { - // Get new instance - $taskInstance = new MinerBlockFetcherTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - /* - * Get the miner instance and call a method which should check if - * the in-buffer is going to depleted. If so, new WUs are fetched from - * network or (if enabled in config) a random test WU is being - * generated. This test WU is for developing only or, if you like, to - * test your miner loop. - * - * Please report any bugs you encounter to me. - */ - Registry::getRegistry()->getInstance('miner')->doSearchForBlocks(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/miner/block_producer/.htaccess b/application/hub/main/tasks/miner/block_producer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/miner/block_producer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/miner/block_producer/class_MinerRealGenesisBlockProducerTask.php b/application/hub/main/tasks/miner/block_producer/class_MinerRealGenesisBlockProducerTask.php deleted file mode 100644 index 7ca28a3ac..000000000 --- a/application/hub/main/tasks/miner/block_producer/class_MinerRealGenesisBlockProducerTask.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerRealGenesisBlockProducerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public final static function createMinerRealGenesisBlockProducerTask () { - // Get new instance - $taskInstance = new MinerRealGenesisBlockProducerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the producer instance - $producerInstance = ProducerFactory::createProducerInstance('miner_real_genesis_block_producer_class', 'real_unit'); - - // Get the current miner state from registry - $stateInstance = Registry::getRegistry()->getInstance('miner')->getStateInstance(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); - - // We can now invoke that state instance and pass our producer instance for generating some test units - $stateInstance->executeState($producerInstance); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php b/application/hub/main/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php deleted file mode 100644 index 0cdda15dc..000000000 --- a/application/hub/main/tasks/miner/block_producer/class_MinerTestGenesisBlockProducerTask.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerTestGenesisBlockProducerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public final static function createMinerTestGenesisBlockProducerTask () { - // Get new instance - $taskInstance = new MinerTestGenesisBlockProducerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the producer instance - $producerInstance = ProducerFactory::createProducerInstance('miner_test_genesis_block_producer_class', 'test_unit'); - - // Get the current miner state from registry - $stateInstance = Registry::getRegistry()->getInstance('miner')->getStateInstance(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); - - // We can now invoke that state instance and pass our producer instance for generating some test units - $stateInstance->executeState($producerInstance); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/miner/class_Miner b/application/hub/main/tasks/miner/class_Miner deleted file mode 100644 index bc946d8a7..000000000 --- a/application/hub/main/tasks/miner/class_Miner +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Miner???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createMiner???Task () { - // Get new instance - $taskInstance = new Miner???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/miner/communicator/.htaccess b/application/hub/main/tasks/miner/communicator/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/miner/communicator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php b/application/hub/main/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php deleted file mode 100644 index 5f87718a2..000000000 --- a/application/hub/main/tasks/miner/communicator/class_MinerNodeCommunicatorTask.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2014 Miner Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MinerNodeCommunicatorTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createMinerNodeCommunicatorTask () { - // Get new instance - $taskInstance = new MinerNodeCommunicatorTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the communicator instance - $communicatorInstance = CommunicatorFactory::createCommunicatorInstance('miner_node_communicator_class', 'node'); - - // Get the current miner state from it - $stateInstance = $communicatorInstance->getStateInstance(); - - // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString()); - - // We can now invoke that state instance and pass our communicator instance for generating some test units - $stateInstance->executeState($communicatorInstance); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/network/.htaccess b/application/hub/main/tasks/network/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/network/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/network/class_NetworkPackage b/application/hub/main/tasks/network/class_NetworkPackage deleted file mode 100644 index 0f649ccde..000000000 --- a/application/hub/main/tasks/network/class_NetworkPackage +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NetworkPackage???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNetworkPackage???Task () { - // Get new instance - $taskInstance = new NetworkPackage???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php deleted file mode 100644 index 1cbbb8f93..000000000 --- a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createNetworkPackageReaderTask () { - // Get new instance - $taskInstance = new NetworkPackageReaderTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Also visit some sub-objects? - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // "Cache" package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Do we have something to handle? - if ($packageInstance->isProcessedMessagePending()) { - /* - * A previously proccessed message is waiting for being - * "interpreted". This is done by trying to find a configuration - * entry based on 'message_type' element. - */ - $packageInstance->handleProcessedMessage(); - } elseif ($packageInstance->isNewMessageArrived()) { - /* - * A fully "decoded" message has been received and added for being - * processed. Processing a message should not take long, so mostly - * this step involves reading all data through a XML template engine - * as "XML variables" from the content (which must be a well-formed - * XML) and then pushing it on the next stack "processed messages". - */ - $packageInstance->handleNewlyArrivedMessage(); - } elseif ($packageInstance->isIncomingRawDataHandled()) { - /* - * Incoming decoded data has been handled (see below) so it needs to - * be assembled back to a "package array". Please see NetworkPackage - * for further details (what array elements are required et cetera). - */ - $packageInstance->assembleDecodedDataToPackage(); - } elseif ($packageInstance->ifMultipleMessagesPending()) { - /* - * Some raw data contained multiple messages which where now splitted. - */ - $packageInstance->handleMultipleMessages(); - } elseif ($packageInstance->isNewRawDataPending()) { - // Raw, decoded data has been received - $packageInstance->handleIncomingDecodedData(); - } elseif ($packageInstance->ifAssemblerHasPendingDataLeft()) { - // Handle any pending data from the package assembler - $packageInstance->handleAssemblerPendingData(); - } // END - if - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php b/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php deleted file mode 100644 index 3f24ec0f6..000000000 --- a/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createNetworkPackageWriterTask () { - // Get new instance - $taskInstance = new NetworkPackageWriterTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Also visit some sub-objects? - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // "Cache" package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Do we have something to deliver? - if ($packageInstance->isEncodedDataPending()) { - // Sent encoded (raw) data - $packageInstance->sendEncodedData(); - } elseif ($packageInstance->isPackageWaitingForDelivery()) { - // Sent it finally out - $packageInstance->sendWaitingPackage(); - } elseif ($packageInstance->isPackageDeclared()) { - // Prepare package for delivery - $packageInstance->processDeclaredPackage(); - } elseif ($packageInstance->isPackageEnqueued()) { - // Okay, then deliver (better discover its recipients) this package - $packageInstance->declareEnqueuedPackage(); - } - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/.htaccess b/application/hub/main/tasks/node/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/announcement/.htaccess b/application/hub/main/tasks/node/announcement/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/announcement/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/announcement/class_NodeAnnouncementTask.php b/application/hub/main/tasks/node/announcement/class_NodeAnnouncementTask.php deleted file mode 100644 index 6ca0a0a71..000000000 --- a/application/hub/main/tasks/node/announcement/class_NodeAnnouncementTask.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeAnnouncementTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createNodeAnnouncementTask () { - // Get new instance - $taskInstance = new NodeAnnouncementTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the node instance and announce us - NodeObjectFactory::createNodeInstance()->announceToUpperNodes($this); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/chunks/.htaccess b/application/hub/main/tasks/node/chunks/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/chunks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php b/application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php deleted file mode 100644 index da9edb417..000000000 --- a/application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeChunkAssemblerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeChunkAssemblerTask () { - // Get new instance - $taskInstance = new NodeChunkAssemblerTask(); - - // Get a chunk handler instance - $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); - - // And add it to this task instance - $taskInstance->setHandlerInstance($handlerInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Also visit some sub-objects? - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // "Cache" handler instance - $handlerInstance = $this->getHandlerInstance(); - - // Are there chunks to handle or a final array to assemble? - if ($handlerInstance->ifUnassembledChunksAvailable()) { - /* - * Then do the final steps: - * - * 1) Sort the final array with ksort(). This will bring the "hash - * chunk" up to the last array index and the EOP chunk to the - * pre-last array index - * 2) Assemble all chunks except two last (see above step) - * 3) While so, do the final check on all hashes - * 4) If the package is assembled back together, hash it again for - * the very final verification. - */ - $handlerInstance->assembleChunksFromFinalArray(); - } elseif ($handlerInstance->ifUnhandledChunksWithFinalAvailable()) { - /* - * Then handle them (not all!). This should push all chunks into a - * 'final array' for last verification. - */ - $handlerInstance->handleAvailableChunksWithFinal(); - } elseif ($handlerInstance->ifRawPackageDataIsAvailable()) { - /* - * The final raw package data is back together again. So feed it - * into the next stack for further decoding/processing - */ - $handlerInstance->handledAssembledRawPackageData(); - } - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/class_Node b/application/hub/main/tasks/node/class_Node deleted file mode 100644 index b73ff490b..000000000 --- a/application/hub/main/tasks/node/class_Node +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Node???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNode???Task () { - // Get new instance - $taskInstance = new Node???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% done - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/decoder/.htaccess b/application/hub/main/tasks/node/decoder/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/decoder/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php b/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php deleted file mode 100644 index f12b2205e..000000000 --- a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodePackageDecoderTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodePackageDecoderTask () { - // Get new instance - $taskInstance = new NodePackageDecoderTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get a decoder instance - $decoderInstance = DecoderFactory::createPackageDecoderInstance(); - - // Check if the stacker has some entries left - if ($decoderInstance->ifUnhandledRawPackageDataLeft()) { - // Then handle it - $decoderInstance->handleRawPackageData(); - } elseif ($decoderInstance->ifDeocedPackagesLeft()) { - // Some decoded packages have arrived (for this peer) - $decoderInstance->handleDecodedPackage(); - } - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/.htaccess b/application/hub/main/tasks/node/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/dht/class_NodeDht b/application/hub/main/tasks/node/dht/class_NodeDht deleted file mode 100644 index 74640b57d..000000000 --- a/application/hub/main/tasks/node/dht/class_NodeDht +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDht???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeDht???Task () { - // Get new instance - $taskInstance = new NodeDht???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% done - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtBootstrapTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtBootstrapTask.php deleted file mode 100644 index a794cafa7..000000000 --- a/application/hub/main/tasks/node/dht/class_NodeDhtBootstrapTask.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtBootstrapTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeDhtBootstrapTask () { - // Get new instance - $taskInstance = new NodeDhtBootstrapTask(); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Let the DHT class do the work for us - $this->getDhtInstance()->bootstrapDht(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtInitializationTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtInitializationTask.php deleted file mode 100644 index 6485392f7..000000000 --- a/application/hub/main/tasks/node/dht/class_NodeDhtInitializationTask.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtInitializationTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeDhtInitializationTask () { - // Get new instance - $taskInstance = new NodeDhtInitializationTask(); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Intiailize the DHT - $this->getDhtInstance()->initDht(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtLateBootstrapTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtLateBootstrapTask.php deleted file mode 100644 index 367a3d813..000000000 --- a/application/hub/main/tasks/node/dht/class_NodeDhtLateBootstrapTask.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtLateBootstrapTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeDhtLateBootstrapTask () { - // Get new instance - $taskInstance = new NodeDhtLateBootstrapTask(); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Let the DHT class do the work for us - $this->getDhtInstance()->bootstrapDht(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtPublicationCheckTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtPublicationCheckTask.php deleted file mode 100644 index 48da0743c..000000000 --- a/application/hub/main/tasks/node/dht/class_NodeDhtPublicationCheckTask.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtPublicationCheckTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeDhtPublicationCheckTask () { - // Get new instance - $taskInstance = new NodeDhtPublicationCheckTask(); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo Add more? - */ - public function executeTask () { - // Get DHT instance - $dhtInstance = $this->getDhtInstance(); - - // Has the DHT some unpublished entries? - if (($dhtInstance->hasFullyBootstrapped()) && ($dhtInstance->hasUnpublishedEntries())) { - // Then initiate publishing them - $dhtInstance->initEntryPublication(); - } // END - if - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtPublicationTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtPublicationTask.php deleted file mode 100644 index 813e4e2ad..000000000 --- a/application/hub/main/tasks/node/dht/class_NodeDhtPublicationTask.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtPublicationTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeDhtPublicationTask () { - // Get new instance - $taskInstance = new NodeDhtPublicationTask(); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo Add more? - */ - public function executeTask () { - // Get DHT instance - $dhtInstance = $this->getDhtInstance(); - - // Has the DHT some entries pending publication? - if ($dhtInstance->hasEntriesPendingPublication()) { - // Then publish next entry - $dhtInstance->publishEntry(); - } // END - if - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php deleted file mode 100644 index 503f0474d..000000000 --- a/application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodeDhtQueryTask () { - // Get new instance - $taskInstance = new NodeDhtQueryTask(); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo ~5% done - */ - public function executeTask () { - // Get DHT instance - $dhtInstance = $this->getDhtInstance(); - - // Are there "INSERT" node data entries? - if ($dhtInstance->ifInsertNodeDataPending()) { - // Then insert a single entry - $dhtInstance->insertSingleNodeData(); - } // END - if - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/listener/.htaccess b/application/hub/main/tasks/node/listener/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/listener/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/listener/class_NodeSocketListenerTask.php b/application/hub/main/tasks/node/listener/class_NodeSocketListenerTask.php deleted file mode 100644 index 6bf9901eb..000000000 --- a/application/hub/main/tasks/node/listener/class_NodeSocketListenerTask.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeSocketListenerTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createNodeSocketListenerTask () { - // Get new instance - $taskInstance = new NodeSocketListenerTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Get the node instance from registry - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Visit the pool listener task - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('LISTENER-TASK[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...'); - $nodeInstance->getListenerPoolInstance()->accept($visitorInstance); - - // Visit this task - // @TODO Do we need to visit this task? $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% done - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/ping/.htaccess b/application/hub/main/tasks/node/ping/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/ping/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/ping/class_NodePingTask.php b/application/hub/main/tasks/node/ping/class_NodePingTask.php deleted file mode 100644 index 4457e98d1..000000000 --- a/application/hub/main/tasks/node/ping/class_NodePingTask.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodePingTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listInstance A Listable instance - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createNodePingTask (Listable $listInstance) { - // Get new instance - $taskInstance = new NodePingTask(); - - // Se the list instance in this task - $taskInstance->setListInstance($listInstance); - - // Init ping iterator instance - $iteratorInstance = $listInstance->getListIterator(); - - // Set it as well - $taskInstance->setIteratorInstance($iteratorInstance); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Also visit some sub-objects? - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% done - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/self_connect/.htaccess b/application/hub/main/tasks/node/self_connect/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/self_connect/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/self_connect/class_NodeSelfConnectTask.php b/application/hub/main/tasks/node/self_connect/class_NodeSelfConnectTask.php deleted file mode 100644 index 8a7d99fb1..000000000 --- a/application/hub/main/tasks/node/self_connect/class_NodeSelfConnectTask.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeSelfConnectTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createNodeSelfConnectTask () { - // Get new instance - $taskInstance = new NodeSelfConnectTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get the node instance and try it - NodeObjectFactory::createNodeInstance()->doSelfConnection($this); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/tags/.htaccess b/application/hub/main/tasks/node/tags/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/tags/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/tags/class_NodePackageTagsInitTask.php b/application/hub/main/tasks/node/tags/class_NodePackageTagsInitTask.php deleted file mode 100644 index e183bedd3..000000000 --- a/application/hub/main/tasks/node/tags/class_NodePackageTagsInitTask.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodePackageTagsInitTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function createNodePackageTagsInitTask () { - // Get new instance - $taskInstance = new NodePackageTagsInitTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Get a factory instance and do no more as this loads the object (tags) registry - $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/update/.htaccess b/application/hub/main/tasks/node/update/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/node/update/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/node/update/class_NodeUpdateCheckTask.php b/application/hub/main/tasks/node/update/class_NodeUpdateCheckTask.php deleted file mode 100644 index 49eeef88f..000000000 --- a/application/hub/main/tasks/node/update/class_NodeUpdateCheckTask.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeUpdateCheckTask extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createNodeUpdateCheckTask () { - // Get new instance - $taskInstance = new NodeUpdateCheckTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo 0% - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/.htaccess b/application/hub/main/template/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/announcement/.htaccess b/application/hub/main/template/announcement/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/announcement/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php deleted file mode 100644 index 5c528e852..000000000 --- a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php +++ /dev/null @@ -1,358 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id'; - const ANNOUNCEMENT_DATA_NODE_ID = 'node-id'; - const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; - const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status'; - const ANNOUNCEMENT_DATA_NODE_MODE = 'node-mode'; - const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'external-address'; - const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'internal-address'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - 'announcement-data', - 'listener', - self::ANNOUNCEMENT_DATA_NODE_STATUS, - self::ANNOUNCEMENT_DATA_NODE_MODE, - self::ANNOUNCEMENT_DATA_NODE_ID, - self::ANNOUNCEMENT_DATA_SESSION_ID, - self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, - self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, - 'object-type-list', - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlAnnouncementTemplateEngine () { - // Get a new instance - $templateInstance = new XmlAnnouncementTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'announcement'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_announcement'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the announcement - * - * @return void - */ - protected function startAnnouncement () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'announcement'); - } - - /** - * Starts the announcement data - * - * @return void - */ - protected function startAnnouncementData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'announcement-data'); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'listener'); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_SESSION_ID); - } - - /** - * Starts the node id - * - * @return void - */ - protected function startNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_ID); - } - - /** - * Starts the private key hash - * - * @return void - */ - protected function startPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the private ip - * - * @return void - */ - protected function startInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the object type list - * - * @return void - */ - protected function startObjectTypeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'object-type-list'); - } - - /** - * Starts the object type - * - * @return void - */ - protected function startObjectType () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement', 'object-type'); - } - - /** - * Finishes the object type - * - * @return void - */ - protected function finishObjectType () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the object type list - * - * @return void - */ - protected function finishObjectTypeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the private key hash - * - * @return void - */ - protected function finishPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the node id - * - * @return void - */ - protected function finishNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the private ip - * - * @return void - */ - protected function finishInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the announcement data - * - * @return void - */ - protected function finishAnnouncementData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } - - /** - * Finishes the announcement - * - * @return void - */ - protected function finishAnnouncement () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/answer/.htaccess b/application/hub/main/template/answer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/answer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/answer/announcement/.htaccess b/application/hub/main/template/answer/announcement/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/answer/announcement/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php deleted file mode 100644 index 87ed8fa54..000000000 --- a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ /dev/null @@ -1,406 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const ANNOUNCEMENT_DATA_NODE_ID = 'my-node-id'; - const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id'; - const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; - const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status'; - const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address'; - const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub-nodes array - $this->setSubNodes(array( - // These nodes don't contain any data - 'my-data', - 'your-data', - // Data from *this* node - self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, - self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, - self::ANNOUNCEMENT_DATA_NODE_STATUS, - self::ANNOUNCEMENT_DATA_NODE_ID, - self::ANNOUNCEMENT_DATA_SESSION_ID, - self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH, - // Data from other node - 'your-external-address', - 'your-internal-address', - 'your-node-id', - 'your-session-id', - 'your-private-key-hash', - // Answer status (generic field) - self::ANSWER_STATUS, - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlAnnouncementAnswerTemplateEngine () { - // Get a new instance - $templateInstance = new XmlAnnouncementAnswerTemplateEngine(); - - // Init instance - $templateInstance->initXmlTemplateEngine('node', 'announcement_answer'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getAnnouncementAnswerCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the announcement-answer - * - * @return void - */ - protected function startAnnouncementAnswer () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer'); - } - - /** - * Starts the my-data - * - * @return void - */ - protected function startMyData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data'); - } - - /** - * Starts the my-external-address - * - * @return void - */ - protected function startMyExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the my-internal-address - * - * @return void - */ - protected function startMyInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the my-node-id - * - * @return void - */ - protected function startMyNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_ID); - } - - /** - * Starts the my-session-id - * - * @return void - */ - protected function startMySessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID); - } - - /** - * Starts the my-private-key-hash - * - * @return void - */ - protected function startMyPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the my-status - * - * @return void - */ - protected function startMyStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS); - } - - /** - * Finishes the my-status - * - * @return void - */ - protected function finishMyStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-private-key-hash - * - * @return void - */ - protected function finishMyPrivateKeyhash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-session-id - * - * @return void - */ - protected function finishMySessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-node-id - * - * @return void - */ - protected function finishMyNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-internal-address - * - * @return void - */ - protected function finishMyInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-external-address - * - * @return void - */ - protected function finishMyExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the my-data - * - * @return void - */ - protected function finishMyData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Starts the your-data - * - * @return void - */ - protected function startYourData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data'); - } - - /** - * Starts the your-external-address - * - * @return void - */ - protected function startYourExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address'); - } - - /** - * Starts the your-internal-address - * - * @return void - */ - protected function startYourInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address'); - } - - /** - * Starts the your-session-id - * - * @return void - */ - protected function startYourSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id'); - } - - /** - * Starts the your-node-id - * - * @return void - */ - protected function startYourNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-node-id'); - } - - /** - * Starts the your-private-key-hash - * - * @return void - */ - protected function startYourPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-private-key-hash'); - } - - /** - * Finishes the your-private-key-hash - * - * @return void - */ - protected function finishYourPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-node-id - * - * @return void - */ - protected function finishYourNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-session-id - * - * @return void - */ - protected function finishYourSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-internal-address - * - * @return void - */ - protected function finishYourInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-external-address - * - * @return void - */ - protected function finishYourExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the your-data - * - * @return void - */ - protected function finishYourData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } - - /** - * Finishes the announcement-answer - * - * @return void - */ - protected function finishAnnouncementAnswer () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_announcement_answer'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/answer/class_ b/application/hub/main/template/answer/class_ deleted file mode 100644 index 7aba4b38d..000000000 --- a/application/hub/main/template/answer/class_ +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXml???TemplateEngine () { - // Get a new instance - $templateInstance = new Xml???TemplateEngine(); - - // Init template instannce - $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return false; - } // END - if - - // Assign data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function get???CacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the ||| - * - * @return void - */ - protected function start??? () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('!!!', '|||'); - } - - /** - * Finishes the ||| - * - * @return void - */ - protected function finish??? () { - // Pop the last entry - $this->getStackInstance()->popNamed('!!!'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/answer/class_BaseXmlAnswerTemplateEngine.php b/application/hub/main/template/answer/class_BaseXmlAnswerTemplateEngine.php deleted file mode 100644 index 261d834d1..000000000 --- a/application/hub/main/template/answer/class_BaseXmlAnswerTemplateEngine.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Generic 'answer-status' field - */ - const ANSWER_STATUS = 'answer-status'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Starts the answer-status - * - * @return void - */ - protected function startAnswerStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed($this->getStackerName(), self::ANSWER_STATUS); - } - - /** - * Finishes the answer-status - * - * @return void - */ - protected function finishAnswerStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed($this->getStackerName()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/answer/dht/.htaccess b/application/hub/main/template/answer/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/answer/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php deleted file mode 100644 index 38a46461a..000000000 --- a/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php +++ /dev/null @@ -1,384 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const DHT_BOOTSTRAP_DATA_SESSION_ID = 'my-session-id'; - const DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash'; - const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'my-status'; - const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'my-external-address'; - const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'my-internal-address'; - const DHT_BOOTSTRAP_DATA_NODE_LIST = 'dht-nodes-list'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub-nodes array - $this->setSubNodes(array( - // These nodes don't contain any data - 'my-data', - 'your-data', - // Data from *this* node - self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, - self::DHT_BOOTSTRAP_DATA_NODE_STATUS, - self::DHT_BOOTSTRAP_DATA_SESSION_ID, - // Data from other node - 'your-external-address', - 'your-internal-address', - 'your-session-id', - // Answer status (generic field) - self::ANSWER_STATUS, - // DHT node list - self::DHT_BOOTSTRAP_DATA_NODE_LIST, - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlDhtBootstrapAnswerTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtBootstrapAnswerTemplateEngine(); - - // Init instance - $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap_answer'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_dht_bootstrap_answer'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getDhtBootstrapAnswerCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the dht_bootstrap-answer - * - * @return void - */ - protected function startDhtBootstrapAnswer () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'dht_bootstrap-answer'); - } - - /** - * Starts the my-data - * - * @return void - */ - protected function startMyData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'my-data'); - } - - /** - * Starts the my-external-address - * - * @return void - */ - protected function startMyExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the my-internal-address - * - * @return void - */ - protected function startMyInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the my-session-id - * - * @return void - */ - protected function startMySessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_SESSION_ID); - } - - /** - * Starts the my-private-key-hash - * - * @return void - */ - protected function startMyPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the my-status - * - * @return void - */ - protected function startMyStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); - } - - /** - * Starts the dht-nodes-list - * - * @return void - */ - protected function startDhtNodesList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_NODE_LIST); - } - - /** - * Finishes the dht-nodes-list - * - * @return void - */ - protected function finishDhtNodesList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-status - * - * @return void - */ - protected function finishMyStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-private-key-hash - * - * @return void - */ - protected function finishMyPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-session-id - * - * @return void - */ - protected function finishMySessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-internal-address - * - * @return void - */ - protected function finishMyInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-external-address - * - * @return void - */ - protected function finishMyExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the my-data - * - * @return void - */ - protected function finishMyData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Starts the your-data - * - * @return void - */ - protected function startYourData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-data'); - } - - /** - * Starts the your-external-address - * - * @return void - */ - protected function startYourExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-external-address'); - } - - /** - * Starts the your-internal-address - * - * @return void - */ - protected function startYourInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-internal-address'); - } - - /** - * Starts the your-session-id - * - * @return void - */ - protected function startYourSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-session-id'); - } - - /** - * Starts the your-private-key-hash - * - * @return void - */ - protected function startYourPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-private-key-hash'); - } - - /** - * Finishes the your-private-key-hash - * - * @return void - */ - protected function finishYourPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-session-id - * - * @return void - */ - protected function finishYourSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-internal-address - * - * @return void - */ - protected function finishYourInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-external-address - * - * @return void - */ - protected function finishYourExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the your-data - * - * @return void - */ - protected function finishYourData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } - - /** - * Finishes the dht_bootstrap-answer - * - * @return void - */ - protected function finishDhtBootstrapAnswer () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_dht_bootstrap_answer'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/answer/requests/.htaccess b/application/hub/main/template/answer/requests/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/answer/requests/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php deleted file mode 100644 index 681078334..000000000 --- a/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php +++ /dev/null @@ -1,172 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { - // Constants for array elements - const REQUEST_DATA_SESSION_ID = 'session-id'; - const REQUEST_DATA_NODE_LIST = 'node-list'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub-nodes array - $this->setSubNodes(array( - self::REQUEST_DATA_SESSION_ID, - self::REQUEST_DATA_NODE_LIST, - // Answer status (generic field) - self::ANSWER_STATUS, - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlRequestNodeListAnswerTemplateEngine () { - // Get a new instance - $templateInstance = new XmlRequestNodeListAnswerTemplateEngine(); - - // Init instance - $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer'); - - // Get a template instance for list entries (as they are dynamic) - $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class'); - - // Set it here - $templateInstance->setTemplateInstance($entriesInstance); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_answer'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getRequestNodeListAnswerCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the 'request-node-list-answer' - * - * @return void - */ - protected function startRequestNodeListAnswer () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer'); - } - - /** - * Starts the session-id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_SESSION_ID); - } - - /** - * Starts the node-list - * - * @return void - */ - protected function startNodeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_NODE_LIST); - } - - /** - * Finishes the node-list - * - * @return void - */ - protected function finishNodeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_answer'); - } - - /** - * Finishes the session-id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_answer'); - } - - /** - * Finishes the 'request-node-list-answer' - * - * @return void - */ - protected function finishRequestNodeListAnswer () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_answer'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/class_ b/application/hub/main/template/class_ deleted file mode 100644 index a36aad5f5..000000000 --- a/application/hub/main/template/class_ +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Xml???TemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXml???TemplateEngine () { - // Get a new instance - $templateInstance = new Xml???TemplateEngine(); - - // Init template instannce - $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return false; - } // END - if - - // Assign data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('!!!'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function get???CacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the ||| - * - * @return void - */ - protected function start??? () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('!!!', '|||'); - } - - /** - * Finishes the ||| - * - * @return void - */ - protected function finish??? () { - // Pop the last entry - $this->getStackInstance()->popNamed('!!!'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/class_BaseXmlTemplateEngine.php b/application/hub/main/template/class_BaseXmlTemplateEngine.php deleted file mode 100644 index 6fca12e7c..000000000 --- a/application/hub/main/template/class_BaseXmlTemplateEngine.php +++ /dev/null @@ -1,326 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseXmlTemplateEngine extends BaseTemplateEngine { - /** - * Main nodes in the XML tree - */ - private $mainNodes = array(); - - /** - * Sub nodes in the XML tree - */ - private $subNodes = array(); - - /** - * Current main node - */ - private $curr = array(); - - /** - * XML template type - */ - private $xmlTemplateType = 'xml'; - - /** - * Type prefix - */ - private $typePrefix = 'xml'; - - /** - * Name of stacker - */ - private $stackerName = ''; - - /** - * Content from dependency - */ - protected $dependencyContent = array(); - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Does a generic initialization of the template engine - * - * @param $typePrefix Type prefix - * @param $xmlTemplateType Type of XML template - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - protected function initXmlTemplateEngine ($typePrefix, $xmlTemplateType) { - // Get template instance - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Determine base path - $templateBasePath = $this->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($this, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($this, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($this, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($this, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $this->setTemplateBasePath($templateBasePath); - - // Set template extensions - $this->setRawTemplateExtension($this->getConfigInstance()->getConfigEntry('raw_template_extension')); - $this->setCodeTemplateExtension($this->getConfigInstance()->getConfigEntry($typePrefix . '_message_template_extension')); - - // Absolute output path for compiled templates - $this->setCompileOutputPath($this->getConfigInstance()->getConfigEntry('base_path') . $this->getConfigInstance()->getConfigEntry('compile_output_path')); - - // Init a variable stacker - $stackInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class'); - - // Set name - $this->stackerName = $typePrefix . '_' . $xmlTemplateType; - - // Init stacker - $stackInstance->initStack($this->stackerName); - - // Set it - $this->setStackInstance($stackInstance); - - // Set XML template type and prefix - $this->xmlTemplateType = $xmlTemplateType; - $this->typePrefix = $typePrefix; - - // Set it in main nodes - array_push($this->mainNodes, str_replace('_', '-', $xmlTemplateType)); - } - - /** - * Load a specified XML template into the engine - * - * @param $templateName Optional name of template - * @return void - */ - public function loadXmlTemplate ($templateName = '') { - // Is the template name empty? - if (empty($templateName)) { - // Set generic template name - $templateName = $this->typePrefix . '_' . $this->xmlTemplateType . '_template_type'; - } // END - if - - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry($templateName)); - - // Load the special template - $this->loadTemplate($this->xmlTemplateType); - } - - /** - * Getter for current main node - * - * @return $currMainNode Current main node - */ - public final function getCurrMainNode () { - return $this->curr['main_node']; - } - - /** - * Setter for current main node - * - * @param $element Element name to set as current main node - * @return $currMainNode Current main node - */ - private final function setCurrMainNode ($element) { - $this->curr['main_node'] = (string) $element; - } - - /** - * Getter for main node array - * - * @return $mainNodes Array with valid main node names - */ - public final function getMainNodes () { - return $this->mainNodes; - } - - /** - * Getter for stacker name - * - * @return $stackerName Name of stacker of this class - */ - protected final function getStackerName () { - return $this->stackerName; - } - - /** - * Setter for sub node array - * - * @param $subNodes Array with valid sub node names - * @return void - */ - public final function setSubNodes (array $subNodes) { - $this->subNodes = $subNodes; - } - - /** - * Getter for sub node array - * - * @return $subNodes Array with valid sub node names - */ - public final function getSubNodes () { - return $this->subNodes; - } - - /** - * Read XML variables by calling readVariable() with 'general' as - * variable stack. - * - * @param $key Key to read from - * @return $value Value from variable - */ - public function readXmlData ($key) { - // Read the variable - $value = parent::readVariable($key, 'general'); - - // Is this null? - if (is_null($value)) { - // Bah, needs fixing. - $this->debugInstance('key=' . $key . ' returns NULL'); - } // END - if - - // Return value - return $value; - } - - /** - * Handles the template dependency for given XML node - * - * @param $node The XML node we should load a dependency template - * @param $templateDependency A template to load to satisfy dependencies - * @return void - */ - protected function handleTemplateDependency ($node, $templateDependency) { - // Check that the XML node is not empty - assert(!empty($node)); - - // Is the template dependency set? - if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { - // Get a temporay template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '_' . self::convertDashesToUnderscores($node) . '_' . $this->xmlTemplateType . '_template_class'); - - // Then load it - $templateInstance->loadXmlTemplate($templateDependency); - - // Parse the XML content - $templateInstance->renderXmlContent(); - - // Save the parsed raw content in our dependency array - $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); - } // END - if - } - - /** - * Handles the start element of an XML resource - * - * @param $resource XML parser resource (currently ignored) - * @param $element The element we shall handle - * @param $attributes All attributes - * @return void - * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found - */ - public final function startElement ($resource, $element, array $attributes) { - // Initial method name which will never be called... - $methodName = 'init' . self::convertToClassName($this->xmlTemplateType); - - // Make the element name lower-case - $element = strtolower($element); - - // Is the element a main node? - //* DEBUG: */ echo "START: >".$element."<
\n"; - if (in_array($element, $this->getMainNodes())) { - // Okay, main node found! - $methodName = 'start' . self::convertToClassName($element); - - // Set it - $this->setCurrMainNode($element); - } elseif (in_array($element, $this->getSubNodes())) { - // Sub node found - $methodName = 'start' . self::convertToClassName($element); - } else { - // Invalid node name found - throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); - } - - // Call method - call_user_func_array(array($this, $methodName), $attributes); - } - - /** - * Ends the main or sub node by sending out the gathered data - * - * @param $resource An XML resource pointer (currently ignored) - * @param $nodeName Name of the node we want to finish - * @return void - * @throws XmlNodeMismatchException If current main node mismatches the closing one - */ - public final function finishElement ($resource, $nodeName) { - // Make all lower-case - $nodeName = strtolower($nodeName); - - // Does this match with current main node? - //* DEBUG: */ echo "END: >".$nodeName."<
\n"; - if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { - // Did not match! - throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); - } // END - if - - // Construct method name - $methodName = 'finish' . self::convertToClassName($nodeName); - - // Call the corresponding method - //* DEBUG: */ echo "call: ".$methodName."
\n"; - call_user_func_array(array($this, $methodName), array()); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/connect/.htaccess b/application/hub/main/template/connect/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/connect/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php deleted file mode 100644 index 543fc7251..000000000 --- a/application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php +++ /dev/null @@ -1,187 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Data nodes - */ - const SELF_CONNECT_DATA_NODE_ID = 'node-id'; - const SELF_CONNECT_DATA_SESSION_ID = 'session-id'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - 'self-connect-data', - self::SELF_CONNECT_DATA_NODE_ID, - self::SELF_CONNECT_DATA_SESSION_ID - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlSelfConnectTemplateEngine () { - // Get a new instance - $templateInstance = new XmlSelfConnectTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'self_connect'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name - */ - parent::assignVariable($this->getStackInstance()->getNamed('node_self_connect'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the self_connect - * - * @return void - */ - protected function startSelfConnect () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect'); - } - - /** - * Starts the self_connect data - * - * @return void - */ - protected function startSelfConnectData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', 'self-connect-data'); - } - - /** - * Starts the node id - * - * @return void - */ - protected function startNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_NODE_ID); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_self_connect', self::SELF_CONNECT_DATA_SESSION_ID); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } - - /** - * Finishes the node id - * - * @return void - */ - protected function finishNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } - - /** - * Finishes the self_connect data - * - * @return void - */ - protected function finishSelfConnectData () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } - - /** - * Finishes the self_connect - * - * @return void - */ - protected function finishSelfConnect () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_self_connect'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/dht/.htaccess b/application/hub/main/template/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php deleted file mode 100644 index c99756b53..000000000 --- a/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php +++ /dev/null @@ -1,274 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data'; - const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id'; - const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; - const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; - const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address'; - const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA, - 'listener', - self::DHT_BOOTSTRAP_DATA_NODE_STATUS, - self::DHT_BOOTSTRAP_DATA_NODE_MODE, - self::DHT_BOOTSTRAP_DATA_SESSION_ID, - self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, - self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlDhtBootstrapTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtBootstrapTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'dht_bootstrap'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('dht_bootstrap'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the dht bootstrap - * - * @return void - */ - protected function startDhtBootstrap () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', 'dht-bootstrap'); - } - - /** - * Starts the dht bootstrap data - * - * @return void - */ - protected function startDhtBootstrapData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener'); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the private ip - * - * @return void - */ - protected function startInternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_SESSION_ID); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the private ip - * - * @return void - */ - protected function finishInternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the dht bootstrap data - * - * @return void - */ - protected function finishDhtBootstrapData () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } - - /** - * Finishes the dht bootstrap - * - * @return void - */ - protected function finishDhtBootstrap () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_bootstrap'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/entries/.htaccess b/application/hub/main/template/entries/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/entries/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/main/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php deleted file mode 100644 index bc95609ec..000000000 --- a/application/hub/main/template/entries/class_XmlRequestNodeListEntryTemplateEngine.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlRequestNodeListEntryTemplateEngine () { - // Get a new instance - $templateInstance = new XmlRequestNodeListEntryTemplateEngine(); - - // Init template instannce - $templateInstance->initXmlTemplateEngine('node', 'request_node_list_entry'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Assign data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_entry'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getRequestNodeListEntryCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the request-node-list-entry - * - * @return void - */ - protected function startRequestNodeListEntry () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list_entry', 'request-node-list-entry'); - } - - /** - * Finishes the request-node-list-entry - * - * @return void - */ - protected function finishRequestNodeListEntry () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list_entry'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/objects/.htaccess b/application/hub/main/template/objects/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/objects/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php deleted file mode 100644 index 2ca364a20..000000000 --- a/application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php +++ /dev/null @@ -1,288 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - // Constants - const OBJECT_TYPE_DATA_NAME = 'object-name'; - const OBJECT_TYPE_DATA_RECIPIENT_LIMITATION = 'object-recipient-limitation'; - const OBJECT_TYPE_DATA_MAX_SPREAD = 'object-max-spread'; - const OBJECT_TYPE_DATA_PROTOCOL = 'object-protocol'; - const OBJECT_TYPE_DATA_RECIPIENT_TYPE = 'object-recipient-type'; - - /** - * Instance for the object registry - */ - private $objectRegistryInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init object type registry instance - $this->objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); - - // Init sub nodes - $this->setSubNodes(array( - 'object-list', - 'object-list-entry', - self::OBJECT_TYPE_DATA_NAME, - self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION, - self::OBJECT_TYPE_DATA_MAX_SPREAD, - self::OBJECT_TYPE_DATA_PROTOCOL, - self::OBJECT_TYPE_DATA_RECIPIENT_TYPE - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlObjectRegistryTemplateEngine () { - // Get a new instance - $templateInstance = new XmlObjectRegistryTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'object_registry'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Get current XML node name as an array index - $nodeName = $this->getStackInstance()->getNamed('node_object_registry'); - - // Is the node name self::OBJECT_TYPE_DATA_NAME? - if ($nodeName == self::OBJECT_TYPE_DATA_NAME) { - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Adding object type ' . $characters . ' to registry.'); - } // END - if - - // Add it to the registry - $this->objectRegistryInstance->addEntry($nodeName, $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getObjectRegistryCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the object-registry - * - * @return void - */ - protected function startObjectRegistry () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', 'object-registry'); - } - - /** - * Starts the object-list - * - * @param $objectCount Count of all objects - * @return void - * @todo Handle $objectCount - */ - protected function startObjectList ($objectCount) { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', 'object-list'); - } - - /** - * Starts the object-list-entry - * - * @return void - */ - protected function startObjectListEntry () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', 'object-list-entry'); - } - - /** - * Starts the object-name - * - * @return void - */ - protected function startObjectName () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_NAME); - } - - /** - * Starts the object-recipient-limitation - * - * @return void - */ - protected function startObjectRecipientLimitation () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION); - } - - /** - * Starts the object-max-spread - * - * @return void - */ - protected function startObjectMaxSpread () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_MAX_SPREAD); - } - - /** - * Starts the object-protocol - * - * @return void - */ - protected function startObjectProtocol () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_PROTOCOL); - } - - /** - * Starts the object-recipient-type - * - * @return void - */ - protected function startObjectRecipientType () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_TYPE); - } - - /** - * Finishes the object-recipient-type - * - * @return void - */ - protected function finishObjectRecipientType () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-protocol - * - * @return void - */ - protected function finishObjectProtocol () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-max-spread - * - * @return void - */ - protected function finishObjectMaxSpread () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-recipient-limitation - * - * @return void - */ - protected function finishObjectRecipientLimitation () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-name - * - * @return void - */ - protected function finishObjectName () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-list-entry - * - * @return void - */ - protected function finishObjectListEntry () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-list - * - * @return void - */ - protected function finishObjectList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } - - /** - * Finishes the object-registry - * - * @return void - */ - protected function finishObjectRegistry () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_object_registry'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/producer/.htaccess b/application/hub/main/template/producer/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/producer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/producer/test_units/.htaccess b/application/hub/main/template/producer/test_units/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/producer/test_units/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php deleted file mode 100644 index 40f19412d..000000000 --- a/application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php +++ /dev/null @@ -1,369 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub nodes - $this->setSubNodes(array( - 'meta-data', - 'global-project-identifier', - 'test-unit-created', - 'cipher', - 'cipher-function', - 'cipher-name', - 'unprocessed-data', - 'encrypted-message', - 'cruncher-key-list', - 'cruncher-key', - 'key-id', - 'key-value' - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlCruncherTestUnitTemplateEngine () { - // Get a new instance - $templateInstance = new XmlCruncherTestUnitTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('cruncher', 'test_unit'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Assign the found characters to variable and use the last entry from - // stack as the name - parent::assignVariable($this->getStackInstance()->getNamed('cruncher_test_unit'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getCruncherTestUnitCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the test-unit - * - * @return void - */ - protected function startTestUnit () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit'); - } - - /** - * Starts the meta-data - * - * @return void - */ - protected function startMetaData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'meta-data'); - } - - /** - * Starts the global-project-identifier - * - * @return void - */ - protected function startGlobalProjectIdentifier () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier'); - } - - /** - * Finishes the global-project-identifier - * - * @return void - */ - protected function finishGlobalProjectIdentifier () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the test-unit-created - * - * @return void - */ - protected function startTestUnitCreated () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'test-unit-created'); - } - - /** - * Finishes the test-unit-created - * - * @return void - */ - protected function finishTestUnitCreated () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the cipher - * - * @return void - */ - protected function startCipher () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher'); - } - - /** - * Starts the cipher-function - * - * @return void - */ - protected function startCipherFunction () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-function'); - } - - /** - * Finishes the cipher-function - * - * @return void - */ - protected function finishCipherFunction () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the cipher-name - * - * @return void - */ - protected function startCipherName () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-name'); - } - - /** - * Finishes the cipher-name - * - * @return void - */ - protected function finishCipherName () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the cipher - * - * @return void - */ - protected function finishCipher () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the meta-data - * - * @return void - */ - protected function finishMetaData () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the unprocessed-data - * - * @return void - */ - protected function startUnprocessedData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data'); - } - - /** - * Starts the encrypted-message - * - * @return void - */ - protected function startEncryptedMessage () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'encrypted-message'); - } - - /** - * Finishes the encrypted-message - * - * @return void - */ - protected function finishEncryptedMessage () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the cruncher-key-list - * - * @param $keyCount Count of keys in this test unit - * @return void - * @todo Handle $keyCount - */ - protected function startCruncherKeyList ($keyCount) { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list'); - } - - /** - * Starts the cruncher-key - * - * @return void - */ - protected function startCruncherKey () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key'); - } - - /** - * Starts the key-id - * - * @return void - */ - protected function startKeyId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-id'); - } - - /** - * Finishes the key-id - * - * @return void - */ - protected function finishKeyId () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Starts the key-value - * - * @return void - */ - protected function startKeyValue () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-value'); - } - - /** - * Finishes the key-value - * - * @return void - */ - protected function finishKeyValue () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the cruncher-key - * - * @return void - */ - protected function finishCruncherKey () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the cruncher-key-list - * - * @return void - */ - protected function finishCruncherKeyList () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the unprocessed-data - * - * @return void - */ - protected function finishUnprocessedData () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } - - /** - * Finishes the test-unit - * - * @return void - */ - protected function finishTestUnit () { - // Pop the last entry - $this->getStackInstance()->popNamed('cruncher_test_unit'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/producer/work_units/.htaccess b/application/hub/main/template/producer/work_units/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/producer/work_units/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/publish/.htaccess b/application/hub/main/template/publish/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/publish/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php deleted file mode 100644 index 167857f0e..000000000 --- a/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php +++ /dev/null @@ -1,358 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const PUBLISH_DATA_NODE_ID = 'node-id'; - const PUBLISH_DATA_SESSION_ID = 'session-id'; - const PUBLISH_DATA_NODE_STATUS = 'node-status'; - const PUBLISH_DATA_NODE_MODE = 'node-mode'; - const PUBLISH_DATA_EXTERNAL_ADDRESS = 'external-address'; - const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; - const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->setSubNodes(array( - 'publish-data', - 'listener', - self::PUBLISH_DATA_NODE_STATUS, - self::PUBLISH_DATA_NODE_MODE, - self::PUBLISH_DATA_PRIVATE_KEY_HASH, - self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES, - self::PUBLISH_DATA_NODE_ID, - self::PUBLISH_DATA_SESSION_ID, - self::PUBLISH_DATA_EXTERNAL_ADDRESS, - 'object-type-list', - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlDhtPublishEntryTemplateEngine () { - // Get a new instance - $templateInstance = new XmlDhtPublishEntryTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'dht_publish'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackInstance()->getNamed('dht_publish'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the publish - * - * @return void - */ - protected function startPublish () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'publish'); - } - - /** - * Starts the publish data - * - * @return void - */ - protected function startPublishData () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'publish-data'); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'listener'); - } - - /** - * Starts accepted object types - * - * @return void - */ - protected function startAcceptedObjectTypes () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES); - } - - /** - * Starts hash from private key - * - * @return void - */ - protected function startPrivateKeyHash () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_PRIVATE_KEY_HASH); - } - - /** - * Starts the node id - * - * @return void - */ - protected function startNodeId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_NODE_ID); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_SESSION_ID); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalAddress () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_ADDRESS); - } - - /** - * Starts the object type list - * - * @return void - */ - protected function startObjectTypeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'object-type-list'); - } - - /** - * Starts the object type - * - * @return void - */ - protected function startObjectType () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('dht_publish', 'object-type'); - } - - /** - * Finishes the object type - * - * @return void - */ - protected function finishObjectType () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the object type list - * - * @return void - */ - protected function finishObjectTypeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node id - * - * @return void - */ - protected function finishNodeId () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalAddress () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes hash from private key - * - * @return void - */ - protected function finishPrivateKeyHash () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes accepted object types - * - * @return void - */ - protected function finishAcceptedObjectTypes () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the publish data - * - * @return void - */ - protected function finishPublishData () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } - - /** - * Finishes the publish - * - * @return void - */ - protected function finishPublish () { - // Pop the last entry - $this->getStackInstance()->popNamed('dht_publish'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/requests/.htaccess b/application/hub/main/template/requests/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/requests/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php deleted file mode 100644 index 23b16636c..000000000 --- a/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - // Constants for array elements - const REQUEST_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; - const REQUEST_DATA_SESSION_ID = 'session-id'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init sub nodes - $this->setSubNodes(array( - self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, - self::REQUEST_DATA_SESSION_ID, - )); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlRequestNodeListTemplateEngine () { - // Get a new instance - $templateInstance = new XmlRequestNodeListTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'request_node_list'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Assign data with matching variable here - parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getRequestNodeListCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the node-request-node-list - * - * @return void - */ - protected function startRequestNodeList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list', 'node-request-node-list'); - } - - /** - * Starts the accepted-object-types - * - * @return void - */ - protected function startAcceptedObjectTypes () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES); - } - - /** - * Starts the session-id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_SESSION_ID); - } - - /** - * Finishes the session-id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list'); - } - - /** - * Finishes the accepted-object-types - * - * @return void - */ - protected function finishAcceptedObjectTypes () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list'); - } - - /** - * Finishes the node-request-node-list - * - * @return void - */ - protected function finishRequestNodeList () { - // Pop the last entry - $this->getStackInstance()->popNamed('node_request_node_list'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/template/work_units/.htaccess b/application/hub/main/template/work_units/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/template/work_units/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tools/.htaccess b/application/hub/main/tools/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tools/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tools/class_HubTools.php b/application/hub/main/tools/class_HubTools.php deleted file mode 100644 index 988fa7a4d..000000000 --- a/application/hub/main/tools/class_HubTools.php +++ /dev/null @@ -1,323 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubTools extends BaseHubSystem { - // Constants for exceptions - const EXCEPTION_SESSION_ID_IS_INVALID = 0x200; - const EXCEPTION_HOSTNAME_NOT_FOUND = 0x201; - - /** - * Cache for session ids - */ - private $sessionIdCache = array(); - - /** - * Length for session id (should be 32+salt_length - */ - private $sessionIdLength = 0; - - /** - * Self instance - */ - private static $selfInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set it here - $this->setDhtInstance($dhtInstance); - - // Init salt length - $this->sessionIdLength = 32 + $this->getConfigInstance()->getConfigEntry('salt_length'); - } - - /** - * Singleton getter for self instance - * - * @retuen $selfInstance An instance of this class - */ - public static final function getSelfInstance () { - // Is the instance set - if (is_null(self::$selfInstance)) { - // Then set it - self::$selfInstance = new HubTools(); - } // END - if - - // Return own instance - return self::$selfInstance; - } - - /** - * Getter for session id length - * - * @return $sessionIdLength Length of session ids - */ - protected final function getSessionIdLength () { - return $this->sessionIdLength; - } - - /** - * Resolves a session id into an instance of a LocateableNode class. The opposite method - * is resolveSessionIdByUniversalNodeLocator() - * - * @param $sessionId A valid session id - * @return $recipientUniversalNodeLocator Recipient as Universal Node Locator - */ - protected function resolveUniversalNodeLocatorBySessionId ($sessionId) { - // Init variable - $recipientUniversalNodeLocator = 'invalid://invalid:invalid'; - - // And ask it for Universal Node Locator by given session id - $recipient = $this->getDhtInstance()->findNodeLocalBySessionId($sessionId); - //* DEBUG-DIE: */ die(__METHOD__ . ': UNFINISHED: recipient[' . gettype($recipient) . ']=' . print_r($recipient, TRUE) . ',sessionId=' . $sessionId . PHP_EOL); - - // Is the recipient valid? - if (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) { - // Then use this - $recipientUniversalNodeLocator = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]; - } else { - // Get the instance, this might throw a NPE - $nodeInstance = NodeObjectFactory::createNodeInstance(); - - // Is the session id the same? - if ($nodeInstance->getSessionId() == $sessionId) { - // Then get an instance of a LocateableNode class from it, assume TCP by default - $recipientUniversalNodeLocator = self::determineOwnExternalAddress() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port'); - } // END - if - } - - // Return result - return $recipientUniversalNodeLocator; - } - - /** - * Resolves a session id into a node id by asking local DHT. - * - * @param $sessionId Session id - * @return $nodeId Node id - */ - public static function resolveNodeIdBySessionId ($sessionId) { - // Get an own instance - $selfInstance = self::getSelfInstance(); - - // And ask it for session id by given Universal Node Locator - $nodeData = $selfInstance->getDhtInstance()->findNodeLocalBySessionId($sessionId); - - // Make sure the node id is there - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE)); - assert(isset($nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID])); - - // Return it - return $nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID]; - } - - /** - * Resolves a Universal Node Locator into a session id. The "opposite" method - * is resolveUniversalNodeLocatorBySessionId(). - * - * @param $unlInstance Universal Node Locator - * @return $sessionId Valid session id - */ - public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $unlInstance) { - // Get an own instance - $selfInstance = self::getSelfInstance(); - - // And ask it for session id by given Universal Node Locator - $recipient = $selfInstance->getDhtInstance()->findNodeByUniversalNodeLocator($unlInstance); - die(__METHOD__.':recipient='.print_r($recipient, TRUE)); - - // Return result - return $sessionId; - } - - /** - * Resolves given session id into an instance of a LocateableNode class, if Universal Node Locator is set, it won't be translated - * - * @param $address Session id or Universal Node Locator - * @return $recipient Recipient as Universal Node Locator - * @throws InvalidSessionIdException If the provided session id is invalid (and no Universal Node Locator) - * @throws NoValidHostnameException If the provided hostname cannot be resolved into an IP address - */ - public static function resolveSessionId ($address) { - // Get an own instance - $selfInstance = self::getSelfInstance(); - - // Default is direct Universal Node Locator - $recipient = $address; - - // Does it match a direct Universal Node Locator? (hint: see www.regexlib.com for the regular expression) - if (preg_match('/([a-z0-9]{3,10})\/\/:([a-z0-9\.]{5,})/', $address)) { - // @TODO ((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])):([0-9]{3,5}) - // Direct Universal Node Locator found - self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Direct Universal Node Locator ' . $address . ' detected.'); - } elseif (isset($selfInstance->sessionIdCache[$address])) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using entry from sessionIdCache[] array.'); - - // Found in cache! - $recipient = $selfInstance->sessionIdCache[$address]; - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: sessionIdCache[' . $address . ']=' . $recipient); - } elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $address)) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using internal session id resolver.'); - - // Resolve session id into an instance of a LocateableNode class - $recipient = $selfInstance->resolveUniversalNodeLocatorBySessionId($address); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Session id ' . $address . ' resolved to ' . $recipient); - } else { - // Invalid session id/UNL - throw new InvalidSessionIdException($address, self::EXCEPTION_SESSION_ID_IS_INVALID); - } - - // Return it - return $recipient; - } - - /** - * Determine UNL or 'external_address' if set - * - * @return $unl The determined external UNL of this node - */ - public static function determineOwnExternalAddress () { - // Is the external_address config entry set? - if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_address') != '') { - // Use it as external address - $unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_address'); - } else { - // Determine own external address by connecting to my (coder) server at 188.138.90.169 - $unl = self::determineExternalUniversalNodeLocator(); - } - - // Return it - return $unl; - } - - /** - * Determine UNL or 'internal_address' if set - * - * @return $unl The determined internal UNL of this node - */ - public static function determineOwnInternalAddress () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Is the internal_address config entry set? - if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('allow_publish_internal_address') == 'N') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...'); - - // Not allowed to publish internal address, so use external - $unl = self::determineOwnExternalAddress(); - } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address') != '') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Getting config entry internal_address ...'); - - // Use it as internal address - $unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address'); - } else { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Calling self::determineInternalUniversalNodeLocator() ...'); - - // Determine own internal address - $unl = self::determineInternalUniversalNodeLocator(); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ' - EXIT!'); - - // Return it - return $unl; - } - - /** - * Determines the UNL (Universal Node Locator) for the internal address - * - * @return $internalUnl Internal UNL - */ - public static function determineInternalUniversalNodeLocator () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Is there cache? (This shortens a lot calls) - if (!isset($GLOBALS[__METHOD__])) { - // Determine UNL based on this node: - // 1) Get discovery class - $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class'); - - // 2) "Determine" it - $GLOBALS[__METHOD__] = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('internal'); - - // Make sure it is valid - // @TODO Find a better validation than empty() - assert(!empty($GLOBALS[__METHOD__])); - } // END - if - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); - return $GLOBALS[__METHOD__]; - } - - /** - * Determines the UNL (Universal Node Locator) for the external address - * - * @return $externalUnl External UNL - */ - public static function determineExternalUniversalNodeLocator () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); - - // Is there cache? (This shortens a lot calls) - if (!isset($GLOBALS[__METHOD__])) { - // Determine UNL based on this node: - // 1) Get discovery class - $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class'); - - // 2) "Determine" it - $GLOBALS[__METHOD__] = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('external'); - - // Make sure it is valid - // @TODO Find a better validation than empty() - assert(!empty($GLOBALS[__METHOD__])); - } // END - if - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); - return $GLOBALS[__METHOD__]; - } -} - -// [EOF] -?> diff --git a/application/hub/main/unl/.htaccess b/application/hub/main/unl/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/unl/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/unl/class_UniversalNodeLocator.php b/application/hub/main/unl/class_UniversalNodeLocator.php deleted file mode 100644 index 5064328fd..000000000 --- a/application/hub/main/unl/class_UniversalNodeLocator.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UniversalNodeLocator extends BaseFrameworkSystem implements LocateableNode { - //------- UNL parts ------- - // Protocol - const UNL_PART_PROTOCOL = 'protocol'; - // Address - const UNL_PART_ADDRESS = 'address'; - // Extra part - const UNL_PART_EXTRA = 'extra'; - // Port (if any) - const UNL_PART_PORT = 'port'; - - /** - * UNL data array - */ - private $unlData = array(); - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional. - * @return $unlInstance An instance of a LocateableNode class - */ - public final static function createUniversalNodeLocator (array $current = array()) { - // Get new instance - $unlInstance = new UniversalNodeLocator(); - - // Init instance - $unlInstance->initUniversalNodeLocator($current); - - // Return the prepared instance - return $unlInstance; - } - - /** - * Initializes the UNL instance by givena array. If an entry is found, it - * will be copied, otherwise the entry is set empty. - * - * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional. - * @return void - */ - private function initUniversalNodeLocator (array $current = array()) { - // Init UNL array - $this->unlData = array(); - - // Copy all found entries - foreach (array( - NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, - NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, - NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, - NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, - NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, - NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) { - // Init entry - $this->unlData[$key] = NULL; - - // Is the key found? - if (isset($current[$key])) { - // The copy the entry - $this->unlData[$key] = $current[$key]; - } // END - if - } // END - foreach - } - - /** - * Getter for UNL data array - * - * @return $unlData An array with UNL data - */ - public final function getUnlData () { - return $this->unlData; - } -} - -// [EOF] -?> diff --git a/application/hub/main/visitor/.htaccess b/application/hub/main/visitor/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/visitor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/visitor/pool/.htaccess b/application/hub/main/visitor/pool/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/visitor/pool/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/visitor/pool/class_ b/application/hub/main/visitor/pool/class_ deleted file mode 100644 index 4f7674896..000000000 --- a/application/hub/main/visitor/pool/class_ +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Visitor extends BaseVisitor implements PoolVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('???'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public final static function create???Visitor () { - // Get new instance - $visitorInstance = new ???Visitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given pool instance - * - * @param $poolInstance A Poolable instance - * @return void - * @todo 0% - */ - public function visitPool (Poolable $poolInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/visitor/pool/handler/.htaccess b/application/hub/main/visitor/pool/handler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/visitor/pool/handler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/visitor/pool/handler/class_Handler b/application/hub/main/visitor/pool/handler/class_Handler deleted file mode 100644 index 56d71dccc..000000000 --- a/application/hub/main/visitor/pool/handler/class_Handler +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Handler???Visitor extends BaseVisitor implements PoolVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('handler'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public final static function createHandler???Visitor () { - // Get new instance - $visitorInstance = new Handler???Visitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given pool instance - * - * @param $poolInstance A Poolable instance - * @return void - * @todo 0% - */ - public function visitPool (Poolable $poolInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/visitor/pool/monitor/.htaccess b/application/hub/main/visitor/pool/monitor/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/visitor/pool/monitor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php b/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php deleted file mode 100644 index 630360f5e..000000000 --- a/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, ListenerVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('monitor'); - } - - /** - * Creates an instance of this class - * - * @param $receiverInstance An instance of a Receivable class - * @return $visitorInstance An instance of a Visitorable class - */ - public final static function createRawDataPoolMonitorVisitor () { - // Get new instance - $visitorInstance = new RawDataPoolMonitorVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given pool instance - * - * @param $poolInstance A Poolable instance - * @return void - */ - public function visitPool (Poolable $poolInstance) { - // A pool doesn't normally have any raw data waiting - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: poolInstance=' . $poolInstance->__toString() . ' - CALLED!'); - } - - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - public function visitListener (Listenable $listenerInstance) { - /* - * The listener itself cannot distinguish between node and client - * traffic. This is why we don't call its monitorIncomingRawData() - * method. - */ - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); - } - - /** - * Visits the given decorator instance - * - * @param $decoratorInstance A decorator instance - * @return void - */ - public function visitDecorator (BaseDecorator $decoratorInstance) { - // Do monitor here - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - CALLED!'); - $decoratorInstance->monitorIncomingRawData(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - FINISH'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/visitor/pool/shutdown/.htaccess b/application/hub/main/visitor/pool/shutdown/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/visitor/pool/shutdown/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/visitor/pool/shutdown/class_Shutdown b/application/hub/main/visitor/pool/shutdown/class_Shutdown deleted file mode 100644 index d85f52e97..000000000 --- a/application/hub/main/visitor/pool/shutdown/class_Shutdown +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub; Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Shutdown???Visitor extends BaseVisitor implements PoolVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('shutdown'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public final static function createShutdown???Visitor () { - // Get new instance - $visitorInstance = new Shutdown???Visitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given pool instance - * - * @param $poolInstance A Poolable instance - * @return void - * @todo 0% - */ - public function visitPool (Poolable $poolInstance) { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php b/application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php deleted file mode 100644 index 758f97b91..000000000 --- a/application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('shutdown'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public static final function createShutdownListenerPoolVisitor () { - // Get new instance - $visitorInstance = new ShutdownListenerPoolVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given pool instance - * - * @param $poolInstance A Poolable instance - * @return void - */ - public function visitPool (Poolable $poolInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $poolInstance->__toString() . ' - CALLED!'); - - // Pre-shutdown the pool - $poolInstance->preShutdown(); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $poolInstance->__toString() . ' - EXIT!'); - } - - /** - * Visits the given decorator instance - * - * @param $decoratorInstance A Listenable decorator instance - * @return void - */ - public function visitDecorator (Listenable $decoratorInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $decoratorInstance->__toString() . ' - CALLED!'); - - // Pre-shutdown the pool - $decoratorInstance->doShutdown(); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $decoratorInstance->__toString() . ' - EXIT!'); - } - - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable class instance - * @return void - */ - public function visitListener (Listenable $listenerInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $listenerInstance->__toString() . ' - CALLED!'); - - // Pre-shutdown the pool - $listenerInstance->doShutdown(); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visit of ' . $listenerInstance->__toString() . ' - EXIT!'); - } -} - -// -?> diff --git a/application/hub/main/visitor/socket/.htaccess b/application/hub/main/visitor/socket/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/visitor/socket/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/visitor/socket/class_HalfShutdownSocketVisitor.php b/application/hub/main/visitor/socket/class_HalfShutdownSocketVisitor.php deleted file mode 100644 index 41f743324..000000000 --- a/application/hub/main/visitor/socket/class_HalfShutdownSocketVisitor.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HalfShutdownSocketVisitor extends BaseVisitor implements Visitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('socket'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public static final function createHalfShutdownSocketVisitor () { - // Get new instance - $visitorInstance = new HalfShutdownSocketVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * "Visit" method to do the actual request. Here we want to shutdown the - * attached socket. - * - * @param $helperInstance An instance of a ConnectionHelper class - * @return void - */ - public function visitConnectionHelper (ConnectionHelper $helperInstance) { - // Do we have reached the retry count? - if (ConnectionStatisticsHelper::isConnectRetryExhausted($helperInstance)) { - // Also visit the network package to clear any out-going packages - NetworkPackageFactory::createNetworkPackageInstance()->accept($this); - - // Still shutdown the visitor (look in visitNetworkPackage() for details) - $helperInstance->doShutdown(); - } else { - // We can still move on and retry the connection attempt - ConnectionStatisticsHelper::increaseConnectRetry($helperInstance); - } - } - - /** - * "Visit" method to do the actual request. This method does remove the last - * failed package from the stack because all retries are fully exhausted - * (see visitConnectionHelper() for the logic). - * - * @param $packageInstance An instance of a Deliverable class - * @return void - */ - public function visitNetworkPackage (Deliverable $packageInstance) { - // Just call it back - $packageInstance->removeFirstFailedPackage(); - } -} - -// [EOF] -?> diff --git a/application/hub/main/visitor/socket/class_ShutdownSocketVisitor.php b/application/hub/main/visitor/socket/class_ShutdownSocketVisitor.php deleted file mode 100644 index 7196f8356..000000000 --- a/application/hub/main/visitor/socket/class_ShutdownSocketVisitor.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ShutdownSocketVisitor extends BaseVisitor implements Visitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('socket'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public static final function createShutdownSocketVisitor () { - // Get new instance - $visitorInstance = new ShutdownSocketVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * "Visit" method to do the actual request. Here we want to shutdown the - * attached socket. - * - * @param $helperInstance An instance of a ConnectionHelper class - * @return void - */ - public function visitConnectionHelper (ConnectionHelper $helperInstance) { - // Do we have reached the retry count? - if (ConnectionStatisticsHelper::isConnectRetryExhausted($helperInstance)) { - // Also visit the network package to clear any out-going packages - NetworkPackageFactory::createNetworkPackageInstance()->accept($this); - - // Shutdown the connection - $helperInstance->doShutdown(); - } else { - // We can still move on and retry the connection attempt - ConnectionStatisticsHelper::increaseConnectRetry($helperInstance); - } - } - - /** - * "Visit" method to do the actual request. Here we want to "partly shutdown" - * the network package instance to clear all stacks. - * - * @param $packageInstance An instance of a Deliverable class - * @return void - */ - public function visitNetworkPackage (Deliverable $packageInstance) { - // Just call it back - $packageInstance->clearAllStacks(); - } - - /** - * "Visit" the assembler instance. This shall clear any pending data - * - * @param $assemblerInstance An instance of a Assembler class - * @return void - */ - public function visitAssembler (Assembler $assemblerInstance) { - // Clear pending data - $assemblerInstance->clearPendingData(); - } -} - -// [EOF] -?> diff --git a/application/hub/templates/de/.htaccess b/application/hub/templates/de/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/de/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/de/code/.htaccess b/application/hub/templates/de/code/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/de/code/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/de/code/footer.ctp b/application/hub/templates/de/code/footer.ctp new file mode 100644 index 000000000..aa82e6817 --- /dev/null +++ b/application/hub/templates/de/code/footer.ctp @@ -0,0 +1,4 @@ + + + + diff --git a/application/hub/templates/de/code/header.ctp b/application/hub/templates/de/code/header.ctp new file mode 100644 index 000000000..6f2518ff5 --- /dev/null +++ b/application/hub/templates/de/code/header.ctp @@ -0,0 +1,21 @@ + + + + + {?app_full_name?} - {?title?} + + + + + + + + + + + + {?header_extras_hook?} + + + +
diff --git a/application/hub/templates/de/code/index.ctp b/application/hub/templates/de/code/index.ctp new file mode 100644 index 000000000..33cf308af --- /dev/null +++ b/application/hub/templates/de/code/index.ctp @@ -0,0 +1,53 @@ +addFormGroup('search', "Durchsuchen Sie das Internet oder nur die lokale Node nach Informationen."); + +// Add form group for search type selection +$helperInstance->addFormSubGroup('search_type', "Wählen Sie hier zwischen lokaler Node oder den vom Crawler eingelesenen Webseiten aus:"); +$helperInstance->addInputRadioField('search_type', 'local', "Lokale Node durchsuchen", TRUE); +$helperInstance->addInputRadioField('search_type', 'crawler', "Vom Crawler eingelesene Seiten"); + +// Add form group for search query +$helperInstance->addFormSubGroup('search_query', "Wonach wollen Sie suchen?"); +$helperInstance->addInputTextField('search_query'); + +// Add form group for buttons +$helperInstance->addFormSubGroup('button', "Suche starten:"); +$helperInstance->addInputResetButton("Nochmal eingeben"); +$helperInstance->addInputSubmitButton("Suchen"); + +// Flush finished form +$helperInstance->flushContent(); + +// [EOC] +?> + +
+ Willkommen zum {?app_full_name?} +
+ +
+ {?hub_news?} +
+ +
+ Willkommen zum Web-Interface von {?app_full_name?}, + kurz "{?app_short_name?}". Hier + können Sie die lokale Node durchsuchen, sowie die aktuelle Node-Liste + (DHT) einsehen und vieles mehr. +
+ + diff --git a/application/hub/templates/de/code/menu_block.ctp b/application/hub/templates/de/code/menu_block.ctp new file mode 100644 index 000000000..454ccf1d2 --- /dev/null +++ b/application/hub/templates/de/code/menu_block.ctp @@ -0,0 +1,11 @@ +
+ {?title_text?} +
+ +
    +{?block_content?} +
+ +
+ {?footer_text?} +
diff --git a/application/hub/templates/de/code/menu_entry.ctp b/application/hub/templates/de/code/menu_entry.ctp new file mode 100644 index 000000000..e30bd8c85 --- /dev/null +++ b/application/hub/templates/de/code/menu_entry.ctp @@ -0,0 +1,3 @@ +
  • + {?anchor_text?} +
  • diff --git a/application/hub/templates/de/code/node_main.ctp b/application/hub/templates/de/code/node_main.ctp new file mode 100644 index 000000000..b33a898e8 --- /dev/null +++ b/application/hub/templates/de/code/node_main.ctp @@ -0,0 +1,25 @@ +{?header?} + +
    +
    + {?hub_header?} +
    + + + +
    + {?language_selector?} +
    + +
    + {?main_content?} +
    + + +
    + +{?footer?} diff --git a/application/hub/templates/de/menu/.htaccess b/application/hub/templates/de/menu/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/de/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/de/menu/generic_menu_entries.xml b/application/hub/templates/de/menu/generic_menu_entries.xml new file mode 100644 index 000000000..43b4a6dc4 --- /dev/null +++ b/application/hub/templates/de/menu/generic_menu_entries.xml @@ -0,0 +1,54 @@ + + + + + + + + <title-id><![CDATA[index_menu_title]]></title-id> + <title-class><![CDATA[menu_title]]></title-class> + <title-text><![CDATA[Home:]]></title-text> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/README b/docs/README index 33a874b5e..1c27ada58 100644 --- a/docs/README +++ b/docs/README @@ -83,6 +83,16 @@ environment?) to find hash blocks: php index.php app=hub command=miner +The miner now relies on ext-scrypt. I used latest GIT/master here for developing +this software so you may have to do the same. I used it directly from GIT: + +$ git clone https://github.com/DomBlack/php-scrypt.git + +Follow their build instructions (mostly involves a "configure", "make" and "make +install"). Please also note that I cannot give support on 3rd-party programs or +libraries like this one. You may wish to build this PHP extension outside *this* +path, not to mix them both up. + -------------------------------------------------------------------------------- 6.) How to start the crawler -------------------------------------------------------------------------------- @@ -124,3 +134,18 @@ and deb-src lines: deb [arch=amd64,i386] http://localhost:xxxxx/ftp.de.debian.org/debian unstable main non-free contrib deb-src [arch=amd64,i386] http://localhost:xxxxx/ftp.de.debian.org/debian unstable main non-free contrib + +-------------------------------------------------------------------------------- +9.) How to start the virtual file system and use it +-------------------------------------------------------------------------------- + +The FUSE virtual filesystem allows to access your node's properties and (later) +many more through FUSE (Filesystem in User SpacE). You need the PHP extension +'fuse' enabled in your php.ini and please use latest SVN code from +https://svn.php.net/repository/pecl/fuse/trunk as I also use it. If fuse.dll/so +is correctly installed and enabled in php.ini, you can try to start it like this: + +php index.php app=hub command=fuse + +If all went smooth, you can then access the virtual file system through the +mount point 'fuse' in root directory. diff --git a/fuse/README.txt b/fuse/README.txt new file mode 100644 index 000000000..b1e8e7233 --- /dev/null +++ b/fuse/README.txt @@ -0,0 +1,2 @@ +Do not add any files here, they won't be readable in the virtual file system as +this is the mount point for FUSE.