- ops, wrong bait, wrong fish, inc/ is no more ...
- moved/upgraded files from rewrite
Signed-off-by: Roland Häder <roland@mxchange.org>
}
// 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) {
* @return void
*/
public final function setConfigInstance (FrameworkConfiguration $configInstance) {
- Registry::getRegistry()->addInstance('config', $configInstance);
+ GenericRegistry::getRegistry()->addInstance('config', $configInstance);
}
/**
* @return void
*/
public final function setDebugInstance (DebugMiddleware $debugInstance) {
- Registry::getRegistry()->addInstance('debug', $debugInstance);
+ GenericRegistry::getRegistry()->addInstance('debug', $debugInstance);
}
/**
* @return void
*/
public final function setWebOutputInstance (OutputStreamer $webInstance) {
- Registry::getRegistry()->addInstance('web_output', $webInstance);
+ GenericRegistry::getRegistry()->addInstance('web_output', $webInstance);
}
/**
* @return void
*/
public final function setDatabaseInstance (DatabaseConnection $databaseInstance) {
- Registry::getRegistry()->addInstance('db_instance', $databaseInstance);
+ GenericRegistry::getRegistry()->addInstance('db_instance', $databaseInstance);
}
/**
* @return void
*/
public final function setCompressorChannel (CompressorChannel $compressorInstance) {
- Registry::getRegistry()->addInstance('compressor', $compressorInstance);
+ GenericRegistry::getRegistry()->addInstance('compressor', $compressorInstance);
}
/**
* @return void
*/
public final function setApplicationInstance (ManageableApplication $applicationInstance) {
- Registry::getRegistry()->addInstance('application', $applicationInstance);
+ GenericRegistry::getRegistry()->addInstance('application', $applicationInstance);
}
/**
* @see LanguageSystem
*/
public final function setLanguageInstance (ManageableLanguage $langInstance) {
- Registry::getRegistry()->addInstance('language', $langInstance);
+ GenericRegistry::getRegistry()->addInstance('language', $langInstance);
}
/**
// 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)) {
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();
*/
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));
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A HTTP client class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class HttpClient extends BaseClient implements Client {
+ // Constants
+ const HTTP_EOL = "\r\n";
+ const HTTP_USER_AGENT = 'HttpClient-Core/1.0';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Set default user agent string (to allow other classes to override this)
+ $this->setUserAgent(self::HTTP_USER_AGENT);
+
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this Client class and prepares it for usage
+ *
+ * @param $socketResource Resource of a socket (optional)
+ * @return $clientInstance An instance of a Client class
+ */
+ public final static function createHttpClient ($socketResouce = FALSE) {
+ // Get a new instance
+ $clientInstance = new HttpClient();
+
+ // Set socket resource
+ $clientInstance->setSocketResource($socketResource);
+
+ // Return the prepared instance
+ return $clientInstance;
+ }
+
+ /**
+ * Checks wether proxy configuration is used
+ *
+ * @return $isUsed Wether proxy is used
+ */
+ protected function isProxyUsed () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__METHOD__])) {
+ // Determine it
+ $GLOBALS[__METHOD__] = (($this->getConfigInstance()->getConfigEntry('proxy_host') != '') && ($this->getConfigInstance()->getConfigEntry('proxy_port') > 0));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__METHOD__];
+ }
+
+ /**
+ * Sets up a proxy tunnel for given hostname and through resource
+ *
+ * @param $host Host to connect to
+ * @param $port Port number to connect to
+ * @return $response Response array
+ */
+ protected function setupProxyTunnel ($host, $port) {
+ // Initialize array
+ $response = array('', '', '');
+
+ // Do the connect
+ $respArray = $this->doConnectRequest($host, $port);
+
+ // Analyze first header line
+ if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) {
+ // Response code is not 200
+ return $response;
+ } // END - if
+
+ // All fine!
+ return $respArray;
+ }
+
+ /**
+ * Sends a raw HTTP request out to given IP/host and port number
+ *
+ * @param $method Request method (GET, POST, HEAD, CONNECT, ...)
+ * @param $host Host to connect to
+ * @param $port Port number to connect to
+ * @return $responseArray Array with raw response
+ */
+ private function sendRawHttpRequest ($method, $host, $port, array $header = array()) {
+ // Minimum raw HTTP/1.1 request
+ $rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL;
+ $rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL;
+
+ // Use login data to proxy? (username at least)
+ if ($this->getConfigInstance()->getConfigEntry('proxy_username') != '') {
+ // Add it as well
+ $encodedAuth = base64_encode($this->getConfigInstance()->getConfigEntry('proxy_username') . ':' . $this->getConfigInstance()->getConfigEntry('proxy_password'));
+ $rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL;
+ } // END - if
+
+ // Add last new-line
+ $rawRequest .= self::HTTP_EOL;
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HTTP-CLIENT[' . __METHOD__ . ':' . __LINE__ . ']: rawRequest=' . $rawRequest);
+
+ // Write request
+ fwrite($this->getSocketResource(), $rawRequest);
+
+ // Got response?
+ if (feof($this->getSocketResource())) {
+ // No response received
+ return $response;
+ } // END - if
+
+ // Read the first line
+ $resp = trim(fgets($this->getSocketResource(), 10240));
+
+ // "Explode" the string to an array
+ $responseArray = explode(' ', $resp);
+
+ // And return it
+ return $responseArray;
+ }
+
+ /**
+ * A HTTP/1.1 CONNECT request
+ *
+ * @param $host Host to connect to
+ * @param $port Port number to connect to
+ * @return $responseArray An array with the read response
+ */
+ public function doConnectRequest ($host, $port) {
+ // Prepare extra header(s)
+ $headers = array(
+ 'Proxy-Connection' => 'Keep-Alive'
+ );
+
+ // Prepare raw request
+ $responseArray = $this->sendRawHttpRequest('CONNECT', $host, $port, $headers);
+
+ // Return response array
+ return $responseArray;
+ }
+
+}
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);
*/
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);
*/
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);
} // END - if
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('app');
+ $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
// Prepare a template instance
$templateInstance = $this->prepareTemplateInstance($applicationInstance);
} // END - if
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('app');
+ $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
// Get a resolver
$actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName, $applicationInstance);
$actionInstance->addExtraFilters($controllerInstance, $requestInstance);
// Remember this action in registry
- Registry::getRegistry()->addInstance('action', $actionInstance);
+ GenericRegistry::getRegistry()->addInstance('action', $actionInstance);
}
}
*/
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);
*/
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);
*/
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);
*/
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);
$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');
*/
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);
$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);
$this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND);
// Add this controller to the registry
- Registry::getRegistry()->addInstance('controller', $this);
+ GenericRegistry::getRegistry()->addInstance('controller', $this);
}
/**
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? database migration class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ???DatabaseMigration extends BaseDatabaseMigration implements MigrateableDatabase {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct($class = __CLASS__) {
+ // Call parent constructor
+ parent::__construct($class);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A general database migration class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+abstract class BaseDatabaseMigration extends BaseFrameworkSystem {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct($class = __CLASS__) {
+ // Call parent constructor
+ parent::__construct($class);
+ }
+
+}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? format-upgrade class from format 01 to 02
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ???FormatVersion01To02Upgrade extends BaseFormatUpgrade implements UpgradeableDatabaseFormat {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this UpgradeableDatabaseFormat class and prepares it for usage
+ *
+ * @return $upgradeInstance An instance of this UpgradeableDatabaseFormat class
+ */
+ public final static function create???FormatVersion1To2Upgrade () {
+ // Get a new instance
+ $upgradeInstance = new ???FormatVersion1To2Upgrade();
+
+ // Return the prepared instance
+ return $upgradeInstance;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A general format upgrade class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+abstract class BaseFormatUpgrade extends BaseDatabaseMigration implements MigrateableDatabase {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct($class = __CLASS__) {
+ // Call parent constructor
+ parent::__construct($class);
+ }
+
+}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A format-upgrade class for LocalFileDatabase format version 01 to 02
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class LocalFileDatabaseFormatVersion01To02Upgrade extends BaseFormatUpgrade implements UpgradeableDatabaseFormat {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this UpgradeableDatabaseFormat class and prepares it for usage
+ *
+ * @return $upgradeInstance An instance of this UpgradeableDatabaseFormat class
+ */
+ public final static function createLocalFileDatabaseFormatVersion01To02Upgrade () {
+ // Get a new instance
+ $upgradeInstance = new LocalFileDatabaseFormatVersion01To02Upgrade();
+
+ // Return the prepared instance
+ return $upgradeInstance;
+ }
+
+}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Factory\Client;
+
+/**
+ * An object factory for clients
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ClientFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates a client object for given protocol. This method uses the
+ * registry pattern to cache those instances.
+ *
+ * @param $protocolInstance An instance of a HandleableProtocol class to create a client object for (e.g. 'http' for a HTTP/1.1 client)
+ * @param $socketResource A valid socket resource (optional)
+ * @return $clientInstance An instance of the requested client
+ */
+ public static final function createClientByProtocolInstance (HandleableProtocol $protocolInstance, $socketResource = FALSE) {
+ // Default is NULL (to initialize variable)
+ $clientInstance = NULL;
+
+ // Generate registry key
+ $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client';
+
+ // Is the key already in registry?
+ if (GenericRegistry::getRegistry()->instanceExists($registryKey)) {
+ // Then use that instance
+ $clientInstance = GenericRegistry::getRegistry()->getInstance($registryKey);
+
+ // Set socket resource
+ $clientInstance->setSocketResource($socketResource);
+ } else {
+ // Generate object instance
+ $clientInstance = self::createObjectByConfiguredName($registryKey, array($socketResource));
+
+ // Set it in registry for later re-use
+ GenericRegistry::getRegistry()->addInstance($registryKey, $clientInstance);
+ }
+
+ // Return the prepared instance
+ return $clientInstance;
+ }
+
+}
assert($indexInstance instanceof IndexableStack);
// Add it to the registry
- Registry::getRegistry()->addInstance($type . '_index', $indexInstance);
+ GenericRegistry::getRegistry()->addInstance($type . '_index', $indexInstance);
}
// Return the instance
$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
$templateInstance->enableXmlCompacting();
// Set the instance in registry for further use
- Registry::getRegistry()->addInstance($configEntry, $templateInstance);
+ GenericRegistry::getRegistry()->addInstance($configEntry, $templateInstance);
}
// Return the instance
} // 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);
}
}
$newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance);
// Store the news instance in registry
- Registry::getRegistry()->addInstance('news', $newsInstance);
+ GenericRegistry::getRegistry()->addInstance('news', $newsInstance);
}
}
$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);
} // END - if
// Add this instance to registry
- Registry::getRegistry()->addInstance('user', $userInstance);
+ GenericRegistry::getRegistry()->addInstance('user', $userInstance);
}
}
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/',
$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();
// 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
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? database-format-upgrade registry
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ???FormatUpgradeRegistry extends BaseRegistry implements RegisterableFormatUpgrade {
+ /**
+ * 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 final static function getRegistry () {
+ // Is an instance there?
+ if (is_null(self::$registryInstance)) {
+ // Not yet, so create one
+ self::$registryInstance = new ???FormatUpgradeRegistry();
+ } // END - if
+
+ // Return the instance
+ return self::$registryInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Registry\Upgrade\Format\Lfdb;
+/**
+ * A LocalFileDatabase database-format-upgrade registry
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class LocalFileDatabaseFormatUpgradeRegistry extends BaseRegistry implements RegisterableFormatUpgrade {
+ /**
+ * 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 final static function getRegistry () {
+ // Is an instance there?
+ if (is_null(self::$registryInstance)) {
+ // Not yet, so create one
+ self::$registryInstance = new LocalFileDatabaseFormatUpgradeRegistry();
+ } // END - if
+
+ // Return the instance
+ return self::$registryInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Registry;
+
+/**
+ * A registry for several data types and objects. Objects should be added by
+ * addInstance() and therefore must implement the interface Registerable.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class GenericRegistry 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 GenericRegistry();
+ } // END - if
+
+ // Return the instance
+ return self::$registryInstance;
+ }
+
+}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Registry;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Registry\BaseRegistry;
-use Org\Mxchange\CoreFramework\Registry\Register;
-
-/**
- * A registry for several data types and objects. Objects should be added by
- * addInstance() and therefore must implement the interface Registerable.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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;
- }
-
-}
$resolverConfigEntry,
array(
$controllerName,
- Registry::getRegistry()->getInstance('app')
+ Registry::getRegistry()->getInstance('application')
)
);
$controllerInstance = ObjectFactory::createObjectByName(
*/
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));
*/
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)) {
*/
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',
*/
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()) {
*/
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()) {
$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(). '/';
$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(). '/';
$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(). '/';
$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(). '/';
$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(). '/';
*/
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);
*/
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',
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A database migration interface
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface MigrateableDatabase extends FrameworkDatabase {
+
+}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for database format upgrade classes
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface UpgradeableDatabaseFormat extends MigrateableDatabase {
+
+}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Upgrade\Format;
+
+/**
+ * An interface for format-upgrade registries
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+interface RegisterableFormatUpgrade extends FrameworkInterface {
+ /**
+ * Registers given format-upgrade class with this registry
+ *
+ * @param $upgradeInstance An instance of a UpgradeableDatabaseFormat class
+ * @return void
+ */
+ function registerFormatUpgrader (UpgradeableDatabaseFormat $upgradeInstance);
+
+}
+++ /dev/null
-<?php
-/**
- * General configuration. Do not touch this file! If you need different settings
- * create a config-local.php in this directory at and set your changed
- * configuration entries there.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-
-// 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);
+++ /dev/null
-<?php
-/**
- * A class for the configuration stuff implemented in a singleton design paddern
- *
- * NOTE: We cannot put this in inc/main/ because it would be loaded (again) in
- * class loader. See inc/loader/class_ClassLoader.php for instance
- *
- * @see ClassLoader
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Initializes the database layer
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-
-// 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);
+++ /dev/null
-<?php
-/**
- * Initializes the local file database class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-
-// For testing purposes we use a local file database
-$databaseInstance = ObjectFactory::createObjectByConfiguredName('local_file_database_class');
+++ /dev/null
-<?php
-/**
- * Loads more include files by using the generic class loader
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-
-// 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();
+++ /dev/null
-<?php
-/**
- * A HTTP client class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class HttpClient extends BaseClient implements Client {
- // Constants
- const HTTP_EOL = "\r\n";
- const HTTP_USER_AGENT = 'HttpClient-Core/1.0';
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Set default user agent string (to allow other classes to override this)
- $this->setUserAgent(self::HTTP_USER_AGENT);
-
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this Client class and prepares it for usage
- *
- * @param $socketResource Resource of a socket (optional)
- * @return $clientInstance An instance of a Client class
- */
- public final static function createHttpClient ($socketResouce = FALSE) {
- // Get a new instance
- $clientInstance = new HttpClient();
-
- // Set socket resource
- $clientInstance->setSocketResource($socketResource);
-
- // Return the prepared instance
- return $clientInstance;
- }
-
- /**
- * Checks wether proxy configuration is used
- *
- * @return $isUsed Wether proxy is used
- */
- protected function isProxyUsed () {
- // Do we have cache?
- if (!isset($GLOBALS[__METHOD__])) {
- // Determine it
- $GLOBALS[__METHOD__] = (($this->getConfigInstance()->getConfigEntry('proxy_host') != '') && ($this->getConfigInstance()->getConfigEntry('proxy_port') > 0));
- } // END - if
-
- // Return cache
- return $GLOBALS[__METHOD__];
- }
-
- /**
- * Sets up a proxy tunnel for given hostname and through resource
- *
- * @param $host Host to connect to
- * @param $port Port number to connect to
- * @return $response Response array
- */
- protected function setupProxyTunnel ($host, $port) {
- // Initialize array
- $response = array('', '', '');
-
- // Do the connect
- $respArray = $this->doConnectRequest($host, $port);
-
- // Analyze first header line
- if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) {
- // Response code is not 200
- return $response;
- } // END - if
-
- // All fine!
- return $respArray;
- }
-
- /**
- * Sends a raw HTTP request out to given IP/host and port number
- *
- * @param $method Request method (GET, POST, HEAD, CONNECT, ...)
- * @param $host Host to connect to
- * @param $port Port number to connect to
- * @return $responseArray Array with raw response
- */
- private function sendRawHttpRequest ($method, $host, $port, array $header = array()) {
- // Minimum raw HTTP/1.1 request
- $rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL;
- $rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL;
-
- // Use login data to proxy? (username at least)
- if ($this->getConfigInstance()->getConfigEntry('proxy_username') != '') {
- // Add it as well
- $encodedAuth = base64_encode($this->getConfigInstance()->getConfigEntry('proxy_username') . ':' . $this->getConfigInstance()->getConfigEntry('proxy_password'));
- $rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL;
- } // END - if
-
- // Add last new-line
- $rawRequest .= self::HTTP_EOL;
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HTTP-CLIENT[' . __METHOD__ . ':' . __LINE__ . ']: rawRequest=' . $rawRequest);
-
- // Write request
- fwrite($this->getSocketResource(), $rawRequest);
-
- // Got response?
- if (feof($this->getSocketResource())) {
- // No response received
- return $response;
- } // END - if
-
- // Read the first line
- $resp = trim(fgets($this->getSocketResource(), 10240));
-
- // "Explode" the string to an array
- $responseArray = explode(' ', $resp);
-
- // And return it
- return $responseArray;
- }
-
- /**
- * A HTTP/1.1 CONNECT request
- *
- * @param $host Host to connect to
- * @param $port Port number to connect to
- * @return $responseArray An array with the read response
- */
- public function doConnectRequest ($host, $port) {
- // Prepare extra header(s)
- $headers = array(
- 'Proxy-Connection' => 'Keep-Alive'
- );
-
- // Prepare raw request
- $responseArray = $this->sendRawHttpRequest('CONNECT', $host, $port, $headers);
-
- // Return response array
- return $responseArray;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A Socket Container class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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;
- }
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? database migration class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class ???DatabaseMigration extends BaseDatabaseMigration implements MigrateableDatabase {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct($class = __CLASS__) {
- // Call parent constructor
- parent::__construct($class);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A general database migration class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-abstract class BaseDatabaseMigration extends BaseFrameworkSystem {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct($class = __CLASS__) {
- // Call parent constructor
- parent::__construct($class);
- }
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? format-upgrade class from format 01 to 02
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class ???FormatVersion01To02Upgrade extends BaseFormatUpgrade implements UpgradeableDatabaseFormat {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this UpgradeableDatabaseFormat class and prepares it for usage
- *
- * @return $upgradeInstance An instance of this UpgradeableDatabaseFormat class
- */
- public final static function create???FormatVersion1To2Upgrade () {
- // Get a new instance
- $upgradeInstance = new ???FormatVersion1To2Upgrade();
-
- // Return the prepared instance
- return $upgradeInstance;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A general format upgrade class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-abstract class BaseFormatUpgrade extends BaseDatabaseMigration implements MigrateableDatabase {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct($class = __CLASS__) {
- // Call parent constructor
- parent::__construct($class);
- }
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A format-upgrade class for LocalFileDatabase format version 01 to 02
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class LocalFileDatabaseFormatVersion01To02Upgrade extends BaseFormatUpgrade implements UpgradeableDatabaseFormat {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this UpgradeableDatabaseFormat class and prepares it for usage
- *
- * @return $upgradeInstance An instance of this UpgradeableDatabaseFormat class
- */
- public final static function createLocalFileDatabaseFormatVersion01To02Upgrade () {
- // Get a new instance
- $upgradeInstance = new LocalFileDatabaseFormatVersion01To02Upgrade();
-
- // Return the prepared instance
- return $upgradeInstance;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An object factory for clients
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class ClientFactory extends ObjectFactory {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates a client object for given protocol. This method uses the
- * registry pattern to cache those instances.
- *
- * @param $protocolInstance An instance of a HandleableProtocol class to create a client object for (e.g. 'http' for a HTTP/1.1 client)
- * @param $socketResource A valid socket resource (optional)
- * @return $clientInstance An instance of the requested client
- */
- public static final function createClientByProtocolInstance (HandleableProtocol $protocolInstance, $socketResource = FALSE) {
- // Default is NULL (to initialize variable)
- $clientInstance = NULL;
-
- // Generate registry key
- $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client';
-
- // Is the key already in registry?
- if (GenericRegistry::getRegistry()->instanceExists($registryKey)) {
- // Then use that instance
- $clientInstance = GenericRegistry::getRegistry()->getInstance($registryKey);
-
- // Set socket resource
- $clientInstance->setSocketResource($socketResource);
- } else {
- // Generate object instance
- $clientInstance = self::createObjectByConfiguredName($registryKey, array($socketResource));
-
- // Set it in registry for later re-use
- Registry::getRegistry()->addInstance($registryKey, $clientInstance);
- }
-
- // Return the prepared instance
- return $clientInstance;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A ??? network package handler
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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.');
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A general data Handler
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
-
-}
+++ /dev/null
-<?php
-/**
- * A !!! raw data handler
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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) {
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A general Handler for raw data from sockets
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A ??? listener
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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.') {
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A general listener class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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();
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A general decorator for listeners to communicate to hubs
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A file-based socket listener
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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.');
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A decorator for the SocketFileListener to communicate to hubs
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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;
- }
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? database-format-upgrade registry
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class ???FormatUpgradeRegistry extends BaseRegistry implements RegisterableFormatUpgrade {
- /**
- * 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 final static function getRegistry () {
- // Is an instance there?
- if (is_null(self::$registryInstance)) {
- // Not yet, so create one
- self::$registryInstance = new ???FormatUpgradeRegistry();
- } // END - if
-
- // Return the instance
- return self::$registryInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A LocalFileDatabase database-format-upgrade registry
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class LocalFileDatabaseFormatUpgradeRegistry extends BaseRegistry implements RegisterableFormatUpgrade {
- /**
- * 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 final static function getRegistry () {
- // Is an instance there?
- if (is_null(self::$registryInstance)) {
- // Not yet, so create one
- self::$registryInstance = new LocalFileDatabaseFormatUpgradeRegistry();
- } // END - if
-
- // Return the instance
- return self::$registryInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A registry for several data types and objects. Objects should be added by
- * addInstance() and therefore must implement the interface Registerable.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class GenericRegistry 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 GenericRegistry();
- } // END - if
-
- // Return the instance
- return self::$registryInstance;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * A ??? resolver
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An ActiveTask visitor
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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.
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An ShutdownTask visitor
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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();
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown when a configuration entry is empty
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown when the save path string is empty
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown when a file name is empty or NULL.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown when the path string is empty
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown when the language path string is empty
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * This exception is thrown when a command instance is invalid
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown when a method is missing, this exception is used in
- * guest/user login classes and thrown when a factory method is absend. I think
- * we should still give it a try to rewrite these classes and again mark this
- * method as deprecated because we have a more flexible ObjectFactory class.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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 <u>%s()</u>.',
- $classArray[0]->__toString(),
- $this->getLine(),
- $classArray[1]
- );
-
- // Call parent constructor
- parent::__construct($message, $code);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * This exception is thrown when the requested socket is not thrown
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * This exception is thrown if the socket cannot be shut down is not error 107
- * which is "Transport endpoint not connected".
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown when the base path is empty
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * An exception thrown hen the base path string is invalid
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
- }
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A database migration interface
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-interface MigrateableDatabase extends FrameworkDatabase {
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * An interface for database format upgrade classes
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-interface UpgradeableDatabaseFormat extends MigrateableDatabase {
-
-}
+++ /dev/null
-<?php
-/**
- * An interface for protocol handlers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
-
-}
+++ /dev/null
-<?php
-/**
- * An interface for listeners
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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 ();
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * An interface for format-upgrade registries
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-interface RegisterableFormatUpgrade extends FrameworkInterface {
- /**
- * Registers given format-upgrade class with this registry
- *
- * @param $upgradeInstance An instance of a UpgradeableDatabaseFormat class
- * @return void
- */
- function registerFormatUpgrader (UpgradeableDatabaseFormat $upgradeInstance);
-
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A class for registerable socket classes
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
-
-}
+++ /dev/null
-<?php
-/**
- * An instance for state resolver classes
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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);
-
-}
+++ /dev/null
-<?php
-/**
- * An interface for the visitor implementation for listeners
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-interface ListenerVisitor extends Visitor {
- /**
- * Visits the given listener instance
- *
- * @param $listenerInstance A Listenable instance
- * @return void
- */
- function visitListener (Listenable $listenerInstance);
-
-}
+++ /dev/null
-<?php
-/**
- * An interface for the visitor implementation for pools
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-interface PoolVisitor extends Visitor {
- /**
- * Visits the given pool instance
- *
- * @param $poolInstance A Poolable instance
- * @return void
- */
- function visitPool (Poolable $poolInstance);
-
-}
+++ /dev/null
-<?php
-/**
- * The application selector main include file
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-
-// 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);