From 91de23a7cb7b4c51500d8ce1df76b8af8843cb0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 12 Dec 2021 07:30:30 +0100 Subject: [PATCH] Continued: - made ClassLoader final as no inheriting classes shall be made (it is generic enough) - renamed ClassLoader->$foundClasses to $pendingFiles as this describes the content of the array more closely - removed some old-lost "// END - if" (WAY more to follow!) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- framework/loader/class_ClassLoader.php | 93 ++-- .../controller/class_BaseController.php | 6 +- .../classes/criteria/class_BaseCriteria.php | 10 +- .../dataset/class_DataSetCriteria.php | 2 +- .../filter/auth/class_UserAuthFilter.php | 8 +- .../filter/change/class_EmailChangeFilter.php | 10 +- .../change/class_PasswordChangeFilter.php | 8 +- .../checkboxes/class_RulesAcceptedFilter.php | 2 +- .../main/classes/filter/class_FilterChain.php | 4 +- .../crypto/class_CaptchaEncryptFilter.php | 4 +- .../guest/class_UserNameIsGuestFilter.php | 2 +- .../payment/class_PaymentDiscoveryFilter.php | 2 +- .../validator/class_EmailValidatorFilter.php | 4 +- .../class_PasswordValidatorFilter.php | 4 +- .../class_UserNameValidatorFilter.php | 2 +- .../classes/images/png/class_PngImage.php | 2 +- .../main/classes/mailer/class_BaseMailer.php | 2 +- .../mailer/debug/class_DebugMailer.php | 4 +- .../crypto/mcrypt/class_McryptStream.php | 4 +- .../crypto/openssl/class_OpenSslStream.php | 4 +- .../exceptions/class_FrameworkException.php | 14 +- .../class_UnsupportedOperationException.php | 2 +- .../xml/class_InvalidXmlNodeException.php | 2 +- .../compressor/class_CompressorChannel.php | 8 +- .../debug/class_DebugMiddleware.php | 2 +- .../middleware/io/class_FileIoHandler.php | 2 +- .../api/wernisportal/class_WernisApi.php | 427 +----------------- index.php | 7 +- 28 files changed, 111 insertions(+), 530 deletions(-) diff --git a/framework/loader/class_ClassLoader.php b/framework/loader/class_ClassLoader.php index 3f5271a0..f29e6b63 100644 --- a/framework/loader/class_ClassLoader.php +++ b/framework/loader/class_ClassLoader.php @@ -60,16 +60,17 @@ use \SplFileInfo; * - Initial release * ---------------------------------- */ -class ClassLoader { +final class ClassLoader { /** * Instance of this class */ private static $selfInstance = NULL; /** - * Array with all found classes + * Array with all valid but pending for loading file names (class, + * interfaces, traits must start with below prefix). */ - private $foundClasses = []; + private $pendingFiles = []; /** * List of loaded classes @@ -168,7 +169,7 @@ class ClassLoader { // Skip here if already cached if ($this->listCached === false) { // Writes the cache file of our list away - $cacheContent = json_encode($this->foundClasses); + $cacheContent = json_encode($this->pendingFiles); // Open cache instance $fileObject = $this->listCacheFile->openFile('w'); @@ -208,25 +209,27 @@ class ClassLoader { //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__); $loaderInstance = self::getSelfInstance(); - // "Cache" configuration instance + // "Cache" configuration instance and framework base path $configInstance = FrameworkBootstrap::getConfigurationInstance(); + $frameworkBasePath = $configInstance->getConfigEntry('framework_base_path'); // Load all classes + //* NOISY-DEBUG: */ printf('[%s:%d]: frameworkBasePath=%s,self::$frameworkPaths()=%d,' . PHP_EOL, __METHOD__, __LINE__, $frameworkBasePath, count(self::$frameworkPaths)); foreach (self::$frameworkPaths as $shortPath) { // Generate full path from it - //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath); + //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($shortPath), $shortPath); $realPathName = realpath(sprintf( '%smain%s%s%s', - $configInstance->getConfigEntry('framework_base_path'), + $frameworkBasePath, DIRECTORY_SEPARATOR, $shortPath, DIRECTORY_SEPARATOR )); // Is it not false and accessible? - //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName=%s' . PHP_EOL, __METHOD__, __LINE__, $realPathName); + //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPathName), $realPathName); if (is_bool($realPathName)) { - // Skip this + // Skip this, it is not accessible continue; } elseif (!is_readable($realPathName)) { // @TODO Throw exception instead of break @@ -285,18 +288,14 @@ class ClassLoader { * @return void */ public static function scanTestsClasses () { - // Trace message - //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__); - // "Cache" configuration instance + //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__); $configInstance = FrameworkBootstrap::getConfigurationInstance(); // Load all classes for the application foreach (self::$testPaths as $shortPath) { - // Debug message - //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath); - // Construct path name + //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath); $pathName = sprintf( '%s%s%s', $configInstance->getConfigEntry('root_base_path'), @@ -354,17 +353,24 @@ class ClassLoader { * @throws InvalidArgumentException If the class' name does not contain a namespace: Tld\Domain\Project is AT LEAST recommended! */ public static function autoLoad (string $className) { - // The class name should contain at least 2 back-slashes, so split at them + // Validate parameter //* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className); + if (empty($className)) { + // Should not be empty + throw new InvalidArgumentException('Parameter "className" is empty'); + } + + // The class name MUST be at least Tld\Domain\Project\Package\SomeFooBar so split at them $classNameParts = explode("\\", $className); // At least 3 parts should be there if ((self::$strictNamingConvention === true) && (count($classNameParts) < 5)) { - // Namespace scheme is: Project\Package[\SubPackage...] + // Namespace scheme is: Tld\Domain\Project\Package[\SubPackage...] throw new InvalidArgumentException(sprintf('Class name "%s" is not conform to naming-convention: Tld\Domain\Project\Package[\SubPackage...]\SomeFooBar', $className)); } // Try to include this class + //* NOISY-DEBUG: */ printf('[%s:%d]: Calling self->loadClassFile(%s) ...' . PHP_EOL, __METHOD__, __LINE__, $className); self::getSelfInstance()->loadClassFile($className); // Trace message @@ -422,22 +428,16 @@ class ClassLoader { */ protected function scanClassPath (string $basePath, array $ignoreList = [] ) { // Is a list has been restored from cache, don't read it again + /* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s,ignoreList()=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $basePath, count($ignoreList)); if ($this->listCached === true) { // Abort here + /* NOISY-DEBUG: */ printf('[%s:%d] this->listCache=true - EXIT!' . PHP_EOL, __METHOD__, __LINE__); return; } // Keep it in class for later usage $this->ignoreList = $ignoreList; - /* - * Ignore .htaccess by default as it is for protection of directories - * on Apache servers. - * - * @deprecated - */ - array_push($ignoreList, '.htaccess'); - /* * Set base directory which holds all our classes, an absolute path * should be used here so is_dir(), is_file() and so on will always @@ -446,6 +446,7 @@ class ClassLoader { $basePath2 = realpath($basePath); // If the basePath is false it is invalid + /* NOISY-DEBUG: */ printf('[%s:%d] basePath2[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($basePath2), $basePath2); if ($basePath2 === false) { /* @TODO: Do not exit here. */ exit(__METHOD__ . ': Cannot read ' . $basePath . ' !' . PHP_EOL); @@ -472,23 +473,23 @@ class ClassLoader { $iteratorInstance->next(); // Skip non-file entries - //* NOISY-DEBUG: */ printf('[%s:%d] SKIP: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName); + //* NOISY-DEBUG: */ printf('[%s:%d] SKIP: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName); continue; } // Is this file wanted? - //* NOISY-DEBUG: */ printf('[%s:%d] FOUND: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName); + //* NOISY-DEBUG: */ printf('[%s:%d] FOUND: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName); if ((substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) { // Add it to the list - //* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,currentEntry=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $currentEntry); - $this->foundClasses[$fileName] = $currentEntry; + //* NOISY-DEBUG: */ printf('[%s:%d] ADD: fileName=%s,currentEntry=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $currentEntry); + $this->pendingFiles[$fileName] = $currentEntry; } else { // Not added - //* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,currentEntry=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $currentEntry); + //* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: fileName=%s,currentEntry=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $currentEntry); } // Advance to next entry - //* NOISY-DEBUG: */ printf('[%s:%d] NEXT: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName); + //* NOISY-DEBUG: */ printf('[%s:%d] NEXT: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName); $iteratorInstance->next(); } } @@ -521,7 +522,7 @@ class ClassLoader { // Is the cache there? if (FrameworkBootstrap::isReadableFile($this->listCacheFile)) { // Load and convert it - $this->foundClasses = json_decode(file_get_contents($this->listCacheFile->getPathname())); + $this->pendingFiles = json_decode(file_get_contents($this->listCacheFile->getPathname())); // List has been restored from cache! $this->listCached = true; @@ -538,9 +539,10 @@ class ClassLoader { } /** - * Tries to find the given class in our list. This method ignores silently - * missing classes or interfaces. So if you use class_exists() this method - * does not interrupt your program. + * Tries to find the given class in our list. It will ignore already loaded + * (to the program available) class/interface/trait files. But you SHOULD + * save below "expensive" code by pre-checking this->loadedClasses[], if + * possible. * * @param $className The class that shall be loaded * @return void @@ -557,22 +559,22 @@ class ClassLoader { $fileName = sprintf('%s%s%s', $this->prefix, $shortClassName, $this->suffix); // Now look it up in our index - //* NOISY-DEBUG: */ printf('[%s:%d] ISSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName); - if ((isset($this->foundClasses[$fileName])) && (!isset($this->loadedClasses[$this->foundClasses[$fileName]->getPathname()]))) { + //* NOISY-DEBUG: */ printf('[%s:%d] ISSET: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName); + if ((isset($this->pendingFiles[$fileName])) && (!isset($this->loadedClasses[$this->pendingFiles[$fileName]->getPathname()]))) { // File is found and not loaded so load it only once - //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName); - FrameworkBootstrap::loadInclude($this->foundClasses[$fileName]); - //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName); + //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: fileName=%s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName); + FrameworkBootstrap::loadInclude($this->pendingFiles[$fileName]); + //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: fileName=%s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName); // Count this loaded class/interface/exception $this->total++; // Mark this class as loaded for other purposes than loading it. - $this->loadedClasses[$this->foundClasses[$fileName]->getPathname()] = true; + $this->loadedClasses[$this->pendingFiles[$fileName]->getPathname()] = true; // Remove it from classes list so it won't be found twice. - //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName); - unset($this->foundClasses[$fileName]); + //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName); + unset($this->pendingFiles[$fileName]); // Developer mode excludes caching (better debugging) if (!FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) { @@ -582,8 +584,11 @@ class ClassLoader { } } else { // Not found - //* NOISY-DEBUG: */ printf('[%s:%d] 404: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName); + //* NOISY-DEBUG: */ printf('[%s:%d] 404: fileName=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName); } + + // Trace message + //* NOISY-DEBUG: */ printf('[%s:%d] EXIT!' . PHP_EOL, __METHOD__, __LINE__); } } diff --git a/framework/main/classes/controller/class_BaseController.php b/framework/main/classes/controller/class_BaseController.php index 14037990..5f1d42e4 100644 --- a/framework/main/classes/controller/class_BaseController.php +++ b/framework/main/classes/controller/class_BaseController.php @@ -141,7 +141,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl // Execute *very* generic post filters $this->executePostFilters($requestInstance, $responseInstance); - } // END - if + } // Flush the buffer out $responseInstance->flushBuffer(); @@ -214,7 +214,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl if (!isset($this->filterChains[$filterChain])) { // Throw an exception here throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID); - } // END - if + } // Add the filter $this->filterChains[$filterChain]->addFilter($filterInstance); @@ -267,7 +267,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl if (!isset($this->filterChains[$filterChain])) { // Throw an exception here throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID); - } // END - if + } // Run all filters $this->filterChains[$filterChain]->processFilters($requestInstance, $responseInstance); diff --git a/framework/main/classes/criteria/class_BaseCriteria.php b/framework/main/classes/criteria/class_BaseCriteria.php index a477e072..9331121c 100644 --- a/framework/main/classes/criteria/class_BaseCriteria.php +++ b/framework/main/classes/criteria/class_BaseCriteria.php @@ -291,7 +291,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { if ($this->isKeySet($criteriaType, $criteriaKey)) { // Then use it $value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); - } // END - if + } // Return the value //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!'); @@ -352,7 +352,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { if (($key == $criteriaKey) && ($criteriaValue == $entry)) { // Then count this one up $counted++; - } // END - if + } } // END - foreach } // END - foreach @@ -420,7 +420,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { $criteriaKey, urlencode($criteriaValue) ); - } // END - if + } } // END - foreach // Remove last semicolon @@ -435,8 +435,8 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { $this->getLimit(), $this->getSkip() ); - } // END - if - } // END - if + } + } // Return the cache key return $cacheKey; diff --git a/framework/main/classes/criteria/dataset/class_DataSetCriteria.php b/framework/main/classes/criteria/dataset/class_DataSetCriteria.php index f970fc50..5413cfea 100644 --- a/framework/main/classes/criteria/dataset/class_DataSetCriteria.php +++ b/framework/main/classes/criteria/dataset/class_DataSetCriteria.php @@ -252,7 +252,7 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria { if (empty($primaryKey)) { // Get uniqueKey $primaryKey = $this->getUniqueKey(); - } // END - if + } // Return it return $primaryKey; diff --git a/framework/main/classes/filter/auth/class_UserAuthFilter.php b/framework/main/classes/filter/auth/class_UserAuthFilter.php index 985df48f..d902899b 100644 --- a/framework/main/classes/filter/auth/class_UserAuthFilter.php +++ b/framework/main/classes/filter/auth/class_UserAuthFilter.php @@ -110,7 +110,7 @@ class UserAuthFilter extends BaseFilter implements Filterable { // Stop here throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID); - } // END - if + } // Regular user account $className = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_class'); @@ -121,13 +121,13 @@ class UserAuthFilter extends BaseFilter implements Filterable { // Set class $className = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('guest_class'); $methodName = 'createGuestByUserName'; - } // END - if + } // Does the guest class exist? if (!class_exists($className)) { // Then abort here throw new NoClassException (array($this, $className), self::EXCEPTION_CLASS_NOT_FOUND); - } // END - if + } // Now try the dynamic login $userInstance = call_user_func_array(array($className, $methodName), array($authLogin)); @@ -136,7 +136,7 @@ class UserAuthFilter extends BaseFilter implements Filterable { if ($userInstance->getPasswordHash() !== $authHash) { // Mismatching password throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH); - } // END - if + } // Remember auth and user instances in registry GenericRegistry::getRegistry()->addInstance('auth', $authInstance); diff --git a/framework/main/classes/filter/change/class_EmailChangeFilter.php b/framework/main/classes/filter/change/class_EmailChangeFilter.php index 7a228bad..1b4600af 100644 --- a/framework/main/classes/filter/change/class_EmailChangeFilter.php +++ b/framework/main/classes/filter/change/class_EmailChangeFilter.php @@ -80,7 +80,7 @@ class EmailChangeFilter extends BaseFilter implements Filterable { // Stop processing here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } // Is only second email set? if ((empty($email1)) && (!empty($email2))) { @@ -92,7 +92,7 @@ class EmailChangeFilter extends BaseFilter implements Filterable { // Stop processing here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } // Do both match? if ($email1 != $email2) { @@ -104,13 +104,13 @@ class EmailChangeFilter extends BaseFilter implements Filterable { // Stop processing here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } // Are email and confirmation empty? if ((empty($email1)) && (empty($email2))) { // No email change required! return true; - } // END - if + } // Now, get a user instance for comparison $userInstance = GenericRegistry::getRegistry()->getInstance('user'); @@ -122,7 +122,7 @@ class EmailChangeFilter extends BaseFilter implements Filterable { if ($userEmail == $email1) { // Nothing has been changed is fine... return true; - } // END - if + } // Update the "new_email" field $this->partialStub('Unfinished part.'); diff --git a/framework/main/classes/filter/change/class_PasswordChangeFilter.php b/framework/main/classes/filter/change/class_PasswordChangeFilter.php index 40f2c4af..e00c3543 100644 --- a/framework/main/classes/filter/change/class_PasswordChangeFilter.php +++ b/framework/main/classes/filter/change/class_PasswordChangeFilter.php @@ -81,7 +81,7 @@ class PasswordChangeFilter extends BaseFilter implements Filterable { // Stop processing here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } // Is only second pass set? if ((empty($pass1)) && (!empty($pass2))) { @@ -93,13 +93,13 @@ class PasswordChangeFilter extends BaseFilter implements Filterable { // Stop processing here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } // Are password and confirmation empty? if ((empty($pass1)) && (empty($pass2))) { // Don't change password here return true; - } // END - if + } // Do both match? if ($pass1 != $pass2) { @@ -111,7 +111,7 @@ class PasswordChangeFilter extends BaseFilter implements Filterable { // Stop processing here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } // Now, get a user instance for comparison $userInstance = GenericRegistry::getRegistry()->getInstance('user'); diff --git a/framework/main/classes/filter/checkboxes/class_RulesAcceptedFilter.php b/framework/main/classes/filter/checkboxes/class_RulesAcceptedFilter.php index 7672f48d..ad022245 100644 --- a/framework/main/classes/filter/checkboxes/class_RulesAcceptedFilter.php +++ b/framework/main/classes/filter/checkboxes/class_RulesAcceptedFilter.php @@ -79,7 +79,7 @@ class RulesAcceptedFilter extends BaseFilter implements Filterable { // Skip further processing throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } } } diff --git a/framework/main/classes/filter/class_FilterChain.php b/framework/main/classes/filter/class_FilterChain.php index 807a2caf..da922dd1 100644 --- a/framework/main/classes/filter/class_FilterChain.php +++ b/framework/main/classes/filter/class_FilterChain.php @@ -89,7 +89,7 @@ class FilterChain extends BaseFrameworkSystem implements Registerable { if ($this->isValidGenericArrayKey('filters', 'generic', 'dummy')) { // Then get them $filters = $this->getGenericArrayKey('filters', 'generic', 'dummy'); - } // END - if + } // Return it return $filters; @@ -108,7 +108,7 @@ class FilterChain extends BaseFrameworkSystem implements Registerable { if ($this->isValidGenericArrayKey('filters', 'post', 'dummy')) { // Then get them $filters = $this->getGenericArrayKey('filters', 'post', 'dummy'); - } // END - if + } // Return it return $filters; diff --git a/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php b/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php index 4326a052..377aab8e 100644 --- a/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php +++ b/framework/main/classes/filter/crypto/class_CaptchaEncryptFilter.php @@ -76,7 +76,7 @@ class CaptchaEncryptFilter extends BaseFilter implements Filterable { // Throw exception throw new EncryptMissingException($this, CryptoHelper::EXCEPTION_ENCRYPT_MISSING); - } // END - if + } // Decode it fully $encryptDecoded = base64_decode(str_replace(' ', '+', urldecode($encryptRequest))); @@ -91,7 +91,7 @@ class CaptchaEncryptFilter extends BaseFilter implements Filterable { // Throw exception throw new EncryptInvalidLengthException($this, CryptoHelper::EXCEPTION_ENCRYPT_INVALID); - } // END - if + } // Write it to the request $requestInstance->setRequestElement('decrypted', $decryptedString); diff --git a/framework/main/classes/filter/guest/class_UserNameIsGuestFilter.php b/framework/main/classes/filter/guest/class_UserNameIsGuestFilter.php index c815e0c5..4038c7eb 100644 --- a/framework/main/classes/filter/guest/class_UserNameIsGuestFilter.php +++ b/framework/main/classes/filter/guest/class_UserNameIsGuestFilter.php @@ -72,7 +72,7 @@ class UserNameIsGuestFilter extends BaseFilter implements Filterable { // Then set the password to the configured password $requestInstance->setRequestElement('pass1', FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('guest_login_passwd')); $requestInstance->setRequestElement('pass2', FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('guest_login_passwd')); - } // END - if + } } } diff --git a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php index d10bf90f..a09870f2 100644 --- a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php +++ b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php @@ -73,7 +73,7 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable { if (is_null($resolverInstance)) { // Throw an exception here throw new NullPointerException($filterInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if + } // Get the action name from resolver $actionName = $resolverInstance->getActionName(); diff --git a/framework/main/classes/filter/validator/class_EmailValidatorFilter.php b/framework/main/classes/filter/validator/class_EmailValidatorFilter.php index 6721c4fd..8d1d827c 100644 --- a/framework/main/classes/filter/validator/class_EmailValidatorFilter.php +++ b/framework/main/classes/filter/validator/class_EmailValidatorFilter.php @@ -96,13 +96,13 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { if (empty($email1)) { // Add a message to the response $responseInstance->addFatalMessage('email1_empty'); - } // END - if + } // Is the confirmation empty? if (empty($email2)) { // Add a message to the response $responseInstance->addFatalMessage('email2_empty'); - } // END - if + } // Abort here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); diff --git a/framework/main/classes/filter/validator/class_PasswordValidatorFilter.php b/framework/main/classes/filter/validator/class_PasswordValidatorFilter.php index 1e2b2264..d910bdf7 100644 --- a/framework/main/classes/filter/validator/class_PasswordValidatorFilter.php +++ b/framework/main/classes/filter/validator/class_PasswordValidatorFilter.php @@ -87,13 +87,13 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable { if (empty($password1)) { // Add a message to the response $responseInstance->addFatalMessage('pass1_empty'); - } // END - if + } // Is the confirmation empty? if (empty($password2)) { // Add a message to the response $responseInstance->addFatalMessage('pass2_empty'); - } // END - if + } // Abort here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); diff --git a/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php b/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php index ccb2f196..97eb61df 100644 --- a/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php +++ b/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php @@ -141,7 +141,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable { if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) { // This username is still available $alreadyTaken = false; - } // END - if + } // Return the result return $alreadyTaken; diff --git a/framework/main/classes/images/png/class_PngImage.php b/framework/main/classes/images/png/class_PngImage.php index 3189809c..3d41351a 100644 --- a/framework/main/classes/images/png/class_PngImage.php +++ b/framework/main/classes/images/png/class_PngImage.php @@ -82,7 +82,7 @@ class PngImage extends BaseImage { if (FrameworkBootstrap::isReadableFile($cacheFile)) { // Remove it unlink($cacheFile->getPathname()); - } // END - if + } // Finish the image and send it to a cache file imagepng($this->getImageResource(), $cacheFile->getPathname(), 9, PNG_ALL_FILTERS); diff --git a/framework/main/classes/mailer/class_BaseMailer.php b/framework/main/classes/mailer/class_BaseMailer.php index 4c71822b..2715763a 100644 --- a/framework/main/classes/mailer/class_BaseMailer.php +++ b/framework/main/classes/mailer/class_BaseMailer.php @@ -176,7 +176,7 @@ abstract class BaseMailer extends BaseFrameworkSystem { if ((!empty($templateName)) && ($this->isGenericArrayElementSet('recipients', $templateName, 'generic', 'subject'))) { // Then use it $subjectLine = $this->getGenericArrayElement('recipients', $templateName, 'generic', 'subject'); - } // END - if + } // Return it return $subjectLine; diff --git a/framework/main/classes/mailer/debug/class_DebugMailer.php b/framework/main/classes/mailer/debug/class_DebugMailer.php index c73e3716..a1e58a51 100644 --- a/framework/main/classes/mailer/debug/class_DebugMailer.php +++ b/framework/main/classes/mailer/debug/class_DebugMailer.php @@ -101,7 +101,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { foreach ($recipientList['config_vars'] as $variable => $dummy) { // Load the config value and set it $templateInstance->assignConfigVariable($variable); - } // END - if + } // Now do the same with the values but ask the "value instance" instead! foreach ($recipientList['value_vars'] as $variable => $dummy) { @@ -109,7 +109,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { if (!isset($recipientList['values'][$variable])) { // Throw exception throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if + } // Get the field from the value instance $fieldValue = $recipientList['values'][$variable]->getField($variable); diff --git a/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php b/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php index 6499f576..e166dcae 100644 --- a/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php +++ b/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php @@ -78,7 +78,7 @@ class McryptStream extends BaseCryptoStream implements EncryptableStream { if (is_null($key)) { // None provided $key = $this->getRngInstance()->generateKey(); - } // END - if + } // Add some "payload" to the string switch ($this->getRngInstance()->randomNumber(0, 8)) { @@ -142,7 +142,7 @@ class McryptStream extends BaseCryptoStream implements EncryptableStream { if (is_null($key)) { // Generate (default) key $key = $this->getRngInstance()->generateKey(); - } // END - if + } // Decrypt the string $payloadString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); diff --git a/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php b/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php index 11d0f95f..12489892 100644 --- a/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php +++ b/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php @@ -80,7 +80,7 @@ class OpenSslStream extends BaseCryptoStream implements EncryptableStream { if (is_null($key)) { // None provided $key = $this->getRngInstance()->generateKey(); - } // END - if + } // Add some "payload" to the string switch ($this->getRngInstance()->randomNumber(0, 8)) { @@ -147,7 +147,7 @@ class OpenSslStream extends BaseCryptoStream implements EncryptableStream { if (is_null($key)) { // Generate (default) key $key = $this->getRngInstance()->generateKey(); - } // END - if + } // Decrypt the string $payloadString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); diff --git a/framework/main/exceptions/class_FrameworkException.php b/framework/main/exceptions/class_FrameworkException.php index b63ee64a..d7bbe1c4 100644 --- a/framework/main/exceptions/class_FrameworkException.php +++ b/framework/main/exceptions/class_FrameworkException.php @@ -66,7 +66,7 @@ abstract class FrameworkException extends ReflectionException { // End here exit(); - } // END - if + } // Should we log exceptions? (bad implementation) if (defined('LOG_EXCEPTIONS')) { @@ -77,7 +77,7 @@ abstract class FrameworkException extends ReflectionException { $message, $this->getHexCode() )); - } // END - if + } } /** @@ -128,12 +128,12 @@ abstract class FrameworkException extends ReflectionException { // Add only non-array elements if (!is_array($debug)) { $info .= $debug . ', '; - } // END - if + } } // END - foreach // Remove last chars (commata, space) $info = substr($info, 0, -2); - } // END - if + } // Prepare argument infos $info = '' . $info . ''; @@ -142,17 +142,17 @@ abstract class FrameworkException extends ReflectionException { $file = 'Unknown file'; if (isset($dbgInfo['file'])) { $file = basename($dbgInfo['file']); - } // END - if + } // Line detection $line = 'Unknown line'; if (isset($dbgInfo['line'])) { $line = 'line ' . $dbgInfo['line']; - } // END - if + } // The message $dbgMsg .= "\t at ".$dbgIndex." ".$file." (".$line.") -> ".$dbgInfo['function'].'('.$info.")
\n"; - } // END - if + } // Add end-message $dbgMsg .= "Debug backtrace end
\n"; diff --git a/framework/main/exceptions/main/class_UnsupportedOperationException.php b/framework/main/exceptions/main/class_UnsupportedOperationException.php index 3cebaf5f..54952640 100644 --- a/framework/main/exceptions/main/class_UnsupportedOperationException.php +++ b/framework/main/exceptions/main/class_UnsupportedOperationException.php @@ -45,7 +45,7 @@ class UnsupportedOperationException extends FrameworkException { if ((isset($classArray[2])) && ($classArray[2] instanceof FrameworkInterface)) { // Get the class name $extraClassName = $classArray[2]->__toString(); - } // END - if + } // Add a message around the missing class $message = sprintf('[%s:%d] Method %s() is unsupported or should not be called. extraInstance=%s', diff --git a/framework/main/exceptions/xml/class_InvalidXmlNodeException.php b/framework/main/exceptions/xml/class_InvalidXmlNodeException.php index 9d437a7f..bbeb43dc 100644 --- a/framework/main/exceptions/xml/class_InvalidXmlNodeException.php +++ b/framework/main/exceptions/xml/class_InvalidXmlNodeException.php @@ -40,7 +40,7 @@ class InvalidXmlNodeException extends FrameworkException { $attributes = 'None'; if ((is_array($classArray[2])) && (count($classArray[2]) > 0)) { $attributes = implode(', ', $classArray[2]); - } // END - if + } // Construct our message $message = sprintf('[%s:%d] Invalid XML node found: %s, attributes: %s.', diff --git a/framework/main/middleware/compressor/class_CompressorChannel.php b/framework/main/middleware/compressor/class_CompressorChannel.php index 09d01537..798f6e48 100644 --- a/framework/main/middleware/compressor/class_CompressorChannel.php +++ b/framework/main/middleware/compressor/class_CompressorChannel.php @@ -98,19 +98,19 @@ class CompressorChannel extends BaseMiddleware implements Registerable { if (is_null($tempInstance)) { // Then skip to the next one continue; - } // END - if + } // Set the compressor $compressorInstance->setCompressor($tempInstance); // No more searches required because we have found a valid compressor stream break; - } // END - if + } } // END - while // Close the directory $directoryInstance->closeDirectory(); - } // END - if + } // Check again if there is a compressor if ( @@ -121,7 +121,7 @@ class CompressorChannel extends BaseMiddleware implements Registerable { // Set the null compressor handler. This should not be configureable! // @TODO Is there a configurable fall-back compressor needed, or is NullCompressor okay? $compressorInstance->setCompressor(ObjectFactory::createObjectByName('Org\Mxchange\CoreFramework\Compressor\Null\NullCompressor')); - } // END - if + } // Return the compressor instance return $compressorInstance; diff --git a/framework/main/middleware/debug/class_DebugMiddleware.php b/framework/main/middleware/debug/class_DebugMiddleware.php index 3a7913b3..326a692d 100644 --- a/framework/main/middleware/debug/class_DebugMiddleware.php +++ b/framework/main/middleware/debug/class_DebugMiddleware.php @@ -89,7 +89,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { if ($isInitialized === true) { // Then set class name $debugInstance->getOutputInstance()->setLoggerClassName($className); - } // END - if + } // Return instance return $debugInstance; diff --git a/framework/main/middleware/io/class_FileIoHandler.php b/framework/main/middleware/io/class_FileIoHandler.php index 7cd6e762..55e47eb4 100644 --- a/framework/main/middleware/io/class_FileIoHandler.php +++ b/framework/main/middleware/io/class_FileIoHandler.php @@ -117,7 +117,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler { if ($objectInstance instanceof FrameworkInterface) { // Then use this $className = $objectInstance->__toString(); - } // END - if + } // Prepare output array $dataArray = array( diff --git a/framework/main/third_party/api/wernisportal/class_WernisApi.php b/framework/main/third_party/api/wernisportal/class_WernisApi.php index a37e7b11..7d6dceec 100644 --- a/framework/main/third_party/api/wernisportal/class_WernisApi.php +++ b/framework/main/third_party/api/wernisportal/class_WernisApi.php @@ -1,427 +1,2 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Out-dated since 0.6-BETA - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WernisApi extends BaseFrameworkSystem { - /** - * Static base API URL - */ - private static $apiUrl = 'https://www.wds66.com/api/'; - - /** - * API Wernis amount - */ - private $wernis_amount = 0; - - /** - * API username - */ - private $w_id = 0; - - /** - * API Wernis password (not account password!) - */ - private $w_md5 = ''; - - /** - * Nickname of the user - */ - private $w_nick = ''; - - /** - * Wernis amount of the user - */ - private $w_amount = 0; - - /** - * Array with status informations - */ - private $statusArray = array(); - - /** - * Status for 'okay' - */ - private $statusOkay = 'OK'; - - /** - * Protected constructor - * - * @return void - */ - private function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this API class - * - * @param $configArray Configuration array - * @return $apiInstance An instance of this API class - */ - public static final function createWernisApi (array $configArray) { - // Create a new instance - $apiInstance = new WernisApi(); - - // If not an api_url is given (e.g. on local development system) - if (!isset($configArray['api_url'])) { - // ... then set the productive URL - $configArray['api_url'] = self::$apiUrl; - } - - // Konfiguration uebertragen - $apiInstance->setCoonfigArray($configArray); - - // Return the instance - return $apiInstance; - } - - /** - * Setter for gamer data - * - * @param $w_id Username (id) of the gamer - * @param $w_pwd Clear password of the gamer - * @return void - */ - public function setUser (int $w_id, string $w_pwd) { - // Set username (id) - $this->w_id = $w_id; - - // Hash clear password and set it - $this->w_md5 = md5($w_pwd); - } - - /************************************************ - * The following methods are not yet rewritten! * - ************************************************/ - - public function einziehen (int $amount) { - // amount auf Gueltigkeit pruefen - if ($amount < $this->config['mineinsatz']) { - $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); - return false; - } - - // Abfrage senden - return $this->executeWithdraw($amount); - } - - public function verschicken (int $amount) { - // amount auf Gueltigkeit pruefen - if ($amount < $this->config['mineinsatz']) { - $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); - return false; - } - - // Abfrage senden - return $this->executePayout($amount); - } - - // Script abbrechen mit Zurueck-Buttom - public function ende () { - global $_CONFIG; - include 'templates/zurueck.html'; - include 'templates/fuss.html'; - exit(); - } - - // Fehlermeldung ausgeben und beenden - public function error () { - print "
Fehler im Spiel: ".$this->getErrorMessage()."

\n"; - $this->ende(); - } - - // Sets a status message and code - public function setStatusMessage (string $msg, string $status) { - $this->statusArray['message'] = $msg; - $this->statusArray['status'] = $status; - } - - // Get the status message - public function getErrorMessage () { - if (isset($this->statusArray['message'])) { - // Use raw message - return $this->statusArray['message']; - } else { - // Fall-back to status - return sprintf('Fehler-Code %s ist keiner Nachricht zugewiesen.', $this->getErrorCode()); - } - } - - // Get the status code - public function getErrorCode () { - if (isset($this->statusArray['status'])) { - // Use raw message - return $this->statusArray['status']; - } else { - // Something bad happend - return 'unknown'; - } - } - - // Sends out a request to the API and returns it's result - private function sendRequest (string $scriptName, array $requestData = []) { - // Is the requestData an array? - if (!is_array($requestData)) { - // Then abort here! - return array( - 'status' => 'failed_general', - 'message' => 'API-Daten in config sind ungültig!' - ); - } - - // Is the API id and MD5 hash there? - if ((empty($this->config['wernis_api_id'])) || (empty($this->config['wernis_api_key']))) { - // Abort here... - return array( - 'status' => 'failed_general', - 'message' => 'API-Daten in config.php sind leer!' - ); - } - - // Construct the request string - $requestString = $this->config['api_url'] . $scriptName . '?api_id=' . $this->config['wernis_api_id'] . '&api_key='.$this->config['wernis_api_key']; - foreach ($requestData as $key => $value) { - $requestString .= '&' . $key . '=' . $value; - } - - // Get the raw response from the lower function - $response = $this->sendRawRequest($requestString); - - // Check the response header if all is fine - if (strpos($response[0], '200') === false) { - // Something bad happend... :( - return array( - 'status' => 'request_error', - 'message' => sprintf('Servermeldung %s von WDS66-API erhalten.', $response[0]) - ); - } - - // All (maybe) fine so remove the response header from server - for ($idx = (count($response) - 1); $idx > 1; $idx--) { - $line = trim($response[$idx]); - if (!empty($line)) { - $response = $line; - break; - } - } - - // Prepare the returning result for higher functions - if (substr($response, 0, 1) == '&') { - // Remove the leading & (which can be used in Flash) - $response = substr($response, 1); - } - - // Bring back the response - $data = explode('=', $response); - - // Default return array (should not stay empty) - $return = array(); - - // We use only the first two entries (which shall be fine) - if ($data[0] === 'error') { - // The request has failed... :( - switch ($data[1]) { - case '404': // Invalid API ID - case 'AUTH': // Authorization has failed - $return = array( - 'status' => 'auth_failed', - 'message' => 'API-Daten scheinen nicht zu stimmen! (Access Denied)' - ); - break; - - case 'LOCKED': // User account is locked! - case 'PASS': // Bad passphrase entered - case 'USER': // Missing account or invalid password - $return = array( - 'status' => 'user_failed', - 'message' => 'Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben.' - ); - break; - - case 'OWN': // Transfer to own account - $return = array( - 'status' => 'own_failed', - 'message' => 'Du darfst dein eigenes Spiel leider nicht spielen.' - ); - break; - - case 'AMOUNT': // Amount is depleted - $return = array( - 'status' => 'amount_failed', - 'message' => 'Dein Guthaben reicht nicht aus, um das Spiel zu spielen.' - ); - break; - - case 'AMOUNT-SEND': // API amount is depleted - $return = array( - 'status' => 'api_amount_failed', - 'message' => 'Nicht genügend Guthaben auf dem API-Account.' - ); - break; - - default: // Unknown error (maybe new?) - $return = array( - 'status' => 'request_failed', - 'message' => sprintf('Unbekannter Fehler %s von API erhalten.', $data[1]) - ); - break; - } - } else { - // All fine here - $return = array( - 'status' => $this->statusOkay, - 'response' => $response - ); - } - - // Return the result - return $return; - } - - // Widthdraw this amount - private function executeWithdraw (int $amount) { - // First all fails... - $result = false; - - // Prepare the purpose - $purpose = "\"Bube oder Dame\"-Einsatz gesetzt."; - - // Prepare the request data - $requestData = array( - 'sub_request' => 'receive', - 't_uid' => $this->w_id, - 't_md5' => $this->w_md5, - 'r_uid' => (int) $this->config['wernis_refid'], - 'amount' => (int) $amount, - 'purpose' => urlencode(base64_encode($purpose)) - ); - - // Return the result from the lower functions - $return = $this->sendRequest('book.php', $requestData); - - if ($return['status'] == $this->statusOkay) { - // All fine! - $result = true; - } else { - // Status failture text - $this->setStatusMessage($return['message'], $return['status']); - } - - // Return result - return $result; - } - - // Payout this amount - private function executePayout (int $amount) { - // First all fails... - $result = false; - - // Prepare the purpose - $purpose = "\"Bube oder Dame\"-Gewinn erhalten."; - - // Prepare the request data - $requestData = array( - 'sub_request' => 'send', - 't_uid' => $this->w_id, - 't_md5' => $this->w_md5, - 'r_uid' => (int) $this->config['wernis_refid'], - 'amount' => (int) $amount, - 'purpose' => urlencode(base64_encode($purpose)) - ); - - // Return the result from the lower functions - $return = $this->sendRequest("book.php", $requestData); - - if ($return['status'] == $this->statusOkay) { - // All fine! - $result = true; - } else { - // Status failture text - $this->setStatusMessage($return['message'], $return['status']); - } - - // Return result - return $result; - } - - // Send raw GET request - private function sendRawRequest (string $script) { - // Use the hostname from script URL as new hostname - $url = substr($script, 7); - $extract = explode('/', $url); - - // Done extracting the URL :) - $url = $extract[0]; - - // Extract host name - $host = str_replace('http://', '', $url); - if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/')); - - // Generate relative URL - $script = substr($script, (strlen($url) + 7)); - if (substr($script, 0, 1) == '/') $script = substr($script, 1); - - // Open connection - $fp = @fsockopen($host, 80, $errno, $errdesc, 30); - if (!$fp) { - // Failed! - return array('', '', ''); - } - - // Generate request header - $request = "GET /" . trim($script) . " HTTP/1.0\r\n"; - $request .= "Host: " . $host . "\r\n"; - $request .= sprintf("User-Agent: WernisApi/1.0 by Quix0r [Spieler: %d]\r\n\r\n", $this->w_id); - - // Initialize array - $response = array(); - - // Write request - fputs($fp, $request); - - // Read response - while(!feof($fp)) { - array_push($response, trim(fgets($fp, 1024))); - } // END - while - - // Close socket - fclose($fp); - - // Was the request successfull? - if ((!ereg('200 OK', $response[0])) && (empty($response[0]))) { - // Not found / access forbidden - $response = array('', '', ''); - } // END - if - - // Return response - return $response; - } - -} +// @DEPRECATED diff --git a/index.php b/index.php index 46f5db5e..c5ee29a3 100644 --- a/index.php +++ b/index.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException; use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Localization\LanguageSystem; +use Org\Mxchange\CoreFramework\Localization\ManageableLanguage; use Org\Mxchange\CoreFramework\Loader\ClassLoader; use Org\Mxchange\CoreFramework\Generic\FrameworkException; @@ -83,7 +84,7 @@ final class ApplicationEntryPoint { } // Get some instances - $tpl = $configInstance->getConfigEntry('html_template_class'); + $templateClassName = $configInstance->getConfigEntry('html_template_class'); $languageInstance = LanguageSystem::getSelfInstance(); // Initialize template instance here to avoid warnings in IDE @@ -93,11 +94,11 @@ final class ApplicationEntryPoint { $responseInstance = FrameworkBootstrap::getResponseInstance(); // Is the template engine loaded? - if ((class_exists($tpl)) && (is_object($languageInstance))) { + if ((class_exists($templateClassName)) && ($languageInstance instanceof ManageableLanguage)) { // Use the template engine for putting out (nicer look) the message try { // Get the template instance from our object factory - $templateInstance = ObjectFactory::createObjectByName($tpl); + $templateInstance = ObjectFactory::createObjectByName($templateClassName); } catch (FrameworkException $e) { exit(sprintf('[Main:] Could not initialize template engine for reason: %s', $e->getMessage() -- 2.39.5