From 8d8cf621bd811811cecd83c65a4ab91f27258e79 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 19 Jan 2018 22:33:40 +0100 Subject: [PATCH] Continued: - ops, wrong bait, wrong fish, inc/ is no more ... - moved/upgraded files from rewrite MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../bootstrap/class_FrameworkBootstrap.php | 2 +- .../classes/class_BaseFrameworkSystem.php | 20 +- .../main/classes/client/http}/.htaccess | 0 .../classes/client/http/class_HttpClient.php | 0 .../classes/commands/class_BaseCommand.php | 2 +- .../html/class_HtmlConfirmCommand.php | 2 +- .../commands/html/class_HtmlHomeCommand.php | 2 +- .../html/class_HtmlLoginAreaCommand.php | 6 +- .../commands/html/class_HtmlLoginCommand.php | 4 +- .../html/class_HtmlLoginFailedCommand.php | 2 +- .../html/class_HtmlLogoutDoneCommand.php | 2 +- .../html/class_HtmlRegisterCommand.php | 4 +- .../html/class_HtmlResendLinkCommand.php | 2 +- .../commands/html/class_HtmlStatusCommand.php | 2 +- .../image/class_ImageCodeCaptchaCommand.php | 2 +- .../controller/class_BaseController.php | 2 +- .../classes/database/migration}/.htaccess | 0 .../main/classes/database/migration/class_ | 0 .../migration/class_BaseDatabaseMigration.php | 0 .../migration/format_upgrade}/.htaccess | 0 .../database/migration/format_upgrade/class_ | 0 .../class_BaseFormatUpgrade.php | 0 .../migration/format_upgrade/lfdb}/.htaccess | 0 ...FileDatabaseFormatVersion01To02Upgrade.php | 0 .../main/classes/factories/client}/.htaccess | 0 .../factories/client/class_ClientFactory.php | 5 +- .../index/class_FileStackIndexFactory.php | 2 +- .../stacks/class_FileStackFactory.php | 2 +- .../xml/class_XmlTemplateEngineFactory.php | 2 +- .../filter/auth/class_UserAuthFilter.php | 4 +- .../filter/news/class_NewsDownloadFilter.php | 2 +- .../payment/class_PaymentDiscoveryFilter.php | 2 +- .../class_UserUnconfirmedVerifierFilter.php | 2 +- .../classes/language/class_LanguageSystem.php | 2 +- .../mailer/debug/class_DebugMailer.php | 2 +- .../main/classes/menu/class_BaseMenu.php | 2 +- .../registry/format_upgrade}/.htaccess | 0 .../format_upgrade/database}/.htaccess | 0 .../registry/format_upgrade/database/class_ | 0 ...LocalFileDatabaseFormatUpgradeRegistry.php | 2 + .../generic/class_GenericRegistry.php | 3 + .../registry/generic/class_Registry.php | 65 -- .../class_BaseControllerResolver.php | 2 +- .../classes/response/class_BaseResponse.php | 6 +- .../response/html/class_HtmlResponse.php | 2 +- .../response/image/class_ImageResponse.php | 2 +- .../console/class_ConsoleTemplateEngine.php | 2 +- .../html/class_HtmlTemplateEngine.php | 2 +- .../image/class_ImageTemplateEngine.php | 2 +- .../mail/class_MailTemplateEngine.php | 2 +- .../menu/class_MenuTemplateEngine.php | 6 +- .../interfaces/database/migration}/.htaccess | 0 .../migration/class_MigrateableDatabase.php | 0 .../migration/format_upgrade/.htaccess | 1 + .../class_UpgradeableDatabaseFormat.php | 0 .../registry/format_upgrade/.htaccess | 1 + .../class_RegisterableFormatUpgrade.php | 6 +- inc/config.php | 471 -------------- inc/config/class_FrameworkConfiguration.php | 412 ------------ inc/database.php | 52 -- inc/database/lib-local.php | 26 - inc/includes.php | 71 --- .../socket/class_SocketContainer.php | 126 ---- inc/main/classes/handler/raw_data/class_ | 71 --- .../raw_data/class_BaseDataHandler.php | 195 ------ .../classes/handler/raw_data/network/class_ | 66 -- .../network/class_BaseRawDataHandler.php | 181 ------ inc/main/classes/listener/class_ | 100 --- .../classes/listener/class_BaseListener.php | 595 ------------------ .../listener/class_BaseListenerDecorator.php | 151 ----- .../socket/class_SocketFileListener.php | 217 ------- .../class_SocketFileListenerDecorator.php | 95 --- inc/main/classes/resolver/class_ | 142 ----- .../visitor/tasks/class_ActiveTaskVisitor.php | 102 --- .../tasks/class_ShutdownTaskVisitor.php | 95 --- .../class_ConfigEntryIsEmptyException.php | 43 -- .../class_SavePathIsEmptyException.php | 43 -- .../class_FileIsEmptyException.php | 37 -- .../class_PathIsEmptyException.php | 43 -- .../class_LanguagePathIsEmptyException.php | 43 -- .../class_InvalidCommandInstanceException.php | 44 -- .../main/class_MissingMethodException.php | 49 -- .../class_NoSocketRegisteredException.php | 42 -- .../socket/class_SocketShutdownException.php | 49 -- .../class_BasePathIsEmptyException.php | 43 -- .../class_InvalidBasePathStringException.php | 44 -- .../protocol/class_HandleableProtocol.php | 56 -- .../interfaces/listener/class_Listenable.php | 83 --- .../socket/class_RegisterableSocket.php | 62 -- .../resolver/state/class_StateResolver.php | 44 -- .../listener/class_ListenerVisitor.php | 33 - .../visitor/pool/class_PoolVisitor.php | 33 - inc/selector.php | 80 --- 93 files changed, 65 insertions(+), 4159 deletions(-) rename {inc/main/classes/database/migration => framework/main/classes/client/http}/.htaccess (100%) rename {inc => framework}/main/classes/client/http/class_HttpClient.php (100%) rename {inc/main/classes/database/migration/format_upgrade => framework/main/classes/database/migration}/.htaccess (100%) rename {inc => framework}/main/classes/database/migration/class_ (100%) rename {inc => framework}/main/classes/database/migration/class_BaseDatabaseMigration.php (100%) rename {inc/main/classes/database/migration/format_upgrade/lfdb => framework/main/classes/database/migration/format_upgrade}/.htaccess (100%) rename {inc => framework}/main/classes/database/migration/format_upgrade/class_ (100%) rename {inc => framework}/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php (100%) rename {inc/main/classes/registry/format_upgrade => framework/main/classes/database/migration/format_upgrade/lfdb}/.htaccess (100%) rename {inc => framework}/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php (100%) rename {inc/main/classes/registry/format_upgrade/database => framework/main/classes/factories/client}/.htaccess (100%) rename {inc => framework}/main/classes/factories/client/class_ClientFactory.php (94%) rename {inc/main/interfaces/database/migration => framework/main/classes/registry/format_upgrade}/.htaccess (100%) rename {inc/main/interfaces/database/migration/format_upgrade => framework/main/classes/registry/format_upgrade/database}/.htaccess (100%) rename {inc => framework}/main/classes/registry/format_upgrade/database/class_ (100%) rename {inc => framework}/main/classes/registry/format_upgrade/database/class_LocalFileDatabaseFormatUpgradeRegistry.php (95%) rename {inc => framework}/main/classes/registry/generic/class_GenericRegistry.php (96%) delete mode 100644 framework/main/classes/registry/generic/class_Registry.php rename {inc/main/interfaces/registry/format_upgrade => framework/main/interfaces/database/migration}/.htaccess (100%) rename {inc => framework}/main/interfaces/database/migration/class_MigrateableDatabase.php (100%) create mode 100644 framework/main/interfaces/database/migration/format_upgrade/.htaccess rename {inc => framework}/main/interfaces/database/migration/format_upgrade/class_UpgradeableDatabaseFormat.php (100%) create mode 100644 framework/main/interfaces/registry/format_upgrade/.htaccess rename {inc => framework}/main/interfaces/registry/format_upgrade/class_RegisterableFormatUpgrade.php (94%) delete mode 100644 inc/config.php delete mode 100644 inc/config/class_FrameworkConfiguration.php delete mode 100644 inc/database.php delete mode 100644 inc/database/lib-local.php delete mode 100644 inc/includes.php delete mode 100644 inc/main/classes/container/socket/class_SocketContainer.php delete mode 100644 inc/main/classes/handler/raw_data/class_ delete mode 100644 inc/main/classes/handler/raw_data/class_BaseDataHandler.php delete mode 100644 inc/main/classes/handler/raw_data/network/class_ delete mode 100644 inc/main/classes/handler/raw_data/network/class_BaseRawDataHandler.php delete mode 100644 inc/main/classes/listener/class_ delete mode 100644 inc/main/classes/listener/class_BaseListener.php delete mode 100644 inc/main/classes/listener/class_BaseListenerDecorator.php delete mode 100644 inc/main/classes/listener/socket/class_SocketFileListener.php delete mode 100644 inc/main/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php delete mode 100644 inc/main/classes/resolver/class_ delete mode 100644 inc/main/classes/visitor/tasks/class_ActiveTaskVisitor.php delete mode 100644 inc/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php delete mode 100644 inc/main/exceptions/config/class_ConfigEntryIsEmptyException.php delete mode 100644 inc/main/exceptions/database/local_file/class_SavePathIsEmptyException.php delete mode 100644 inc/main/exceptions/file_directory/class_FileIsEmptyException.php delete mode 100644 inc/main/exceptions/file_directory/class_PathIsEmptyException.php delete mode 100644 inc/main/exceptions/language/class_LanguagePathIsEmptyException.php delete mode 100644 inc/main/exceptions/main/class_InvalidCommandInstanceException.php delete mode 100644 inc/main/exceptions/main/class_MissingMethodException.php delete mode 100644 inc/main/exceptions/socket/class_NoSocketRegisteredException.php delete mode 100644 inc/main/exceptions/socket/class_SocketShutdownException.php delete mode 100644 inc/main/exceptions/template/class_BasePathIsEmptyException.php delete mode 100644 inc/main/exceptions/template/class_InvalidBasePathStringException.php delete mode 100644 inc/main/interfaces/handler/protocol/class_HandleableProtocol.php delete mode 100644 inc/main/interfaces/listener/class_Listenable.php delete mode 100644 inc/main/interfaces/registry/socket/class_RegisterableSocket.php delete mode 100644 inc/main/interfaces/resolver/state/class_StateResolver.php delete mode 100644 inc/main/interfaces/visitor/listener/class_ListenerVisitor.php delete mode 100644 inc/main/interfaces/visitor/pool/class_PoolVisitor.php delete mode 100644 inc/selector.php diff --git a/framework/bootstrap/class_FrameworkBootstrap.php b/framework/bootstrap/class_FrameworkBootstrap.php index c18593eb..ce3da75f 100644 --- a/framework/bootstrap/class_FrameworkBootstrap.php +++ b/framework/bootstrap/class_FrameworkBootstrap.php @@ -376,7 +376,7 @@ final class FrameworkBootstrap { } // Set it in registry - Registry::getRegistry()->addInstance('app', $applicationInstance); + GenericRegistry::getRegistry()->addInstance('application', $applicationInstance); // Now call all methods in one go foreach (array('setupApplicationData', 'initApplication', 'launchApplication') as $methodName) { diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 0390d528..8ba9d8ce 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -774,7 +774,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public final function setConfigInstance (FrameworkConfiguration $configInstance) { - Registry::getRegistry()->addInstance('config', $configInstance); + GenericRegistry::getRegistry()->addInstance('config', $configInstance); } /** @@ -794,7 +794,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public final function setDebugInstance (DebugMiddleware $debugInstance) { - Registry::getRegistry()->addInstance('debug', $debugInstance); + GenericRegistry::getRegistry()->addInstance('debug', $debugInstance); } /** @@ -817,7 +817,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public final function setWebOutputInstance (OutputStreamer $webInstance) { - Registry::getRegistry()->addInstance('web_output', $webInstance); + GenericRegistry::getRegistry()->addInstance('web_output', $webInstance); } /** @@ -837,7 +837,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public final function setDatabaseInstance (DatabaseConnection $databaseInstance) { - Registry::getRegistry()->addInstance('db_instance', $databaseInstance); + GenericRegistry::getRegistry()->addInstance('db_instance', $databaseInstance); } /** @@ -860,7 +860,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public final function setCompressorChannel (CompressorChannel $compressorInstance) { - Registry::getRegistry()->addInstance('compressor', $compressorInstance); + GenericRegistry::getRegistry()->addInstance('compressor', $compressorInstance); } /** @@ -890,7 +890,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public final function setApplicationInstance (ManageableApplication $applicationInstance) { - Registry::getRegistry()->addInstance('application', $applicationInstance); + GenericRegistry::getRegistry()->addInstance('application', $applicationInstance); } /** @@ -911,7 +911,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @see LanguageSystem */ public final function setLanguageInstance (ManageableLanguage $langInstance) { - Registry::getRegistry()->addInstance('language', $langInstance); + GenericRegistry::getRegistry()->addInstance('language', $langInstance); } /** @@ -1632,7 +1632,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac // Is the application instance set? if (is_null($applicationInstance)) { // Get the current instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Still null? if (is_null($applicationInstance)) { @@ -1792,7 +1792,7 @@ Loaded includes: DebugMiddleware::getSelfInstance()->output(''); // Set it in registry - Registry::getRegistry()->addInstance('debug', $debugInstance); + GenericRegistry::getRegistry()->addInstance('debug', $debugInstance); } else { // Get instance from registry $debugInstance = GenericRegistry::getRegistry()->getDebugInstance(); @@ -3123,7 +3123,7 @@ Loaded includes: */ protected function initWebOutputInstance () { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Init web output instance $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance)); diff --git a/inc/main/classes/database/migration/.htaccess b/framework/main/classes/client/http/.htaccess similarity index 100% rename from inc/main/classes/database/migration/.htaccess rename to framework/main/classes/client/http/.htaccess diff --git a/inc/main/classes/client/http/class_HttpClient.php b/framework/main/classes/client/http/class_HttpClient.php similarity index 100% rename from inc/main/classes/client/http/class_HttpClient.php rename to framework/main/classes/client/http/class_HttpClient.php diff --git a/framework/main/classes/commands/class_BaseCommand.php b/framework/main/classes/commands/class_BaseCommand.php index 8417f019..12ae3690 100644 --- a/framework/main/classes/commands/class_BaseCommand.php +++ b/framework/main/classes/commands/class_BaseCommand.php @@ -56,7 +56,7 @@ abstract class BaseCommand extends BaseFrameworkSystem { assert(!$requestInstance->isPostRequestMethod()); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php index cc074a86..e6b3f813 100644 --- a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php +++ b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php @@ -73,7 +73,7 @@ class HtmlConfirmCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/html/class_HtmlHomeCommand.php b/framework/main/classes/commands/html/class_HtmlHomeCommand.php index 7ed5a751..ef2de9af 100644 --- a/framework/main/classes/commands/html/class_HtmlHomeCommand.php +++ b/framework/main/classes/commands/html/class_HtmlHomeCommand.php @@ -71,7 +71,7 @@ class HtmlHomeCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php index dbbd4518..3437798d 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php @@ -98,7 +98,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { } // END - if // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); @@ -197,7 +197,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { } // END - if // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Get a resolver $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName, $applicationInstance); @@ -209,7 +209,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { $actionInstance->addExtraFilters($controllerInstance, $requestInstance); // Remember this action in registry - Registry::getRegistry()->addInstance('action', $actionInstance); + GenericRegistry::getRegistry()->addInstance('action', $actionInstance); } } diff --git a/framework/main/classes/commands/html/class_HtmlLoginCommand.php b/framework/main/classes/commands/html/class_HtmlLoginCommand.php index 4b317f30..4b5f017a 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginCommand.php @@ -71,10 +71,10 @@ class HtmlLoginCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Set request instance as extra instance - Registry::getRegistry()->addInstance('extra', $this); + GenericRegistry::getRegistry()->addInstance('extra', $this); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php b/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php index 47e2c725..3b19b20e 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php @@ -71,7 +71,7 @@ class HtmlLoginFailedCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php b/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php index 120229f6..0ed61017 100644 --- a/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php @@ -71,7 +71,7 @@ class HtmlLogoutDoneCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/html/class_HtmlRegisterCommand.php b/framework/main/classes/commands/html/class_HtmlRegisterCommand.php index 5fa9543f..98bd6edc 100644 --- a/framework/main/classes/commands/html/class_HtmlRegisterCommand.php +++ b/framework/main/classes/commands/html/class_HtmlRegisterCommand.php @@ -71,10 +71,10 @@ class HtmlRegisterCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Set request instance as extra instance - Registry::getRegistry()->addInstance('extra', $this); + GenericRegistry::getRegistry()->addInstance('extra', $this); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php index f16c7fbc..d0e558e8 100644 --- a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php +++ b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php @@ -75,7 +75,7 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable { $userInstance = GenericRegistry::getRegistry()->getInstance('user'); // Get an application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Get a RNG instance (Random Number Generator) $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); diff --git a/framework/main/classes/commands/html/class_HtmlStatusCommand.php b/framework/main/classes/commands/html/class_HtmlStatusCommand.php index 08167e29..3bcadda6 100644 --- a/framework/main/classes/commands/html/class_HtmlStatusCommand.php +++ b/framework/main/classes/commands/html/class_HtmlStatusCommand.php @@ -71,7 +71,7 @@ class HtmlStatusCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php b/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php index 34c1d00b..641e46ac 100644 --- a/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php +++ b/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php @@ -73,7 +73,7 @@ class ImageCodeCaptchaCommand extends BaseCommand implements Commandable { $decryptedCode = $requestInstance->getRequestElement('decrypted'); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Prepare a template instance $templateInstance = $this->prepareTemplateInstance($applicationInstance); diff --git a/framework/main/classes/controller/class_BaseController.php b/framework/main/classes/controller/class_BaseController.php index e32b6781..c871c0e3 100644 --- a/framework/main/classes/controller/class_BaseController.php +++ b/framework/main/classes/controller/class_BaseController.php @@ -64,7 +64,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND); // Add this controller to the registry - Registry::getRegistry()->addInstance('controller', $this); + GenericRegistry::getRegistry()->addInstance('controller', $this); } /** diff --git a/inc/main/classes/database/migration/format_upgrade/.htaccess b/framework/main/classes/database/migration/.htaccess similarity index 100% rename from inc/main/classes/database/migration/format_upgrade/.htaccess rename to framework/main/classes/database/migration/.htaccess diff --git a/inc/main/classes/database/migration/class_ b/framework/main/classes/database/migration/class_ similarity index 100% rename from inc/main/classes/database/migration/class_ rename to framework/main/classes/database/migration/class_ diff --git a/inc/main/classes/database/migration/class_BaseDatabaseMigration.php b/framework/main/classes/database/migration/class_BaseDatabaseMigration.php similarity index 100% rename from inc/main/classes/database/migration/class_BaseDatabaseMigration.php rename to framework/main/classes/database/migration/class_BaseDatabaseMigration.php diff --git a/inc/main/classes/database/migration/format_upgrade/lfdb/.htaccess b/framework/main/classes/database/migration/format_upgrade/.htaccess similarity index 100% rename from inc/main/classes/database/migration/format_upgrade/lfdb/.htaccess rename to framework/main/classes/database/migration/format_upgrade/.htaccess diff --git a/inc/main/classes/database/migration/format_upgrade/class_ b/framework/main/classes/database/migration/format_upgrade/class_ similarity index 100% rename from inc/main/classes/database/migration/format_upgrade/class_ rename to framework/main/classes/database/migration/format_upgrade/class_ diff --git a/inc/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php b/framework/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php similarity index 100% rename from inc/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php rename to framework/main/classes/database/migration/format_upgrade/class_BaseFormatUpgrade.php diff --git a/inc/main/classes/registry/format_upgrade/.htaccess b/framework/main/classes/database/migration/format_upgrade/lfdb/.htaccess similarity index 100% rename from inc/main/classes/registry/format_upgrade/.htaccess rename to framework/main/classes/database/migration/format_upgrade/lfdb/.htaccess diff --git a/inc/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php b/framework/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php similarity index 100% rename from inc/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php rename to framework/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php diff --git a/inc/main/classes/registry/format_upgrade/database/.htaccess b/framework/main/classes/factories/client/.htaccess similarity index 100% rename from inc/main/classes/registry/format_upgrade/database/.htaccess rename to framework/main/classes/factories/client/.htaccess diff --git a/inc/main/classes/factories/client/class_ClientFactory.php b/framework/main/classes/factories/client/class_ClientFactory.php similarity index 94% rename from inc/main/classes/factories/client/class_ClientFactory.php rename to framework/main/classes/factories/client/class_ClientFactory.php index 56ad8ab4..f02c06f3 100644 --- a/inc/main/classes/factories/client/class_ClientFactory.php +++ b/framework/main/classes/factories/client/class_ClientFactory.php @@ -1,4 +1,7 @@ addInstance($registryKey, $clientInstance); + GenericRegistry::getRegistry()->addInstance($registryKey, $clientInstance); } // Return the prepared instance diff --git a/framework/main/classes/factories/index/class_FileStackIndexFactory.php b/framework/main/classes/factories/index/class_FileStackIndexFactory.php index b9c7130f..e483fc83 100644 --- a/framework/main/classes/factories/index/class_FileStackIndexFactory.php +++ b/framework/main/classes/factories/index/class_FileStackIndexFactory.php @@ -62,7 +62,7 @@ class FileStackIndexFactory extends ObjectFactory { assert($indexInstance instanceof IndexableStack); // Add it to the registry - Registry::getRegistry()->addInstance($type . '_index', $indexInstance); + GenericRegistry::getRegistry()->addInstance($type . '_index', $indexInstance); } // Return the instance diff --git a/framework/main/classes/factories/stacks/class_FileStackFactory.php b/framework/main/classes/factories/stacks/class_FileStackFactory.php index 5198806b..23e6cab9 100644 --- a/framework/main/classes/factories/stacks/class_FileStackFactory.php +++ b/framework/main/classes/factories/stacks/class_FileStackFactory.php @@ -68,7 +68,7 @@ class FileStackFactory extends ObjectFactory { $stackInstance = self::createObjectByConfiguredName($prefix . '_' . $stackName . '_stack_class', array($fileInfoInstance, $prefix . '_' . $stackName)); // Add it to the registry - Registry::getRegistry()->addInstance($stackName . '_stack', $stackInstance); + GenericRegistry::getRegistry()->addInstance($stackName . '_stack', $stackInstance); } // Return the instance diff --git a/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php b/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php index 7c544b68..86cc114e 100644 --- a/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php +++ b/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php @@ -68,7 +68,7 @@ class XmlTemplateEngineFactory extends ObjectFactory { $templateInstance->enableXmlCompacting(); // Set the instance in registry for further use - Registry::getRegistry()->addInstance($configEntry, $templateInstance); + GenericRegistry::getRegistry()->addInstance($configEntry, $templateInstance); } // Return the instance diff --git a/framework/main/classes/filter/auth/class_UserAuthFilter.php b/framework/main/classes/filter/auth/class_UserAuthFilter.php index bfc185af..bab1a5b1 100644 --- a/framework/main/classes/filter/auth/class_UserAuthFilter.php +++ b/framework/main/classes/filter/auth/class_UserAuthFilter.php @@ -138,8 +138,8 @@ class UserAuthFilter extends BaseFilter implements Filterable { } // END - if // Remember auth and user instances in registry - Registry::getRegistry()->addInstance('auth', $authInstance); - Registry::getRegistry()->addInstance('user', $userInstance); + GenericRegistry::getRegistry()->addInstance('auth', $authInstance); + GenericRegistry::getRegistry()->addInstance('user', $userInstance); } } diff --git a/framework/main/classes/filter/news/class_NewsDownloadFilter.php b/framework/main/classes/filter/news/class_NewsDownloadFilter.php index e9f2f06c..7954643e 100644 --- a/framework/main/classes/filter/news/class_NewsDownloadFilter.php +++ b/framework/main/classes/filter/news/class_NewsDownloadFilter.php @@ -70,7 +70,7 @@ class NewsDownloadFilter extends BaseFilter implements Filterable { $newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance); // Store the news instance in registry - Registry::getRegistry()->addInstance('news', $newsInstance); + GenericRegistry::getRegistry()->addInstance('news', $newsInstance); } } diff --git a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php index 7ba94262..5df7ac34 100644 --- a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php +++ b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php @@ -121,7 +121,7 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable { $discoveryInstance->discover($requestInstance); // Remember this instance if all wents fine - Registry::getRegistry()->addInstance('payments', $discoveryInstance); + GenericRegistry::getRegistry()->addInstance('payments', $discoveryInstance); } catch (NoConfigEntryException $e) { // Something bad happend $requestInstance->requestIsValid(false); diff --git a/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php index 9c4e21b1..4db5a294 100644 --- a/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php @@ -92,7 +92,7 @@ class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable { } // END - if // Add this instance to registry - Registry::getRegistry()->addInstance('user', $userInstance); + GenericRegistry::getRegistry()->addInstance('user', $userInstance); } } diff --git a/framework/main/classes/language/class_LanguageSystem.php b/framework/main/classes/language/class_LanguageSystem.php index 99df4209..6dfbe3bb 100644 --- a/framework/main/classes/language/class_LanguageSystem.php +++ b/framework/main/classes/language/class_LanguageSystem.php @@ -85,7 +85,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, if (empty($languageBasePath)) { // No, then attempt "auto-dection": // 1) Get application - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // 2) Try to build it $languageBasePath = sprintf('%s%s/language/', diff --git a/framework/main/classes/mailer/debug/class_DebugMailer.php b/framework/main/classes/mailer/debug/class_DebugMailer.php index 372aed8e..c9292dda 100644 --- a/framework/main/classes/mailer/debug/class_DebugMailer.php +++ b/framework/main/classes/mailer/debug/class_DebugMailer.php @@ -177,7 +177,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { $templateInstance->assignTemplateWithVariable('footer', 'footer'); // Load the master template - $templateInstance->loadCodeTemplate(Registry::getRegistry()->getInstance('app')->buildMasterTemplateName()); + $templateInstance->loadCodeTemplate(GenericRegistry::getRegistry()->getInstance('application')->buildMasterTemplateName()); // Then compile it again $templateInstance->compileVariables(); diff --git a/framework/main/classes/menu/class_BaseMenu.php b/framework/main/classes/menu/class_BaseMenu.php index 642a01ba..0bc8a836 100644 --- a/framework/main/classes/menu/class_BaseMenu.php +++ b/framework/main/classes/menu/class_BaseMenu.php @@ -66,7 +66,7 @@ abstract class BaseMenu extends BaseFrameworkSystem { // If page is empty, choose default if (empty($command)) { // Use default page as none has been specified - $command = $this->getConfigInstance()->getConfigEntry('default_' . GenericRegistry::getRegistry()->getInstance('app')->getAppShortName() . '_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command'); + $command = $this->getConfigInstance()->getConfigEntry('default_' . GenericRegistry::getRegistry()->getInstance('application')->getAppShortName() . '_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command'); } // END - if // Load the menu template for this page diff --git a/inc/main/interfaces/database/migration/.htaccess b/framework/main/classes/registry/format_upgrade/.htaccess similarity index 100% rename from inc/main/interfaces/database/migration/.htaccess rename to framework/main/classes/registry/format_upgrade/.htaccess diff --git a/inc/main/interfaces/database/migration/format_upgrade/.htaccess b/framework/main/classes/registry/format_upgrade/database/.htaccess similarity index 100% rename from inc/main/interfaces/database/migration/format_upgrade/.htaccess rename to framework/main/classes/registry/format_upgrade/database/.htaccess diff --git a/inc/main/classes/registry/format_upgrade/database/class_ b/framework/main/classes/registry/format_upgrade/database/class_ similarity index 100% rename from inc/main/classes/registry/format_upgrade/database/class_ rename to framework/main/classes/registry/format_upgrade/database/class_ diff --git a/inc/main/classes/registry/format_upgrade/database/class_LocalFileDatabaseFormatUpgradeRegistry.php b/framework/main/classes/registry/format_upgrade/database/class_LocalFileDatabaseFormatUpgradeRegistry.php similarity index 95% rename from inc/main/classes/registry/format_upgrade/database/class_LocalFileDatabaseFormatUpgradeRegistry.php rename to framework/main/classes/registry/format_upgrade/database/class_LocalFileDatabaseFormatUpgradeRegistry.php index 25c7ef29..49aeae05 100644 --- a/inc/main/classes/registry/format_upgrade/database/class_LocalFileDatabaseFormatUpgradeRegistry.php +++ b/framework/main/classes/registry/format_upgrade/database/class_LocalFileDatabaseFormatUpgradeRegistry.php @@ -1,4 +1,6 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Registry 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 getter for self instance. This class has no factory pattern - * because here is no need for special parameters. - * - * @return $registryInstance Instance of this class - */ - public static final function getRegistry () { - // Is an instance there? - if (is_null(self::$registryInstance)) { - // Not yet, so create one - self::$registryInstance = new Registry(); - } // END - if - - // Return the instance - return self::$registryInstance; - } - -} diff --git a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php index ff10fc88..80c81f67 100644 --- a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php +++ b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php @@ -113,7 +113,7 @@ abstract class BaseControllerResolver extends BaseResolver { $resolverConfigEntry, array( $controllerName, - Registry::getRegistry()->getInstance('app') + Registry::getRegistry()->getInstance('application') ) ); $controllerInstance = ObjectFactory::createObjectByName( diff --git a/framework/main/classes/response/class_BaseResponse.php b/framework/main/classes/response/class_BaseResponse.php index 0c2c8a17..625c1d95 100644 --- a/framework/main/classes/response/class_BaseResponse.php +++ b/framework/main/classes/response/class_BaseResponse.php @@ -152,7 +152,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { */ public final function addFatalMessage ($messageId) { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Adds the resolved message id to the fatal message list $this->addFatalMessagePlain($applicationInstance()->getLanguageInstance()->getMessage($messageId)); @@ -180,7 +180,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { */ public function flushBuffer ($force = false) { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Headers already sent? if ((headers_sent()) && ($force === false)) { @@ -243,7 +243,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { */ public function determineDefaultCommand () { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Generate config key $configKey = sprintf('default_%s_%s_command', diff --git a/framework/main/classes/response/html/class_HtmlResponse.php b/framework/main/classes/response/html/class_HtmlResponse.php index bd3f450e..03815a9e 100644 --- a/framework/main/classes/response/html/class_HtmlResponse.php +++ b/framework/main/classes/response/html/class_HtmlResponse.php @@ -131,7 +131,7 @@ class HtmlResponse extends BaseResponse implements Responseable { */ public function redirectToConfiguredUrl ($configEntry) { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Is the header not yet sent? if (headers_sent()) { diff --git a/framework/main/classes/response/image/class_ImageResponse.php b/framework/main/classes/response/image/class_ImageResponse.php index 13101d9e..a2fc7a06 100644 --- a/framework/main/classes/response/image/class_ImageResponse.php +++ b/framework/main/classes/response/image/class_ImageResponse.php @@ -141,7 +141,7 @@ class ImageResponse extends BaseResponse implements Responseable { */ public function redirectToConfiguredUrl ($configEntry) { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Is the header not yet sent? if (headers_sent()) { diff --git a/framework/main/classes/template/console/class_ConsoleTemplateEngine.php b/framework/main/classes/template/console/class_ConsoleTemplateEngine.php index 7ee90554..7288e21c 100644 --- a/framework/main/classes/template/console/class_ConsoleTemplateEngine.php +++ b/framework/main/classes/template/console/class_ConsoleTemplateEngine.php @@ -60,7 +60,7 @@ class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTem $templateInstance = new ConsoleTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Determine base path $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/html/class_HtmlTemplateEngine.php b/framework/main/classes/template/html/class_HtmlTemplateEngine.php index 9d1bb119..0ba6a50b 100644 --- a/framework/main/classes/template/html/class_HtmlTemplateEngine.php +++ b/framework/main/classes/template/html/class_HtmlTemplateEngine.php @@ -60,7 +60,7 @@ class HtmlTemplateEngine extends BaseTemplateEngine implements CompileableTempla $templateInstance = new HtmlTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Determine base path $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/image/class_ImageTemplateEngine.php b/framework/main/classes/template/image/class_ImageTemplateEngine.php index 608038fe..d26074e1 100644 --- a/framework/main/classes/template/image/class_ImageTemplateEngine.php +++ b/framework/main/classes/template/image/class_ImageTemplateEngine.php @@ -97,7 +97,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl $templateInstance = new ImageTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Determine base path $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/mail/class_MailTemplateEngine.php b/framework/main/classes/template/mail/class_MailTemplateEngine.php index 6973d80e..436b39b2 100644 --- a/framework/main/classes/template/mail/class_MailTemplateEngine.php +++ b/framework/main/classes/template/mail/class_MailTemplateEngine.php @@ -90,7 +90,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla $templateInstance = new MailTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Determine base path $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/menu/class_MenuTemplateEngine.php b/framework/main/classes/template/menu/class_MenuTemplateEngine.php index f5cace25..bef97182 100644 --- a/framework/main/classes/template/menu/class_MenuTemplateEngine.php +++ b/framework/main/classes/template/menu/class_MenuTemplateEngine.php @@ -150,7 +150,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla $templateInstance = new MenuTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Determine base path $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; @@ -368,7 +368,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla */ private function initMenu ($templateDependency = '') { // Get web template engine - $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(Registry::getRegistry()->getInstance('app')))); + $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(GenericRegistry::getRegistry()->getInstance('application')))); // Handle the dependency template $this->handleTemplateDependency('menu', $templateDependency); @@ -872,7 +872,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla */ public function getMenuCacheFile () { // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('app'); + $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); // Get the file instance ready $fileInstance = new SplFileInfo(sprintf('%s%smenus/_cache/%s.%s', diff --git a/inc/main/interfaces/registry/format_upgrade/.htaccess b/framework/main/interfaces/database/migration/.htaccess similarity index 100% rename from inc/main/interfaces/registry/format_upgrade/.htaccess rename to framework/main/interfaces/database/migration/.htaccess diff --git a/inc/main/interfaces/database/migration/class_MigrateableDatabase.php b/framework/main/interfaces/database/migration/class_MigrateableDatabase.php similarity index 100% rename from inc/main/interfaces/database/migration/class_MigrateableDatabase.php rename to framework/main/interfaces/database/migration/class_MigrateableDatabase.php diff --git a/framework/main/interfaces/database/migration/format_upgrade/.htaccess b/framework/main/interfaces/database/migration/format_upgrade/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/framework/main/interfaces/database/migration/format_upgrade/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/database/migration/format_upgrade/class_UpgradeableDatabaseFormat.php b/framework/main/interfaces/database/migration/format_upgrade/class_UpgradeableDatabaseFormat.php similarity index 100% rename from inc/main/interfaces/database/migration/format_upgrade/class_UpgradeableDatabaseFormat.php rename to framework/main/interfaces/database/migration/format_upgrade/class_UpgradeableDatabaseFormat.php diff --git a/framework/main/interfaces/registry/format_upgrade/.htaccess b/framework/main/interfaces/registry/format_upgrade/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/framework/main/interfaces/registry/format_upgrade/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/registry/format_upgrade/class_RegisterableFormatUpgrade.php b/framework/main/interfaces/registry/format_upgrade/class_RegisterableFormatUpgrade.php similarity index 94% rename from inc/main/interfaces/registry/format_upgrade/class_RegisterableFormatUpgrade.php rename to framework/main/interfaces/registry/format_upgrade/class_RegisterableFormatUpgrade.php index 7fde65b6..f880985c 100644 --- a/inc/main/interfaces/registry/format_upgrade/class_RegisterableFormatUpgrade.php +++ b/framework/main/interfaces/registry/format_upgrade/class_RegisterableFormatUpgrade.php @@ -1,4 +1,7 @@ diff --git a/inc/config.php b/inc/config.php deleted file mode 100644 index a1ba03c9..00000000 --- a/inc/config.php +++ /dev/null @@ -1,471 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Load very basic classes, required to bootstrap -require(ApplicationEntryPoint::detectCorePath() . '/inc/main/interfaces/class_FrameworkInterface.php'); -require(ApplicationEntryPoint::detectCorePath() . '/inc/main/interfaces/registry/class_Registerable.php'); -require(ApplicationEntryPoint::detectCorePath() . '/inc/config/class_FrameworkConfiguration.php'); - -// Get a new configuration instance -$cfg = FrameworkConfiguration::getSelfInstance(); - -// CFG: SERVER-PATH -$cfg->setConfigEntry('base_path', ApplicationEntryPoint::detectCorePath() . '/'); - -// CFG: BASE-URL -$cfg->setConfigEntry('base_url', $cfg->detectBaseUrl()); - -// CFG: DATABASE-TYPE -$cfg->setConfigEntry('db_type', 'local'); - -// CFG: LOCAL-DB-PATH -$cfg->setConfigEntry('local_db_path', $cfg->getConfigEntry('base_path') . 'db/'); - -// CFG: TIME-ZONE -$cfg->setDefaultTimezone('Europe/Berlin'); - -// CFG: MAGIC-QUOTES-RUNTIME -$cfg->setMagicQuotesRuntime(FALSE); - -// CFG: CLASS-PREFIX -$cfg->setConfigEntry('class_prefix', 'class_'); - -// CFG: CLASS-SUFFIX -$cfg->setConfigEntry('class_suffix', '.php'); - -// CFG: RAW-TEMPLATE-EXTENSION -$cfg->setConfigEntry('raw_template_extension', '.tpl'); - -// CFG: CODE-TEMPLATE-EXTENSION -$cfg->setConfigEntry('code_template_extension', '.ctp'); - -// CFG: SELECTOR-PATH -$cfg->setConfigEntry('selector_path', 'selector'); - -// CFG: APPLICATION-HELPER-CLASS -$cfg->setConfigEntry('app_helper_class', 'ApplicationHelper'); - -// CFG: LAUNCH-METHOD -$cfg->setConfigEntry('entry_method', 'entryPoint'); - -// CFG: TEMPLATE-BASE-PATH -$cfg->setConfigEntry('tpl_base_path', 'templates/'); - -// CFG: LANGUAGE-BASE-PATH -$cfg->setConfigEntry('lang_base_path', 'inc/language/'); - -// CFG: COMPRESSOR-BASE-PATH -$cfg->setConfigEntry('compressor_base_path', 'inc/main/classes/compressor/'); - -// CFG: APPLICATION-BASE-PATH -$cfg->setConfigEntry('application_base_path', 'application/'); - -// CFG: APPLICATION-PATH -$cfg->setConfigEntry('application_path', $cfg->getConfigEntry('base_path') . $cfg->getConfigEntry('application_base_path')); - -// CFG: COMPILE-OUTPUT-PATH -$cfg->setConfigEntry('compile_output_path', 'templates/_compiled/'); - -// CFG: HTML-TEMPLATE-CLASS -$cfg->setConfigEntry('html_template_class', 'HtmlTemplateEngine'); - -// CFG: DECO-XML-REWRITER-TEMPLATE-CLASS -$cfg->setConfigEntry('deco_xml_rewriter_template_class', 'XmlRewriterTemplateDecorator'); - -// CFG: DEBUG-HTML-CLASS -$cfg->setConfigEntry('debug_html_class', 'DebugWebOutput'); - -// CFG: DEBUG-CONSOLE-CLASS -$cfg->setConfigEntry('debug_console_class', 'DebugConsoleOutput'); - -// CFG: DEFAULT-LANGUAGE -$cfg->setConfigEntry('default_lang', 'de'); // A two-char language string: de for german, en for english and so on - -// CFG: HTML-TEMPLATE-TYPE -$cfg->setConfigEntry('html_template_type', 'html'); - -// CFG: EMAIL-TEMPLATE-TYPE -$cfg->setConfigEntry('email_template_type', 'emails'); - -// CFG: CODE-HTML-TEMPLATE-TYPE -$cfg->setConfigEntry('code_html_template_type', 'code'); - -// CFG: CODE-CONSOLE-TEMPLATE-TYPE -$cfg->setConfigEntry('code_console_template_type', 'xml'); - -// CFG: IMAGE-TEMPLATE-TYPE -$cfg->setConfigEntry('image_template_type', 'image'); - -// CFG: MENU-TEMPLATE-TYPE -$cfg->setConfigEntry('menu_template_type', 'menu'); - -// CFG: OUTPUT-CLASS -$cfg->setConfigEntry('output_class', 'WebOutput'); - -// CFG: LANGUAGE-SYSTEM-CLASS -$cfg->setConfigEntry('language_system_class', 'LanguageSystem'); - -// CFG: SELECTOR-TEMPLATE-PREFIX -$cfg->setConfigEntry('tpl_selector_prefix', 'selector'); - -// CFG: WEB-CONTENT-TYPE -$cfg->setConfigEntry('web_content_type', 'text/html'); - -// CFG: VALID-TEMPLATE-VARIABLE -$cfg->setConfigEntry('tpl_valid_var', 'content'); - -// CFG: META-AUTHOR -$cfg->setConfigEntry('meta_author', 'Your-name-here'); - -// CFG: META-PUBLISHER -$cfg->setConfigEntry('meta_publisher', 'Your-name-here'); - -// CFG: META-KEYWORDS -$cfg->setConfigEntry('meta_keywords', 'test,test,test'); - -// CFG: META-DESCRIPTION -$cfg->setConfigEntry('meta_description', 'A description for your website'); - -// CFG: SELECTOR-MAIN-TEMPLATE -$cfg->setConfigEntry('selector_main_tpl', 'selector_main'); - -// CFG: SELECTOR-APPS-TEMPLATE -$cfg->setConfigEntry('selector_apps_tpl', 'selector_apps'); - -// CFG: SELECTOR-NAME -$cfg->setConfigEntry('selector_name', 'selector'); - -// CFG: DEFAULT-APPLICATION -$cfg->setConfigEntry('default_application', 'selector'); - -// CFG: VERBOSE-LEVEL -$cfg->setConfigEntry('verbose_level', 0); - -// CFG: CACHE-CLASS -$cfg->setConfigEntry('cache_class', 'MemoryCache'); - -// CFG: SEARCH-CRITERIA-CLASS -$cfg->setConfigEntry('search_criteria_class', 'SearchCriteria'); - -// CFG: DATASET-CRITERIA-CLASS -$cfg->setConfigEntry('dataset_criteria_class', 'DataSetCriteria'); - -// CFG: UPDATE-CRITERIA-CLASS -$cfg->setConfigEntry('update_criteria_class', 'UpdateCriteria'); - -// CFG: FILE-IO-CLASS -$cfg->setConfigEntry('file_io_class', 'FileIoHandler'); - -// CFG: DATABASE-RESULT-CLASS -$cfg->setConfigEntry('database_result_class', 'CachedDatabaseResult'); - -// CFG: FILTER-CHAIN-CLASS -$cfg->setConfigEntry('filter_chain_class', 'FilterChain'); - -// CFG: FILE-INPUT-CLASS -$cfg->setConfigEntry('file_input_class', 'FileIoStream'); - -// CFG: FILE-OUTPUT-CLASS -$cfg->setConfigEntry('file_output_class', 'FileIoStream'); - -// CFG: EMAIL-VALIDATOR-FILTER -$cfg->setConfigEntry('email_validator_filter', 'EmailValidatorFilter'); - -// CFG: USERNAME-VALIDATOR-FILTER -$cfg->setConfigEntry('username_validator_filter', 'UserNameValidatorFilter'); - -// CFG: USERNAME-IS-GUEST-FILTER -$cfg->setConfigEntry('username_is_guest_filter', 'UserNameIsGuestFilter'); - -// CFG: PASSWORD-VALIDATOR-FILTER -$cfg->setConfigEntry('password_validator_filter', 'PasswordValidatorFilter'); - -// CFG: RULES-ACCEPTED-FILTER -$cfg->setConfigEntry('rules_accepted_filter', 'RulesAcceptedFilter'); - -// CFG: USERNAME-VERIFIER-FILTER -$cfg->setConfigEntry('username_verifier_filter', 'UserNameVerifierFilter'); - -// CFG: USER-GUEST-VERIFIER-FILTER -$cfg->setConfigEntry('user_guest_verifier_filter', 'UserGuestVerifierFilter'); - -// CFG: EMAIL-VERIFIER-FILTER -$cfg->setConfigEntry('email_verifier_filter', 'EmailVerifierFilter'); - -// CFG: PASSWORD-VERIFIER-FILTER -$cfg->setConfigEntry('password_verifier_filter', 'PasswordVerifierFilter'); - -// CFG: PASSWD-GUEST-VERIFIER-FILTER -$cfg->setConfigEntry('passwd_guest_verifier_filter', 'PasswordGuestVerifierFilter'); - -// CFG: EMAIL-CHANGE-FILTER -$cfg->setConfigEntry('email_change_filter', 'EmailChangeFilter'); - -// CFG: PASSWORD-CHANGE-FILTER -$cfg->setConfigEntry('password_change_filter', 'PasswordChangeFilter'); - -// CFG: ACCOUNT-PASSWORD-FILTER -$cfg->setConfigEntry('account_password_filter', 'AccountPasswordVerifierFilter'); - -// CFG: USER-STATUS-FILTER -$cfg->setConfigEntry('user_status_filter', 'UserStatusVerifierFilter'); - -// CFG: USER-UNCONFIRMED-FILTER -$cfg->setConfigEntry('user_unconfirmed_filter', 'UserUnconfirmedVerifierFilter'); - -// CFG: CRYPTO-CLASS -$cfg->setConfigEntry('crypto_class', 'CryptoHelper'); - -// CFG: RNG-CLASS -$cfg->setConfigEntry('rng_class', 'RandomNumberGenerator'); - -// CFG: USER-DB-WRAPPER-CLASS -$cfg->setConfigEntry('user_db_wrapper_class', 'UserDatabaseWrapper'); - -// CFG: NEWS-DB-WRAPPER-CLASS -$cfg->setConfigEntry('news_db_wrapper_class', 'NewsDatabaseWrapper'); - -// CFG: HTML-CMD-RESOLVER-CLASS -$cfg->setConfigEntry('html_cmd_resolver_class', 'HtmlCommandResolver'); - -// CFG: HTML-CMD-LOGIN-RESOLVER-CLASS -$cfg->setConfigEntry('html_cmd_login_resolver_class', 'HtmlCommandResolver'); - -// CFG: IMAGE-CMD-RESOLVER-CLASS -$cfg->setConfigEntry('image_cmd_resolver_class', 'ImageCommandResolver'); - -// CFG: IMAGE-CMD-CODE-CAPTCHA-RESOLVER-CLASS -$cfg->setConfigEntry('image_cmd_code_captcha_resolver_class', 'ImageCommandResolver'); - -// CFG: MAILER-CLASS -$cfg->setConfigEntry('mailer_class', 'DebugMailer'); - -// CFG: XML-PARSER-CLASS -$cfg->setConfigEntry('xml_parser_class', 'XmlParser'); - -// CFG: DECO-COMPACTING-XML-PARSER-CLASS -$cfg->setConfigEntry('deco_compacting_xml_parser_class', 'XmlCompactorDecorator'); - -// CFG: MATH-PRIME -$cfg->setConfigEntry('math_prime', 591623); - -// CFG: DATE-KEY -$cfg->setConfigEntry('date_key', date('d-m-Y (l-F-T)', time())); - -// CFG: SALT-LENGTH -$cfg->setConfigEntry('salt_length', 10); - -// CFG: RND-STR-LENGTH -$cfg->setConfigEntry('rnd_str_length', 128); - -// CFG: HASH-EXTRA-MASK -$cfg->setConfigEntry('hash_extra_mask', "%1s:%2s:%3s"); // 1=salt, 2=extra salt, 3=plain password/string - -// CFG: HASH-NORMAL-MASK -$cfg->setConfigEntry('hash_normal_mask', "%1s:%2s"); // 1=salt, 2=plain password/string - -// CFG: IS-SINGLE-SERVER -$cfg->setConfigEntry('is_single_server', 'Y'); - -// CFG: POST-REGISTRATION-CLASS -$cfg->setConfigEntry('post_registration_class', 'LoginAfterRegistrationAction'); - -// CFG: USER-CLASS -$cfg->setConfigEntry('user_class', 'Member'); - -// CFG: GUEST-CLASS -$cfg->setConfigEntry('guest_class', 'Guest'); - -// CFG: COOKIE-EXPIRE -$cfg->setConfigEntry('cookie_expire', (60*60*2)); // Two hours! - -// CFG: COOKIE-PATH -$cfg->setConfigEntry('cookie_path', $cfg->detectScriptPath() . '/'); - -// CFG: COOKIE-DOMAIN -$cfg->setConfigEntry('cookie_domain', $cfg->detectDomain()); // Is mostly the same... - -// CFG: COOKIE-SSL -$cfg->setConfigEntry('cookie_ssl', $cfg->isHttpSecured()); - -// CFG: CRYPT-FIXED-SALT -$cfg->setConfigEntry('crypt_fixed_salt', 'N'); - -// CFG: DB-UPDATE-PRIMARY-FORCED -$cfg->setConfigEntry('db_update_primary_forced', 'Y'); - -// CFG: GERMAN-DATE-TIME -$cfg->setConfigEntry('german_date_time', "%3\$s.%2\$s.%1\$s, %4\$s:%5\$s:%6\$s"); - -// CFG: PRODUCT-INSTALL-MODE -$cfg->setConfigEntry('product_install_mode', 'debug'); - -// CFG: DECIMALS -$cfg->setConfigEntry('decimals', 3); - -// CFG: MENU-STACKER-CLASS -$cfg->setConfigEntry('menu_stacker_class', 'FiLoStacker'); - -// CFG: STACKER-GENERIC-MAX-SIZE -$cfg->setConfigEntry('stacker_generic_max_size', 100); - -// CFG: STACKER-CURRENT-NODE-MAX-SIZE -$cfg->setConfigEntry('stacker_current_node_max_size', 20); - -// CFG: LOCAL-FILE-DATABASE-CLASS -$cfg->setConfigEntry('local_file_database_class', 'CachedLocalFileDatabase'); - -// CFG: COMPRESSOR-CHANNEL-CLASS -$cfg->setConfigEntry('compressor_channel_class', 'CompressorChannel'); - -// CFG: DEBUG-HTML-OUTPUT-TIMINGS -$cfg->setConfigEntry('debug_html_output_timings', 'N'); - -// CFG: DEBUG-CONSOLE-OUTPUT-TIMINGS -$cfg->setConfigEntry('debug_console_output_timings', 'Y'); - -// CFG: PROXY-HOST -$cfg->setConfigEntry('proxy_host', ''); - -// CFG: PROXY-PORT -$cfg->setConfigEntry('proxy_port', ''); - -// CFG: PROXY-USERNAME -$cfg->setConfigEntry('proxy_username', ''); - -// CFG: PROXY-PASSWORD -$cfg->setConfigEntry('proxy_password', ''); - -// CFG: PROXY-CONNECT-METHOD -$cfg->setConfigEntry('proxy_connect_method', 'Y'); - -// CFG: HOSTNAME-FILE -$cfg->setConfigEntry('hostname_file', '/etc/hostname'); - -// CFG: DATABASE-CACHE-ENABLED -$cfg->setConfigEntry('database_cache_enabled', FALSE); - -// CFG: DIRECTORY-CLASS -$cfg->setConfigEntry('directory_class', 'FrameworkDirectoryPointer'); - -// CFG: FILE-RAW-INPUT-CLASS -$cfg->setConfigEntry('file_raw_input_class', 'FrameworkRawFileInputPointer'); - -// CFG: FILE-RAW-OUTPUT-CLASS -$cfg->setConfigEntry('file_raw_output_class', 'FrameworkRawFileOutputPointer'); - -// CFG: FILE-RAW-INPUT-OUTPUT-CLASS -$cfg->setConfigEntry('file_raw_input_output_class', 'FrameworkFileInputOutputPointer'); - -// CFG: TEXT-FILE-INPUT-CLASS -$cfg->setConfigEntry('text_file_input_class', 'FrameworkTextFileInputPointer'); - -// CFG: CSV-INPUT-FILE-CLASS -$cfg->setConfigEntry('csv_input_file_class', 'CsvInputFile'); - -// CFG: FILE-ITERATOR-CLASS -$cfg->setConfigEntry('file_iterator_class', 'FileIterator'); - -// CFG: FILE-STACK-PRE-ALLOCATE-ENABLED -$cfg->setConfigEntry('file_stack_pre_allocate_enabled', 'Y'); - -// CFG: FILE-STACK-PRE-ALLOCATE-COUNT -$cfg->setConfigEntry('file_stack_pre_allocate_count', 10000); - -// CFG: INDEX-INDEX-CLASS -$cfg->setConfigEntry('file_stack_index_class', 'FileStackIndex'); - -// CFG: INDEX-PRE-ALLOCATE-ENABLED -$cfg->setConfigEntry('index_pre_allocate_enabled', 'Y'); - -// CFG: INDEX-PRE-ALLOCATE-COUNT -$cfg->setConfigEntry('index_pre_allocate_count', 10000); - -// CFG: STACK-FILE-CLASS -$cfg->setConfigEntry('stack_file_class', 'StackFile'); - -// CFG: INDEX-FILE-CLASS -$cfg->setConfigEntry('index_file_class', 'IndexFile'); - -// CFG: TASK-HANDLER-CLASS -$cfg->setConfigEntry('task_handler_class', 'TaskHandler'); - -// CFG: TASK-LIST-CLASS -$cfg->setConfigEntry('task_list_class', 'TaskList'); - -// CFG: LIST-GROUP-CLASS -$cfg->setConfigEntry('list_group_class', 'ListGroupList'); - -// CFG: DEFAULT-ITERATOR-CLASS -$cfg->setConfigEntry('default_iterator_class', 'DefaultIterator'); - -// CFG: ACTIVE-TASK-VISITOR-CLASS -$cfg->setConfigEntry('active_task_visitor_class', 'ActiveTaskVisitor'); - -// CFG: IDLE-TASK-CLASS -$cfg->setConfigEntry('idle_task_class', 'IdleLoopTask'); - -// CFG: TASK-IDLE-LOOP-STARTUP-DELAY -$cfg->setConfigEntry('task_idle_loop_startup_delay', 0); - -// CFG: TASK-IDLE-LOOP-INTERVAL-DELAY -$cfg->setConfigEntry('task_idle_loop_interval_delay', 0); - -// CFG: TASK-IDLE-LOOP-MAX-RUNS -$cfg->setConfigEntry('task_idle_loop_max_runs', 0); - -// CFG: IDLE-LOOP-TIME (5 milli seconds) -$cfg->setConfigEntry('idle_loop_time', 5); - -// CFG: SHUTDOWN-TASK-VISITOR-CLASS -$cfg->setConfigEntry('shutdown_task_visitor_class', 'ShutdownTaskVisitor'); - -// CFG: DEFAULT-IMAGE-COMMAND -$cfg->setConfigEntry('default_image_command', 'build'); - -// CFG: DEFAULT-IMAGE-CONTROLLER -$cfg->setConfigEntry('default_image_controller', 'build'); - -// CFG: MENU-TEMPLATE-CLASS -$cfg->setConfigEntry('menu_template_class', 'MenuTemplateEngine'); - -// CFG: MENU-TEMPLATE-EXTENSION -$cfg->setConfigEntry('menu_template_extension', '.xml'); - -// CFG: FEATURE-FUSE-CLASS -$cfg->setConfigEntry('feature_fuse_class', 'FuseFeature'); - -// CFG: TEMP-FILE-PATH -$cfg->setConfigEntry('temp_file_path', sys_get_temp_dir()); - -// CFG: IPC-SOCKET-FILE-NAME -$cfg->setConfigEntry('ipc_socket_file_name', 'php_ipc_socket'); - -// CFG: EXTENSION-SCRYPT-LOADED (By default scrypt is assumed absent and later tested being there) -$cfg->setConfigEntry('extension_scrypt_loaded', FALSE); - -// CFG: EXTENSION-UUID-LOADED (By default uuid is assumed absent and later tested being there) -$cfg->setConfigEntry('extension_uuid_loaded', FALSE); diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php deleted file mode 100644 index a4181bca..00000000 --- a/inc/config/class_FrameworkConfiguration.php +++ /dev/null @@ -1,412 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkConfiguration implements Registerable { - /** - * The framework's main configuration array which will be initialized with - * hard-coded configuration data and might be overwritten/extended by - * config data from the database. - */ - private $config = array(); - - /** - * The configuration instance itself - */ - private static $configInstance = NULL; - - // Some constants for the configuration system - const EXCEPTION_CONFIG_KEY_IS_EMPTY = 0x130; - const EXCEPTION_CONFIG_KEY_WAS_NOT_FOUND = 0x131; - const EXCEPTION_CONFIG_VALUE_TYPE_UNSUPPORTED = 0x132; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Empty for now - } - - /** - * Compatiblity method to return this class' name - * - * @return __CLASS__ This class' name - */ - public function __toString () { - return get_class($this); - } - - /** - * Getter for a singleton instance of this class - * - * @return $configInstance A singleton instance of this class - */ - public static final function getSelfInstance () { - // is the instance there? - if (is_null(self::$configInstance)) { - // Create a config instance - self::$configInstance = new FrameworkConfiguration(); - } // END - if - - // Return singleton instance - return self::$configInstance; - } - - /** - * Converts dashes to underscores, e.g. useable for configuration entries - * - * @param $str The string with maybe dashes inside - * @return $str The converted string with no dashed, but underscores - */ - private final function convertDashesToUnderscores ($str) { - // Convert them all - $str = str_replace('-', '_', $str); - - // Return converted string - return $str; - } - - /** - * Setter for default time zone (must be correct!) - * - * @param $zone The time-zone string (e.g. Europe/Berlin) - * @return void - */ - public final function setDefaultTimezone ($zone) { - // Is PHP version 5.1.0 or higher? Older versions are being ignored - if (version_compare(phpversion(), '5.1.0', '>=')) { - /* - * Set desired time zone to prevent date() and related functions to - * issue a E_WARNING. - */ - date_default_timezone_set($zone); - } // END - if - } - - /** - * Setter for runtime magic quotes - * - * @param $enableQuotes Whether enable magic runtime quotes (should be disabled for security reasons) - * @return void - * @todo This method encapsulates a deprecated PHP function and should be deprecated, too. - */ - public final function setMagicQuotesRuntime ($enableQuotes) { - // Is the PHP version < 5.4? - if (version_compare(phpversion(), '5.4', '>=')) { - // Then silently skip this part as set_magic_quotes_runtime() is deprecated - return; - } // END - if - - // Cast it to boolean - $enableQuotes = (boolean) $enableQuotes; - - // Set it - set_magic_quotes_runtime($enableQuotes); - } - - /** - * Checks whether the given configuration key is set - * - * @param $configKey The configuration key we shall check - * @return $isset Whether the given configuration key is set - */ - public function isConfigurationEntrySet ($configKey) { - // Is it set? - $isset = isset($this->config[$configKey]); - - // Return the result - return $isset; - } - - /** - * Read a configuration element. - * - * @param $configKey The configuration element - * @return $configValue The fetched configuration value - * @throws ConfigEntryIsEmptyException If $configKey is empty - * @throws NoConfigEntryException If a configuration element was not found - */ - public function getConfigEntry ($configKey) { - // Convert dashes to underscore - $configKey = self::convertDashesToUnderscores($configKey); - - // Is a valid configuration key provided? - if (empty($configKey)) { - // Entry is empty - throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_KEY_IS_EMPTY); - } elseif (!$this->isConfigurationEntrySet($configKey)) { - // Entry was not found! - throw new NoConfigEntryException(array(__CLASS__, $configKey), self::EXCEPTION_CONFIG_KEY_WAS_NOT_FOUND); - } - - // Return the requested value - return $this->config[$configKey]; - } - - /** - * Set a configuration key - * - * @param $configKey The configuration key we want to add/change - * @param $configValue The configuration value we want to set - * @return void - * @throws ConfigEntryIsEmptyException If $configKey is empty - * @throws ConfigValueTypeUnsupportedException If $configValue has an unsupported variable type - */ - public final function setConfigEntry ($configKey, $configValue) { - // Cast to string - $configKey = self::convertDashesToUnderscores($configKey); - - // Is a valid configuration key key provided? - if (is_null($configKey)) { - // Configuration key is null - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif ((empty($configKey)) || (!is_string($configKey))) { - // Entry is empty - throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_KEY_IS_EMPTY); - } elseif ((is_null($configValue)) || (is_array($configValue)) || (is_object($configValue)) || (is_resource($configValue))) { - // These cannot be set as this is not intended for configuration values, please use FrameworkArrayObject instead. - throw new ConfigValueTypeUnsupportedException(array($this, $configKey, $configValue), self::EXCEPTION_CONFIG_VALUE_TYPE_UNSUPPORTED); - } - - // Set the configuration value - //* NOISY-DEBUG: */ print(__METHOD__ . ':configEntry=' . $configKey . ',configValue[' . gettype($configValue) . ']=' . $configValue . PHP_EOL); - $this->config[$configKey] = $configValue; - - // Resort the array - ksort($this->config); - } - - /** - * Unset a configuration key, the entry must be there or else an - * exception is thrown. - * - * @param $configKey Configuration key to unset - * @return void - * @throws NoConfigEntryException If a configuration element was not found - */ - public final function unsetConfigEntry ($configKey) { - // Convert dashes to underscore - $configKey = self::convertDashesToUnderscores($configKey); - - // Is the configuration key there? - if (!$this->isConfigurationEntrySet($configKey)) { - // Entry was not found! - throw new NoConfigEntryException(array(__CLASS__, $configKey), self::EXCEPTION_CONFIG_KEY_WAS_NOT_FOUND); - } // END - if - - // Unset it - unset($this->config[$configKey]); - } - - /** - * Detects the server address (SERVER_ADDR) and set it in configuration - * - * @return $serverAddress The detected server address - * @todo We have to add some more entries from $_SERVER here - */ - public function detectServerAddress () { - // Is the entry set? - if (!$this->isConfigurationEntrySet('server_addr')) { - // Is it set in $_SERVER? - if (isset($_SERVER['SERVER_ADDR'])) { - // Set it from $_SERVER - $this->setServerAddress($_SERVER['SERVER_ADDR']); - } elseif (class_exists('ConsoleTools')) { - // Run auto-detecting through console tools lib - ConsoleTools::acquireSelfIPAddress(); - } - } // END - if - - // Now get it from configuration - $serverAddress = $this->getServerAddress(); - - // Return it - return $serverAddress; - } - - /** - * Setter for SERVER_ADDR - * - * @param $serverAddress New SERVER_ADDR value to set - * @return void - */ - public function setServerAddress ($serverAddress) { - $this->setConfigEntry('server_addr', (string) $serverAddress); - } - - /** - * Getter for SERVER_ADDR - * - * @return $serverAddress New SERVER_ADDR value to set - */ - public function getServerAddress () { - return $this->getConfigEntry('server_addr'); - } - - /** - * Detects the HTTPS flag - * - * @return $https The detected HTTPS flag or null if failed - */ - public function detectHttpSecured () { - // Default is null - $https = NULL; - - // Is HTTPS set? - if ($this->isHttpSecured()) { - // Then use it - $https = $_SERVER['HTTPS']; - } // END - if - - // Return it - return $https; - } - - /** - * Checks whether HTTPS is set in $_SERVER - * - * @return $isset Whether HTTPS is set - */ - public function isHttpSecured () { - return (isset($_SERVER['HTTPS'])); - } - - /** - * Dectect and return the base URL for all URLs and forms - * - * @return $baseUrl Detected base URL - */ - public function detectBaseUrl () { - // Initialize the URL - $baseUrl = 'http'; - - // Do we have HTTPS? - if ($this->isHttpSecured()) { - // Add the >s< for HTTPS - $baseUrl .= 's'; - } // END - if - - // Construct the full URL and secure it against CSRF attacks - $baseUrl = $baseUrl . '://' . $this->detectDomain() . $this->detectScriptPath(); - - // Return the URL - return $baseUrl; - } - - /** - * Detect safely and return the full domain where this script is installed - * - * @return $fullDomain The detected full domain - */ - public function detectDomain () { - // Full domain is localnet.invalid by default - $fullDomain = 'localnet.invalid'; - - // Is the server name there? - if (isset($_SERVER['SERVER_NAME'])) { - // Detect the full domain - $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES); - } // END - if - - // Return it - return $fullDomain; - } - - /** - * Detect safely the script path without trailing slash which is the glue - * between "http://your-domain.invalid/" and "script-name.php" - * - * @return $scriptPath The script path extracted from $_SERVER['SCRIPT_NAME'] - */ - public function detectScriptPath () { - // Default is empty - $scriptPath = ''; - - // Is the scriptname set? - if (isset($_SERVER['SCRIPT_NAME'])) { - // Get dirname from it and replace back-slashes with slashes for lame OSes... - $scriptPath = str_replace("\\", '/', dirname($_SERVER['SCRIPT_NAME'])); - } // END - if - - // Return it - return $scriptPath; - } - - /** - * Getter for field name - * - * @param $fieldName Field name which we shall get - * @return $fieldValue Field value from the user - * @throws NullPointerException If the result instance is null - */ - public final function getField ($fieldName) { - // Our super interface "FrameworkInterface" requires this - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks if given field is set - * - * @param $fieldName Field name to check - * @return $isSet Whether the given field name is set - * @throws NullPointerException If the result instance is null - */ - public function isFieldSet ($fieldName) { - // Our super interface "FrameworkInterface" requires this - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Generates a code for hashes from this class - * - * @return $hashCode The hash code respresenting this class - */ - public function hashCode () { - return crc32($this->__toString()); - } - - /** - * Checks whether an object equals this object. You should overwrite this - * method to implement own equality checks - * - * @param $objectInstance An instance of a FrameworkInterface object - * @return $equals Whether both objects equals - */ - public function equals (FrameworkInterface $objectInstance) { - // Now test it - $equals = (( - $this->__toString() == $objectInstance->__toString() - ) && ( - $this->hashCode() == $objectInstance->hashCode() - )); - - // Return the result - return $equals; - } - -} diff --git a/inc/database.php b/inc/database.php deleted file mode 100644 index 28ad6743..00000000 --- a/inc/database.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @deprecated - * @todo Minimize these includes - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Initialize database layer -$databaseInstance = NULL; - -// Generate FQFN for the database layer -$fqfn = FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path') . 'inc/database/lib-' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('db_type') . '.php'; - -// Load the database layer include -if (BaseFrameworkSystem::isReadableFile($fqfn)) { - // Load the layer - require($fqfn); -} else { - // Layer is missing! - ApplicationEntryPoint::app_exit(sprintf('[Main:] Database layer is missing! (%s) -> R.I.P.', - FrameworkConfiguration::getSelfInstance()->getConfigEntry('db_type') - )); -} - -// Clean it up -unset($fqfn); - -// Prepare database instance -$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance); - -// Is the app variable there and valid? -// @TODO Rewrite this -if (is_object($app)) $app->setDatabaseInstance($connectionInstance); diff --git a/inc/database/lib-local.php b/inc/database/lib-local.php deleted file mode 100644 index 5abbc151..00000000 --- a/inc/database/lib-local.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// For testing purposes we use a local file database -$databaseInstance = ObjectFactory::createObjectByConfiguredName('local_file_database_class'); diff --git a/inc/includes.php b/inc/includes.php deleted file mode 100644 index 2acfa7fb..00000000 --- a/inc/includes.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @deprecated - * @todo Minimize these includes - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Include the class loader function -require(FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path') . 'inc/loader/class_ClassLoader.php'); - -/* - * Shall we include additional configs where you can configure some things? - * Then load matching config file. - */ -ClassLoader::getSelfInstance()->loadExtraConfigs(); - -// Register auto-load function with the SPL -// @TODO This makes the core depending on the SPL. But it should be installed anyway. -spl_autoload_register('ClassLoader::autoLoad'); - -// Does the user has an application specified? -// @TODO Find a nicer OOP-ed way for this -if (!empty($_GET['app'])) { - // Set the application from string - $application = (string) $_GET['app']; -} elseif (!empty($_SERVER['argv'][1])) { - // Set the application from string - $application = (string) $_SERVER['argv'][1]; - $app = explode('=', trim($application)); - if ($app[0] == 'app') { - // Application is valid! - $application = trim($app[1]); - } else { - // Invalid entry found, first must be "app"! - $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_application'); - } -} else { - // Set the "application selector" application - $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_application'); -} - -// Secure it, by keeping out tags -$application = htmlentities(strip_tags($application), ENT_QUOTES); - -// Secure it a little more with a reg.exp. -$application = preg_replace('/([^a-z0-9_-])+/i', '', $application); - -// Set the application name for later usage -FrameworkConfiguration::getSelfInstance()->setConfigEntry('app_name', $application); - -// Scan for all framework classes, exceptions and interfaces -ClassLoader::scanFrameworkClasses(); diff --git a/inc/main/classes/container/socket/class_SocketContainer.php b/inc/main/classes/container/socket/class_SocketContainer.php deleted file mode 100644 index 96811592..00000000 --- a/inc/main/classes/container/socket/class_SocketContainer.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketContainer extends BaseContainer implements Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Container class and prepares it for usage - * - * @param $socketResource A valid socket resource - * @param $infoInstance An instance of a ShareableInfo class - * @param $packageData Raw package data - * @return $containerInstance An instance of this Container class - */ - public static final function createSocketContainer ($socketResource, ShareableInfo $infoInstance = NULL, array $packageData = array()) { - // Get a new instance - $containerInstance = new SocketContainer(); - - // Remove unneeded entries - unset($packageData[NetworkPackage::PACKAGE_DATA_CONTENT]); - unset($packageData[NetworkPackage::PACKAGE_DATA_HASH]); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']:socketResource=' . $socketResource . ',packageData='.print_r($packageData, TRUE)); - - // Is the info instance set? - if ($infoInstance instanceof ShareableInfo) { - // Get listener/helper from info class - $listenerInstance = $infoInstance->getListenerInstance(); - $helperInstance = $infoInstance->getHelperInstance(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: listenerInstance[]=' . gettype($listenerInstance)); - - // Is there a listener instance set? - if ($listenerInstance instanceof Listenable) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...'); - - // Set it here for later usage - $containerInstance->setListenerInstance($listenerInstance); - } elseif ($helperInstance instanceof ConnectionHelper) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: Setting helperInstance=' . $helperInstance->__toString() . ' ...'); - - // Set it here for later usage - $containerInstance->setHelperInstance($helperInstance); - } - } // END - if - - // Set the resource ... - $containerInstance->setSocketResource($socketResource); - - // ... and package data - $containerInstance->setPackageData($packageData); - - // Return the prepared instance - return $containerInstance; - } - - /** - * Checks whether the given Universal Node Locator matches with the one from package data - * - * @param $unl A Universal Node Locator - * @return $matches Whether $address matches with the one from package data - */ - public final function ifAddressMatches ($unl) { - // Get current package data - $packageData = $this->getPackageData(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',packageData=' . print_r($packageData, TRUE)); - - // So, does both match? - $matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $unl)); - - // Return result - return $matches; - } - - /** - * Checks whether the given socket matches with stored - * - * @param $socketResource A valid socket resource - * @return $matches Whether given socket matches - */ - public final function ifSocketResourceMatches ($socketResource) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); - - // So, does both match? - $matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource())); - - // Return result - return $matches; - } - -} diff --git a/inc/main/classes/handler/raw_data/class_ b/inc/main/classes/handler/raw_data/class_ deleted file mode 100644 index 6a0e25f2..00000000 --- a/inc/main/classes/handler/raw_data/class_ +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 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 ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('!!!'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a Networkable class - */ - public final static function create???NetworkPackageHandler () { - // Get new instance - $handlerInstance = new ???NetworkPackageHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Processes a package from given resource. This is mostly useful for TCP - * package handling and is implemented in the TcpListener class - * - * @param $resource A valid resource identifier - * @return void - * @throws InvalidResourceException If the given resource is invalid - * @todo 0% - */ - public function processResourcePackage ($resource) { - // Check the resource - if (!is_resource($resource)) { - // Throw an exception - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } // END - if - - // Implement processing here - $this->partialStub('Please implement this method.'); - } - -} diff --git a/inc/main/classes/handler/raw_data/class_BaseDataHandler.php b/inc/main/classes/handler/raw_data/class_BaseDataHandler.php deleted file mode 100644 index ffe568c6..00000000 --- a/inc/main/classes/handler/raw_data/class_BaseDataHandler.php +++ /dev/null @@ -1,195 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General 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); - -} diff --git a/inc/main/classes/handler/raw_data/network/class_ b/inc/main/classes/handler/raw_data/network/class_ deleted file mode 100644 index d87cd846..00000000 --- a/inc/main/classes/handler/raw_data/network/class_ +++ /dev/null @@ -1,66 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???RawDataHandler 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('|||'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a Networkable class - */ - public static final function create???RawDataHandler () { - // Get new instance - $handlerInstance = new ???RawDataHandler(); - - // 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 ???Listener class - * - * @param $resource A valid socket resource array - * @return void - */ - public function processRawDataFromResource (array $socketArray) { - } - -} diff --git a/inc/main/classes/handler/raw_data/network/class_BaseRawDataHandler.php b/inc/main/classes/handler/raw_data/network/class_BaseRawDataHandler.php deleted file mode 100644 index df084395..00000000 --- a/inc/main/classes/handler/raw_data/network/class_BaseRawDataHandler.php +++ /dev/null @@ -1,181 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public 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_ERROR_PERMISSION_DENIED = 'permission_denied'; // Permission denied - 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; - } - -} diff --git a/inc/main/classes/listener/class_ b/inc/main/classes/listener/class_ deleted file mode 100644 index b5ed6089..00000000 --- a/inc/main/classes/listener/class_ +++ /dev/null @@ -1,100 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 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 ???Listener extends BaseListener implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set the protocol to !!! - $this->setProtocolName('!!!'); - } - - /** - * Creates an instance of this class - * - * @return $listenerInstance An instance a prepared listener class - */ - public final static function create???Listener () { - // Get new instance - $listenerInstance = new ???Listener(); - - // 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.'); - } - - /** - * 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) { - $this->partialStub('Need to implement this method.') { - } - - /** - * Monitors incoming raw data from the handler and transfers it to the - * given receiver instance. - * - * @return void - */ - public function monitorIncomingRawData () { - $this->partialStub('Need to implement this method.') { - } - - /** - * Getter for connection type - * - * @return $connectionType Connection type for this listener - */ - public function getConnectionType () { - $this->partialStub('Need to implement this method.') { - } - -} diff --git a/inc/main/classes/listener/class_BaseListener.php b/inc/main/classes/listener/class_BaseListener.php deleted file mode 100644 index e22ceea1..00000000 --- a/inc/main/classes/listener/class_BaseListener.php +++ /dev/null @@ -1,595 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General 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 BaseListener extends BaseFrameworkSystem implements Visitable { - // Exception code constants - const EXCEPTION_INVALID_SOCKET = 0xa00; - const EXCEPTION_SOCKET_ALREADY_REGISTERED = 0xa01; - const EXCEPTION_SOCKET_CREATION_FAILED = 0xa02; - const EXCEPTION_NO_SOCKET_ERROR = 0xa03; - const EXCEPTION_CONNECTION_ALREADY_REGISTERED = 0xa04; - const EXCEPTION_UNEXPECTED_PACKAGE_STATUS = 0xa05; - const EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER = 0xa06; - const EXCEPTION_FINAL_CHUNK_VERIFICATION = 0xa07; - const EXCEPTION_INVALID_DATA_CHECKSUM = 0xa08; - - /** - * Address (IP mostly) we shall listen on - */ - private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces - - /** - * Port we shall listen on (or wait for incoming data) - */ - private $listenPort = 0; // This port MUST be changed by your application - - /** - * Whether we are in blocking or non-blocking mode (default: non-blocking - */ - private $blockingMode = FALSE; - - /** - * A peer pool instance - */ - private $poolInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Checks whether the given socket resource is a server socket - * - * @param $socketResource A valid socket resource - * @return $isServerSocket Whether the socket resource is a server socket - */ - protected function isServerSocketResource ($socketResource) { - // Check it - $isServerSocket = ((is_resource($socketResource)) && (!@socket_getpeername($socketResource, $peerName))); - - // We need to clear the error here if it is a resource - if ($isServerSocket === TRUE) { - // Clear the error - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[]=' . gettype($socketResource)); - socket_clear_error($socketResource); - } // END - if - - // Check peer name, it must be empty - $isServerSocket = (($isServerSocket) && (empty($peerName))); - - // Return result - return $isServerSocket; - } - - /** - * Setter for listen address - * - * @param $listenAddress The address this listener should listen on - * @return void - */ - protected final function setListenAddress ($listenAddress) { - $this->listenAddress = (string) $listenAddress; - } - - /** - * Getter for listen address - * - * @return $listenAddress The address this listener should listen on - */ - public final function getListenAddress () { - return $this->listenAddress; - } - - /** - * Setter for listen port - * - * @param $listenPort The port this listener should listen on - * @return void - */ - protected final function setListenPort ($listenPort) { - $this->listenPort = (int) $listenPort; - } - - /** - * Getter for listen port - * - * @return $listenPort The port this listener should listen on - */ - public final function getListenPort () { - return $this->listenPort; - } - - /** - * "Setter" to set listen address from configuration entry - * - * @param $configEntry The configuration entry holding our listen address - * @return void - */ - public final function setListenAddressByConfiguration ($configEntry) { - $this->setListenAddress($this->getConfigInstance()->getConfigEntry($configEntry)); - } - - /** - * "Setter" to set listen port from configuration entry - * - * @param $configEntry The configuration entry holding our listen port - * @return void - */ - public final function setListenPortByConfiguration ($configEntry) { - $this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry)); - } - - /** - * Setter for blocking-mode - * - * @param $blockingMode Whether blocking-mode is disabled (default) or enabled - * @return void - */ - protected final function setBlockingMode ($blockingMode) { - $this->blockingMode = (boolean) $blockingMode; - } - - /** - * Checks whether blocking-mode is enabled or disabled - * - * @return $blockingMode Whether blocking mode is disabled or enabled - */ - public final function isBlockingModeEnabled () { - return $this->blockingMode; - } - - /** - * Setter for peer pool instance - * - * @param $poolInstance The peer pool instance we shall set - * @return void - */ - protected final function setPoolInstance (PoolablePeer $poolInstance) { - $this->poolInstance = $poolInstance; - } - - /** - * Getter for peer pool instance - * - * @return $poolInstance The peer pool instance we shall set - */ - public final function getPoolInstance () { - return $this->poolInstance; - } - - /** - * Getter for connection type - * - * @return $connectionType Connection type for this listener - */ - public final function getConnectionType () { - // Wrap the real getter - return $this->getProtocolName(); - } - - /** - * Registeres the given socket resource for "this" listener instance. This - * will be done in a seperate class to allow package writers to use it - * again. - * - * @param $socketResource A valid server socket resource - * @return void - * @throws InvalidServerSocketException If the given resource is no server socket - * @throws SocketAlreadyRegisteredException If the given resource is already registered - */ - protected function registerServerSocketResource ($socketResource) { - // First check if it is valid - if (!$this->isServerSocketResource($socketResource)) { - // No server socket - throw new InvalidServerSocketException(array($this, $socketResource), self::EXCEPTION_INVALID_SOCKET); - } elseif ($this->isServerSocketRegistered($socketResource)) { - // Already registered - throw new SocketAlreadyRegisteredException($this, self::EXCEPTION_SOCKET_ALREADY_REGISTERED); - } - - // Get a socket registry instance (singleton) - $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); - - // Get a connection info instance - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); - - // Will the info instance with listener data - $infoInstance->fillWithListenerInformation($this); - - // Register the socket - $registryInstance->registerSocket($infoInstance, $socketResource); - - // And set it here - $this->setSocketResource($socketResource); - } - - /** - * Checks whether given socket resource is registered in socket registry - * - * @param $socketResource A valid server socket resource - * @return $isRegistered Whether given server socket is registered - */ - protected function isServerSocketRegistered ($socketResource) { - // Get a socket registry instance (singleton) - $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); - - // Get a connection info instance - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); - - // Will the info instance with listener data - $infoInstance->fillWithListenerInformation($this); - - // Check it - $isRegistered = $registryInstance->isSocketRegistered($infoInstance, $socketResource); - - // Return result - return $isRegistered; - } - - /** - * 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 - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!'); - - // Visit this listener - $visitorInstance->visitListener($this); - - // Visit the pool if set - if ($this->getPoolInstance() instanceof Poolable) { - $this->getPoolInstance()->accept($visitorInstance); - } // END - if - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); - } - - /** - * Monitors incoming raw data from the handler and transfers it to the - * given receiver instance. This method should not be called, please call - * the decorator's version instead to separator node/client traffic. - * - * @return void - * @throws UnsupportedOperatorException If this method is called by a mistake - */ - public function monitorIncomingRawData () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * 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), BaseConnectionHelper::EXCEPTION_UNSUPPORTED_ERROR_HANDLER); - } // END - if - - // Return it - return $handlerName; - } - - /** - * 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 13: // "Permission denied" - $errorName = BaseRawDataHandler::SOCKET_ERROR_PERMISSION_DENIED; - 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); - } - - // ************************************************************************ - // Socket error handler call-back methods - // ************************************************************************ - - /** - * Handles socket error 'permission denied', but does not clear it for - * later debugging purposes. - * - * @param $socketResource A valid socket resource - * @param $socketData A valid socket data array (0 = IP/file name, 1 = port) - * @return void - * @throws SocketBindingException The socket could not be bind to - */ - protected function socketErrorPermissionDeniedHandler ($socketResource, array $socketData) { - // 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 SocketBindingException(array($this, $socketData, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET); - } - - /** - * "Listens" for incoming network packages - * - * @param $peerSuffix Suffix for peer name (e.g. :0 for TCP(/UDP?) connections) - * @return void - * @throws InvalidSocketException If an invalid socket resource has been found - */ - protected function doListenSocketSelect ($peerSuffix) { - // Check on all instances - assert($this->getPoolInstance() instanceof Poolable); - assert(is_resource($this->getSocketResource())); - - // 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 . $peerSuffix, - 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(); - } - -} diff --git a/inc/main/classes/listener/class_BaseListenerDecorator.php b/inc/main/classes/listener/class_BaseListenerDecorator.php deleted file mode 100644 index 88734973..00000000 --- a/inc/main/classes/listener/class_BaseListenerDecorator.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General 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 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 the 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(); - - /* - * There is some decoded data waiting. The receiver instance is an - * abstract network package (which can be received and sent out) so - * handle the decoded data over. At this moment it is not needed to - * know if the decoded data origins from a TCP or UDP connection so it - * can just be passed 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); - } - -} diff --git a/inc/main/classes/listener/socket/class_SocketFileListener.php b/inc/main/classes/listener/socket/class_SocketFileListener.php deleted file mode 100644 index 47074410..00000000 --- a/inc/main/classes/listener/socket/class_SocketFileListener.php +++ /dev/null @@ -1,217 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 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 SocketFileListener extends BaseListener implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set the protocol to file - $this->setProtocolName('file'); - } - - /** - * Creates an instance of this class - * - * @return $listenerInstance An instance a prepared listener class - */ - public final static function createSocketFileListener () { - // Get new instance - $listenerInstance = new SocketFileListener(); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - */ - public function initListener() { - // Init socket - $mainSocket = socket_create(AF_UNIX, SOCK_STREAM, 0); - - // 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('null', '0')); - } // END - if - - // Create file name - $socketFile = self::createTempPathForFile($this->getConfigInstance()->getConfigEntry('ipc_socket_file_name')); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FILE-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: socketFile=' . $socketFile . ' ...'); - - // File name must not be empty - assert(!empty($socketFile)); - - // Is the file there? - if ((self::isReachableFilePath($socketFile)) && (file_exists($socketFile))) { - // Old socket found - self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FILE-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: WARNING: Old socket at ' . $socketFile . ' found. Will not start.'); - - // Shutdown this socket - $this->shutdownSocket($mainSocket); - - // Quit here - exit; - } // END - if - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FILE-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Binding to ' . $socketFile . ' ...'); - - // Try to bind to it - if (!socket_bind($mainSocket, $socketFile)) { - // Handle error here - $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array($socketFile, '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('SOCKET-FILE-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($socketFile, '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('SOCKET-FILE-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($socketFile, '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('application_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('socket_listen_iterator_class', array($poolInstance->getPoolEntriesInstance())); - - // Rewind it and remember it in this class - $iteratorInstance->rewind(); - $this->setIteratorInstance($iteratorInstance); - - // Initialize the raw data handler - $handlerInstance = ObjectFactory::createObjectByConfiguredName('socket_raw_data_handler_class'); - - // Set it in this class - $this->setHandlerInstance($handlerInstance); - - // Output message - self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FILE-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Socket listener now ready on socket ' . $socketFile . ' for service.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - */ - public function doListen() { - // Call super method - $this->doListenSocketSelect(''); - } - - /** - * 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) { - $this->partialStub('Need to implement this method.'); - } - - /** - * Monitors incoming raw data from the handler and transfers it to the - * given receiver instance. - * - * @return void - */ - public function monitorIncomingRawData () { - $this->partialStub('Need to implement this method.'); - } - -} diff --git a/inc/main/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php b/inc/main/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php deleted file mode 100644 index 140460eb..00000000 --- a/inc/main/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketFileListenerDecorator 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 createSocketFileListenerDecorator (Listenable $listenerInstance) { - // Get new instance - $decoratorInstance = new SocketFileListenerDecorator(); - - // 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; - } - -} diff --git a/inc/main/classes/resolver/class_ b/inc/main/classes/resolver/class_ deleted file mode 100644 index 763479a3..00000000 --- a/inc/main/classes/resolver/class_ +++ /dev/null @@ -1,142 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 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 ???Resolver extends BaseResolver implements Resolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to '???' - $this->setClassPrefix('???'); - } - - /** - * Creates an instance of a ??? resolver with a given default action - * - * @param $!!!Name The default action we shall execute - * @param $appInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if default action is not set - * @throws Invalid|||Exception Thrown if default action is invalid - */ - public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { - // Create the new instance - $resolverInstance = new ???Resolver(); - - // Is the variable $!!!Name set and the action is valid? - if (empty($!!!Name)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { - // Invalid action found - throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($appInstance); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an action instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $!!!Instance An instance of the resolved action - * @throws Invalid|||Exception Thrown if $!!!Name is - * invalid - * @throws Invalid|||InstanceException Thrown if $!!!Instance - * is an invalid instance - */ - public function resolve|||ByRequest (Requestable $requestInstance) { - // Init variables - $!!!Name = ''; - $!!!Instance = null; - - // This goes fine so let's resolve the action - $!!!Name = $requestInstance->getRequestElement('action'); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // And validate it - if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { - // This action has an invalid instance! - throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Set last action - $this->setResolvedInstance($!!!Instance); - - // Return the resolved action instance - return $!!!Instance; - } - - /** - * Resolves the action by its direct name and returns an instance of its class - * - * @return $!!!Instance An instance of the action class - * @throws Invalid|||Exception Thrown if $!!!Name is invalid - */ - public function resolve||| () { - // Initiate the instance variable - $!!!Instance = null; - - // Get action name - $!!!Name = $this->get|||Name(); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) { - $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // Return the instance - return $!!!Instance; - } - -} diff --git a/inc/main/classes/visitor/tasks/class_ActiveTaskVisitor.php b/inc/main/classes/visitor/tasks/class_ActiveTaskVisitor.php deleted file mode 100644 index b9e7a1ce..00000000 --- a/inc/main/classes/visitor/tasks/class_ActiveTaskVisitor.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('task'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public static final function createActiveTaskVisitor () { - // Get new instance - $visitorInstance = new ActiveTaskVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given task instance - * - * @param $taskInstance A Taskable instance - * @return void - */ - public function visitTask (Taskable $taskInstance) { - // Execute the task from this visitor - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting task ' . $taskInstance->__toString() . ' - CALLED!'); - $taskInstance->executeTask(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting task ' . $taskInstance->__toString() . ' - EXIT!'); - } - - /** - * Pool visitor method for active tasks - * - * @param $poolInstance A Poolable instance - * @return void - */ - public function visitPool (Poolable $poolInstance) { - /** - * We don't need to visit a pool as an active task because a pool can - * never become a task. Instead e.g. by a listener pool we should visit - * all listeners one by one - */ - } - - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - public function visitListener (Listenable $listenerInstance) { - // Do "listen" here - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - CALLED!'); - $listenerInstance->doListen(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - FINISH'); - } - - /** - * Visits the given decorator instance - * - * @param $decoratorInstance A decorator instance - * @return void - */ - public function visitDecorator (BaseDecorator $decoratorInstance) { - // A decorator itself can never become an active task so this method - // remains empty. - } - -} diff --git a/inc/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php b/inc/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php deleted file mode 100644 index 822c6457..00000000 --- a/inc/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ShutdownTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('task'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public static final function createShutdownTaskVisitor () { - // Get new instance - $visitorInstance = new ShutdownTaskVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given task instance - * - * @param $taskInstance A Taskable instance - * @return void - */ - public function visitTask (Taskable $taskInstance) { - // Shutdown the task instance - $taskInstance->doShutdown(); - } - - /** - * Pool visitor method for active tasks - * - * @param $poolInstance A Poolable instance - * @return void - */ - public function visitPool (Poolable $poolInstance) { - // Shutdown the pool instance - $poolInstance->doShutdown(); - } - - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - public function visitListener (Listenable $listenerInstance) { - // Shutdown the listener instance - $listenerInstance->doShutdown(); - } - - /** - * Visits the given decorator instance - * - * @param $decoratorInstance A decorator instance - * @return void - */ - public function visitDecorator (BaseDecorator $decoratorInstance) { - // Shutdown the decorator instance - $decoratorInstance->doShutdown(); - } - -} diff --git a/inc/main/exceptions/config/class_ConfigEntryIsEmptyException.php b/inc/main/exceptions/config/class_ConfigEntryIsEmptyException.php deleted file mode 100644 index e5497822..00000000 --- a/inc/main/exceptions/config/class_ConfigEntryIsEmptyException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConfigEntryIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkConfiguration $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Empty configuration entry provided.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/database/local_file/class_SavePathIsEmptyException.php b/inc/main/exceptions/database/local_file/class_SavePathIsEmptyException.php deleted file mode 100644 index 97b3b287..00000000 --- a/inc/main/exceptions/database/local_file/class_SavePathIsEmptyException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SavePathIsEmptyException extends DatabaseException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Save path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/file_directory/class_FileIsEmptyException.php b/inc/main/exceptions/file_directory/class_FileIsEmptyException.php deleted file mode 100644 index a899278b..00000000 --- a/inc/main/exceptions/file_directory/class_FileIsEmptyException.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $fqfn Ignored - * @param $code Code number for the exception - * @return void - */ - public function __construct ($fqfn, $code) { - // Call parent constructor - parent::__construct('No file name provided.', $code); - } - -} diff --git a/inc/main/exceptions/file_directory/class_PathIsEmptyException.php b/inc/main/exceptions/file_directory/class_PathIsEmptyException.php deleted file mode 100644 index b2e60f75..00000000 --- a/inc/main/exceptions/file_directory/class_PathIsEmptyException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PathIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Directory path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/language/class_LanguagePathIsEmptyException.php b/inc/main/exceptions/language/class_LanguagePathIsEmptyException.php deleted file mode 100644 index 80a96a0d..00000000 --- a/inc/main/exceptions/language/class_LanguagePathIsEmptyException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LanguagePathIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Language base path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/main/class_InvalidCommandInstanceException.php b/inc/main/exceptions/main/class_InvalidCommandInstanceException.php deleted file mode 100644 index 582a9a54..00000000 --- a/inc/main/exceptions/main/class_InvalidCommandInstanceException.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidCommandInstanceException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Invalid command %s detected.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/main/class_MissingMethodException.php b/inc/main/exceptions/main/class_MissingMethodException.php deleted file mode 100644 index c63e6ef7..00000000 --- a/inc/main/exceptions/main/class_MissingMethodException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Try to rewrite user/guest login classes and mark this exception as deprecated - * @deprecated Please do no longer use this exception - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MissingMethodException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding the exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] This class has no method %s().', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/socket/class_NoSocketRegisteredException.php b/inc/main/exceptions/socket/class_NoSocketRegisteredException.php deleted file mode 100644 index 38301345..00000000 --- a/inc/main/exceptions/socket/class_NoSocketRegisteredException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoSocketRegisteredException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $protocolInstance An instance of a HandleableProtocol class - * @param $code Error code - * @return void - */ - public function __construct (HandleableProtocol $protocolInstance, $code) { - // Construct the message - $message = sprintf('[%s:] Requested socket is not yet registered.', - $protocolInstance->__toString() - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/socket/class_SocketShutdownException.php b/inc/main/exceptions/socket/class_SocketShutdownException.php deleted file mode 100644 index a72c88bb..00000000 --- a/inc/main/exceptions/socket/class_SocketShutdownException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketShutdownException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $helperInstance An instance of a ConnectionHelper class - * @param $code Error code - * @return void - */ - public function __construct (ConnectionHelper $helperInstance, $code) { - // Get socket resource - $socketResource = $helperInstance->getSocketResource(); - - // Construct the message - $message = sprintf('[%s:] Socket %s cannot be shutdown down. errNo=%s, errStr=%s', - $helperInstance->__toString(), - $socketResource, - socket_last_error($socketResource), - socket_strerror(socket_last_error($socketResource)) - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/template/class_BasePathIsEmptyException.php b/inc/main/exceptions/template/class_BasePathIsEmptyException.php deleted file mode 100644 index 6ddd8d2e..00000000 --- a/inc/main/exceptions/template/class_BasePathIsEmptyException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BasePathIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Template path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/exceptions/template/class_InvalidBasePathStringException.php b/inc/main/exceptions/template/class_InvalidBasePathStringException.php deleted file mode 100644 index bacbeb57..00000000 --- a/inc/main/exceptions/template/class_InvalidBasePathStringException.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidBasePathStringException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] %s is not a string with a base path.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } - -} diff --git a/inc/main/interfaces/handler/protocol/class_HandleableProtocol.php b/inc/main/interfaces/handler/protocol/class_HandleableProtocol.php deleted file mode 100644 index 866ca600..00000000 --- a/inc/main/interfaces/handler/protocol/class_HandleableProtocol.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface HandleableProtocol extends Handleable { - /** - * Getter for port number to satify HandleableProtocol - * - * @return $port The port number - */ - function getPort (); - - /** - * Getter for protocol name - * - * @return $protocol Name of used protocol - */ - function getProtocolName (); - - /** - * 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 - */ - function isValidUniversalNodeLocatorByPackageData (array $packageData); - - /** - * 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 - */ - function isOwnAddress ($unl); - -} diff --git a/inc/main/interfaces/listener/class_Listenable.php b/inc/main/interfaces/listener/class_Listenable.php deleted file mode 100644 index 450305b1..00000000 --- a/inc/main/interfaces/listener/class_Listenable.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Listenable extends FrameworkInterface { - /** - * Initializes the listener by setting up the required socket server - * - * @return void - */ - function initListener(); - - /** - * "Listens" for incoming network packages - * - * @return void - */ - function doListen(); - - /** - * 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); - - /** - * Monitors incoming raw data from the handler and transfers it to the - * given receiver instance. - * - * @return void - */ - function monitorIncomingRawData (); - - /** - * Getter for listen address - * - * @return $listenAddress The address this listener should listen on - */ - function getListenAddress (); - - /** - * Getter for listen port - * - * @return $listenPort The port this listener should listen on - */ - function getListenPort (); - - /** - * Getter for connection type - * - * @return $connectionType Connection type for this listener - */ - function getConnectionType (); - - /** - * Getter for peer pool instance - * - * @return $poolInstance The peer pool instance we shall set - */ - function getPoolInstance (); - -} diff --git a/inc/main/interfaces/registry/socket/class_RegisterableSocket.php b/inc/main/interfaces/registry/socket/class_RegisterableSocket.php deleted file mode 100644 index ad639187..00000000 --- a/inc/main/interfaces/registry/socket/class_RegisterableSocket.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface RegisterableSocket extends Registerable { - /** - * 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 - */ - function isSocketRegistered (ShareableInfo $infoInstance, $socketResource); - - /** - * 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 - * @return void - * @throws SocketAlreadyRegisteredException If the given socket is already registered - */ - function registerSocket (ShareableInfo $infoInstance, $socketResource); - - /** - * 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 - */ - function getRegisteredSocketResource (Listenable $listenerInstance); - - /** - * "Getter" for info instance from given package data - * - * @param $packageData Raw package data - * @return $infoInstance An instance of a ShareableInfo class - */ - function getInfoInstanceFromPackageData (array $packageData); - -} diff --git a/inc/main/interfaces/resolver/state/class_StateResolver.php b/inc/main/interfaces/resolver/state/class_StateResolver.php deleted file mode 100644 index 56a6220d..00000000 --- a/inc/main/interfaces/resolver/state/class_StateResolver.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface StateResolver extends Resolver { - /** - * Returns an state instance for a given package raw 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 - */ - static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource); - - /** - * 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 - */ - function isStateValid ($stateName); - -} diff --git a/inc/main/interfaces/visitor/listener/class_ListenerVisitor.php b/inc/main/interfaces/visitor/listener/class_ListenerVisitor.php deleted file mode 100644 index 2a05186b..00000000 --- a/inc/main/interfaces/visitor/listener/class_ListenerVisitor.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ListenerVisitor extends Visitor { - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - function visitListener (Listenable $listenerInstance); - -} diff --git a/inc/main/interfaces/visitor/pool/class_PoolVisitor.php b/inc/main/interfaces/visitor/pool/class_PoolVisitor.php deleted file mode 100644 index 426a12b1..00000000 --- a/inc/main/interfaces/visitor/pool/class_PoolVisitor.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface PoolVisitor extends Visitor { - /** - * Visits the given pool instance - * - * @param $poolInstance A Poolable instance - * @return void - */ - function visitPool (Poolable $poolInstance); - -} diff --git a/inc/selector.php b/inc/selector.php deleted file mode 100644 index e736e00c..00000000 --- a/inc/selector.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @deprecated - * @todo Minimize these includes - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Try to load these includes in the given order -$configAppIncludes = array( - 'class_' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), // The ApplicationHelper class - 'debug', // Some debugging stuff - 'exceptions', // The application's own exception handler - 'loader', // The application's class loader - 'config', // The application's own configuration - 'config-local', // Local configuration file (optional) - 'data', // Application data - 'init', // The application initializer - 'starter', // The application starter (calls entryPoint(), etc.) -); - -// Cache base path/file here -$basePathFile = FrameworkConfiguration::getSelfInstance()->getConfigEntry('application_path') . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_name'); - -// Is the directory there? -if (!is_dir($basePathFile)) { - // Not found. - trigger_error('Application ' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_name') . ' not found.'); - exit; -} // END - if - -// Load them all (try only) -foreach ($configAppIncludes as $appInc) { - // Skip starter in test mode - if (($appInc == 'starter') && (defined('TEST'))) { - // Skip it here - continue; - } // END - if - - // Generate a FQFN for the helper class - $appFqFn = $basePathFile . '/' . $appInc . '.php'; - - // Does the include file exists? - if (BaseFrameworkSystem::isReadableFile($appFqFn)) { - // Load it - //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - START\n"; - require($appFqFn); - //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - END\n"; - } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('verbose_level') > 0) { - // File is missing - trigger_error(sprintf('Cannot load application script %s.php! File is missing or read-protected.', - $appInc - )); - exit; - } -} - -// Remove variables from namespace, which we don't need -unset($appInc); -unset($configAppIncludes); -unset($appFqFn); -unset($basePathFile); -- 2.30.2