--- /dev/null
+<?php
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+
+/**
+ * Local configuration entries which you can customize. Please keep the
+ * comments starting with CFG: as-is or else, the later configuration wizard
+ * (aka. 'admin' project) will not be able to parse it. You need to rename this
+ * file to config-local.php and make in that new file your changes.
+ *
+ * If you want to start an own network (which may accept different types of
+ * objects which would be rejected by the global network) please change
+ * hub_bootstrap_nodes (semicolon-seperated list) to your bootstrapper.
+ *
+ * You can set external_address to a hostname, e.g. me.homelinux.org, which will be
+ * included in the announcement. This is very useful for consumer DSL
+ * connections because they might be disconnected every 24 hours and rotate the
+ * IP number.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General 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/>.
+ */
+
+// Some hub-specific configuration like port hostname where we will listen, etc.
+$cfg = FrameworkBootstrap::getConfigurationInstance();
// 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', 'Org\Mxchange\CoreFramework\Action\PostRegistration\Login\LoginAfterRegistrationAction');
// CFG: COOKIE-SSL
$cfg->setConfigEntry('cookie_ssl', FrameworkBootstrap::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: COMPRESSOR-CHANNEL-CLASS
$cfg->setConfigEntry('compressor_channel_class', 'Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel');
-// CFG: DEBUG-HTML-OUTPUT-TIMINGS
-$cfg->setConfigEntry('debug_html_output_timings', 'N');
+// CFG: IS-DEBUG-HTML-OUTPUT-TIMINGS-ENABLED
+$cfg->setConfigEntry('is_debug_html_output_timings_enabled', false);
-// CFG: DEBUG-CONSOLE-OUTPUT-TIMINGS
-$cfg->setConfigEntry('debug_console_output_timings', 'Y');
+// CFG: IS-DEBUG-CONSOLE-OUTPUT-TIMINGS-ENABLED
+$cfg->setConfigEntry('is_debug_console_output_timings_enabled', true);
// CFG: PROXY-HOST
$cfg->setConfigEntry('proxy_host', '');
// 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: CRYPTO-HASH-FUNCTION-NAME
$cfg->setConfigEntry('crypto_hash_function_name', 'sha256');
+
+/**
+ * -------------------------------------------------------------
+ * Boolean is_*_enabled configuration keys
+ * -------------------------------------------------------------
+ */
+
+// CFG: IS-REGISTER-EMAIL-UNIQUE-ENABLED
+$cfg->setConfigEntry('is_register_email_unique_enabled', true);
+
+// CFG: IS-BLOCK-SHOWS-REGISTRATION-ENABLED
+$cfg->setConfigEntry('is_block_shows_registration_enabled', true);
+
+// CFG: IS-REGISTER-REQUIRES-EMAIl-ENABLED
+$cfg->setConfigEntry('is_register_requires_email_enabled', true);
+
+// CFG: IS-REGISTER-INCLUDES-PROFILE-ENABLED
+$cfg->setConfigEntry('is_register_includes_profile_enabled', true);
+
+// CFG: IS-REGISTER-PERSONAL-DATA-ENABLED
+$cfg->setConfigEntry('is_register_personal_data_enabled', true);
+
+// CFG: IS-PROFILE-INCLUDES-BIRTHDAY-ENABLED
+$cfg->setConfigEntry('is_profile_includes_birthday_enabled', true);
+
+// CFG: IS-USER-LOGIN-ENABLED
+$cfg->setConfigEntry('is_user_login_enabled', true);
+
+// CFG: IS-GUEST-LOGIN-ENABLED
+$cfg->setConfigEntry('is_guest_login_enabled', true);
+
+// CFG: IS-EMAIL-CHANGE-CONFIRMATION-ENABLED
+$cfg->setConfigEntry('is_email_change_confirmation_enabled', true);
+
+// CFG: IS-EMAIL-CHANGE-ENABLED
+$cfg->setConfigEntry('is_email_change_enabled', true);
+
+// CFG: IS-REFILL-PAGE-ACTIVE-ENABLED
+$cfg->setConfigEntry('is_refill_page_active_enabled', true);
+
+// CFG: IS-PROXY-CONNECT-METHOD-ENABLED
+$cfg->setConfigEntry('is_proxy_connect_method_enabled', true);
+
+// CFG: IS-SINGLE-SERVER-ENABLED
+$cfg->setConfigEntry('is_single_server_enabled', true);
+
+// CFG: IS-CRYPT-FIXED-SALT-ENABLED
+$cfg->setConfigEntry('is_crypt_fixed_salt_enabled', false);
+
+// CFG: IS-DB-UPDATE-PRIMARY-FORCED-ENABLED
+$cfg->setConfigEntry('is_db_update_primary_forced_enabled', true);
// Import SPL stuff
use \InvalidArgumentException;
+use \UnexpectedValueException;
/**
* A class for the configuration stuff implemented in a singleton design pattern
//* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
+ /**
+ * Checks if a configuration entry is_*_enabled set to 'Y'
+ *
+ * @param $keyPart Configuration to expand with is_$keyPart_enabled
+ * @return $enabled Whether it has been set to Y or N
+ * @throws InvalidArgumentException If a parameter is invalid
+ * @throws UnexpectedValueException If a returned value is of an unexpected type or value
+ */
+ public function isEnabled (string $keyPart) {
+ // Validate parameters
+ //* NOISY-DEBUG: */ printf('[%s:%d]: keyPart=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $keyPart);
+ if (empty($keyPart)) {
+ // Entry is empty
+ throw new InvalidArgumentException('Parameter "keyPart" is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+ }
+
+ // Construct final config key
+ $configKey = sprintf('is_%s_enabled', $keyPart);
+
+ // Get value from it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s' . PHP_EOL, __METHOD__, __LINE__, $configKey);
+ $isEnabled = $this->getConfigEntry($configKey);
+
+ // Is it Y/N?
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isEnabled[]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($isEnabled));
+ if (!is_bool($isEnabled)) {
+ // Throw exception
+ throw new UnexpectedValueException(sprintf('isEnabled[]=%s is unexpected', gettype($isEnabled)));
+ }
+
+ // Return it
+ //* NOISY-DEBUG: */ printf('[%s:%d]: isEnabled=%d - EXIT!' . PHP_EOL, __METHOD__, __LINE__, intval($isEnabled));
+ return $isEnabled;
+ }
+
/**
* Generates a code for hashes from this class
*
}
} else {
// Are debug times enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings') == 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings')) {
// Prepent it
$message = $this->getPrintableExecutionTime() . $message;
}
// Then create the info file
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Creating info table for tableName=%s ...', $tableName));
$this->createTableInfoFile($dataSetInstance);
- } elseif ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('db_update_primary_forced') == 'Y') && ($dataSetInstance->getPrimaryKey() != $this->tableInfo[$tableName]['primary'])) {
+ } elseif (FrameworkBootstrap::getConfigurationInstance()->isEnabled('db_update_primary_forced') && $dataSetInstance->getPrimaryKey() != $this->tableInfo[$tableName]['primary']) {
// Set the array element
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Setting primaryKey=%s for tableName=%s ...', $dataSetInstance->getPrimaryKey(), $tableName));
$this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey();
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* The general feature management class. No instance is needed as this class
* has only public methods that are static.
*
* @param $featureName Name of the feature to be checked
* @return $isEnabled Whether the given feature is enabled
+ * @throws InvalidArgumentException If a parameter is invalid
*/
public static function isFeatureEnabled (string $featureName) {
+ // Check parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
+ if (empty($featureName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureName" is empty');
+ }
+
// Is the cache set?
if (!isset(self::$enabledFeatures[$featureName]['is_enabled'])) {
// Generate config key
}
// Return "cached" status
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: is_enabled[%s]=%d - EXIT!', $featureName, intval(self::$enabledFeatures[$featureName]['is_enabled'])));
return self::$enabledFeatures[$featureName]['is_enabled'];
}
*
* @param $featureName Name of the feature to be checked on availability
* @return $isAvailable Whether the given feature is available
+ * @throws InvalidArgumentException If a parameter is invalid
*/
public static function isFeatureAvailable (string $featureName) {
- // Is the cache set?
+ // Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
+ if (empty($featureName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "featureName" is empty');
+ }
+
+ // Is the cache set?
if (!isset(self::$enabledFeatures[$featureName]['is_available'])) {
// Default is not available
self::$enabledFeatures[$featureName]['is_available'] = false;
$email = $requestInstance->getRequestElement('email');
// Is the Email set?
- if ((is_null($email)) || (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_email_unique') == 'Y')) {
+ if ((is_null($email)) || (FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_email_unique'))) {
// Try it again
$email1 = $requestInstance->getRequestElement('email1');
$email2 = $requestInstance->getRequestElement('email2');
}
// Create config entry
- $configKey = sprintf('%s_captcha_secured',
- $requestInstance->getRequestElement('form')
- );
+ $configKey = sprintf('%s_captcha_secured', $requestInstance->getRequestElement('form'));
// Is the CAPTCHA enabled?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey) != 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled($configKey)) {
// Not enabled, so don't check
return;
}
* @return $withRegistration Whether with registration date
*/
public function ifIncludeRegistrationStamp () {
- $withRegistration = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('block_shows_registration') == 'Y');
+ $withRegistration = FrameworkBootstrap::getConfigurationInstance()->isEnabled('block_shows_registration');
return $withRegistration;
}
* @return $required Whether the email address is required
*/
public function ifRegisterRequiresEmailVerification () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_requires_email') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_requires_email');
return $required;
}
* @return $required Whether profile data shall be asked
*/
public function ifRegisterIncludesProfile () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_includes_profile') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_includes_profile');
return $required;
}
* @return $isSecured Whether this form is secured by a CAPTCHA
*/
public function ifFormSecuredWithCaptcha () {
- $isSecured = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y');
+ $isSecured = FrameworkBootstrap::getConfigurationInstance()->isEnabled($this->getFormName() . '_captcha_secured');
return $isSecured;
}
* @return $required Whether personal data shall be asked
*/
public function ifRegisterIncludesPersonaData () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_personal_data') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_personal_data');
return $required;
}
* @return $required Whether birthday shall be asked
*/
public function ifProfileIncludesBirthDay () {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('profile_includes_birthday') == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('profile_includes_birthday');
return $required;
}
* @return $isUnique
*/
public function ifEmailMustBeUnique () {
- $isUnique = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('register_email_unique') == 'Y');
+ $isUnique = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_email_unique');
return $isUnique;
}
* @return $required Whether the specified chat protocol is enabled
*/
public function ifChatEnabled (string $chatProtocol) {
- $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
+ $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('chat_protocol_' . $chatProtocol);
return $required;
}
* @return $isEnabled Whether the login is enabled or disabled
*/
public function ifLoginIsEnabled () {
- $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_enabled') == 'Y');
+ $isEnabled = FrameworkBootstrap::getConfigurationInstance()->isEnabled('user_login');
return $isEnabled;
}
* @return $isEnabled Whether the login shall be done by username
*/
public function ifLoginWithUsername () {
- $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == "username");
+ $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == 'username');
return $isEnabled;
}
* @return $isEnabled Whether the login shall be done by email
*/
public function ifLoginWithEmail () {
- $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == "email");
+ $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == 'email');
return $isEnabled;
}
* @return $isAllowed Whether guest login is allowed
*/
public function ifGuestLoginAllowed () {
- $isAllowed = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('guest_login_allowed') == 'Y');
+ $isAllowed = FrameworkBootstrap::getConfigurationInstance()->isEnabled('guest_login');
return $isAllowed;
}
* @return $requireConfirm Whether email change must be confirmed
*/
public function ifEmailChangeRequireConfirmation () {
- $requireConfirm = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('email_change_confirmation') == 'Y');
+ $requireConfirm = FrameworkBootstrap::getConfigurationInstance()->isEnabled('email_change_confirmation');
return $requireConfirm;
}
* @return $emailChange Whether changing email address is allowed
*/
public function ifEmailChangeAllowed () {
- $emailChange = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('email_change_allowed') == 'Y');
+ $emailChange = FrameworkBootstrap::getConfigurationInstance()->isEnabled('email_change');
return $emailChange;
}
* @return $refillActive Whether the refill page is active
*/
public function ifRefillPageActive () {
- $refillActive = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('refill_page_active') == 'Y');
+ $refillActive = FrameworkBootstrap::getConfigurationInstance()->isEnabled('refill_page_active');
return $refillActive;
}
/**
* Cached configuration entry 'debug_*_output_timings'
*/
- private $debugOutputTimings = 'N';
+ private $isDebugOutputTimingsEnabled = FALSE;
/**
* Protected constructor
parent::__construct(__CLASS__);
// Cache configuration entry
- $this->debugOutputTimings = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings');
+ $this->isDebugOutputTimingsEnabled = FrameworkBootstrap::getConfigurationInstance()->isEnabled('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings');
}
/**
}
// Are debug times enabled?
- if ($this->debugOutputTimings == 'Y') {
+ if ($this->isDebugOutputTimingsEnabled) {
// Output it first
$output = $this->getPrintableExecutionTime() . $output;
}
$serverIp = 'cluster';
// Do we have a single server?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('is_single_server') == 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('single_server')) {
// Then use that IP for extra security
$serverIp = FrameworkBootstrap::detectServerAddress();
}
$key = md5($this->getExtraSalt());
// Get key
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('crypt_fixed_salt') == 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('crypt_fixed_salt')) {
$key = md5($this->getFixedSalt());
}
// Do we use proxy?
if ($helperInstance->isProxyUsed() === true) {
// CONNECT method?
- if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_connect_method') == 'Y') {
+ if (FrameworkBootstrap::getConfigurationInstance()->isEnabled('proxy_connect_method')) {
// Setup proxy tunnel
$response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource);
* @param $requestInstance An instance of a class with an Requestable interface
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
- * @todo 0% done
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Init counter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
$passed = 0;
$failed = 0;
+ $skipped = 0;
// Loop through all configuration keys
foreach (FrameworkBootstrap::getConfigurationInstance()->getConfigurationArray() as $configKey => $configValue) {
// Key must end with _class
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
if (substr($configKey, -6, 6) != '_class') {
// Skip this
+ $skipped++;
continue;
}
// Is the config entry valid and class is there?
if (!is_string($configValue)) {
// Is not a string
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('configValue=%s has unexpected type "%s". FAILED', $configValue, gettype($configValue)));
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('configValue=%s has unexpected type "%s", required: string - FAILED!', $configValue, gettype($configValue)));
// Skip further tests
$failed++;
continue;
} elseif (!class_exists($configValue)) {
// Class not found
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED', $configValue));
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED!', $configValue));
// Skip further tests
$failed++;
}
// Output result
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Test result: %d okay, %d failed (%0.02f%% passed)', $passed, $failed, ($passed / ($passed + $failed) * 100)));
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped - EXIT!', $passed, $failed, ($passed / ($passed + $failed) * 100), $skipped));
}
}