From 75552231db513fd6657bdb232c5f3109aaa605d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 20 Jun 2008 16:10:03 +0000 Subject: [PATCH] Simple exception handler and error handler added, profile update added with stubs --- .gitattributes | 8 ++ application/ship-simu/exceptions.php | 31 +++- application/ship-simu/loader.php | 32 +---- .../class_WebShipsimuGuestLoginCommand.php | 10 ++ .../web/class_WebShipsimuProfileCommand.php | 135 ++++++++++++++++++ .../web/class_WebShipsimuRegisterCommand.php | 10 ++ .../web/class_WebShipsimuUserLoginCommand.php | 10 ++ .../cabines/ship/class_EconomyCabin.php | 7 - .../extended/cabines/ship/class_LowCabin.php | 7 - .../cabines/ship/class_LuxuryCabin.php | 7 - .../cabines/ship/class_PremierCabin.php | 7 - .../extended/decks/cargo/class_CarDeck.php | 7 - .../extended/decks/cargo/class_TrainDeck.php | 7 - .../extended/decks/cargo/class_TruckDeck.php | 7 - application/ship-simu/starter.php | 14 +- .../exceptions/class_FrameworkException.php | 52 +++++++ .../database/general/class_SqlException.php | 4 +- .../io/class_FileIsMissingException.php | 42 ++++++ .../io/class_FileReadProtectedException.php | 42 ++++++ .../class_ConfigEntryIsEmptyException.php | 2 +- .../class_ConfigEntryNotFoundException.php | 6 +- .../main/class_FatalErrorException.php | 39 +++++ .../interfaces/commands/class_Commandable.php | 8 ++ .../main/class_BaseFrameworkSystem.php | 4 +- .../commands/web/class_WebDoFormCommand.php | 11 ++ .../commands/web/class_WebHomeCommand.php | 10 ++ .../web/class_WebLoginAreaCommand.php | 19 ++- .../commands/web/class_WebLoginCommand.php | 10 ++ .../web/class_WebLoginFailedCommand.php | 10 ++ .../web/class_WebLogoutDoneCommand.php | 10 ++ .../commands/web/class_WebRegisterCommand.php | 10 ++ .../form/class_WebDoFormController.php | 13 +- .../form/class_WebLoginAreaController.php | 107 ++++++++++++++ inc/classes/main/filter/change/.htaccess | 1 + .../filter/change/class_EmailChangeFilter.php | 72 ++++++++++ .../change/class_PasswordChangeFilter.php | 72 ++++++++++ .../main/helper/web/class_WebFormHelper.php | 38 ++--- .../io/class_FrameworkFileInputPointer.php | 12 +- .../main/template/class_TemplateEngine.php | 24 ++-- inc/config.php | 6 + templates/de/code/emergency_exit.ctp | 2 +- 41 files changed, 789 insertions(+), 136 deletions(-) create mode 100644 application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php create mode 100644 inc/classes/exceptions/io/class_FileIsMissingException.php create mode 100644 inc/classes/exceptions/io/class_FileReadProtectedException.php create mode 100644 inc/classes/exceptions/main/class_FatalErrorException.php create mode 100644 inc/classes/main/controller/form/class_WebLoginAreaController.php create mode 100644 inc/classes/main/filter/change/.htaccess create mode 100644 inc/classes/main/filter/change/class_EmailChangeFilter.php create mode 100644 inc/classes/main/filter/change/class_PasswordChangeFilter.php diff --git a/.gitattributes b/.gitattributes index 5364a5e..7a90d3b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -66,6 +66,7 @@ application/ship-simu/main/class_WorksContract.php -text application/ship-simu/main/commands/.htaccess -text application/ship-simu/main/commands/web/.htaccess -text application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php -text +application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php -text application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php -text application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php -text application/ship-simu/main/companies/.htaccess -text @@ -198,7 +199,9 @@ inc/classes/exceptions/helper/class_InvalidFormNameException.php -text inc/classes/exceptions/helper/class_UserInstanceMissingException.php -text inc/classes/exceptions/io/.htaccess -text inc/classes/exceptions/io/class_DirPointerNotOpenedException.php -text +inc/classes/exceptions/io/class_FileIsMissingException.php -text inc/classes/exceptions/io/class_FilePointerNotOpenedException.php -text +inc/classes/exceptions/io/class_FileReadProtectedException.php -text inc/classes/exceptions/io/class_InvalidDataLengthException.php -text inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php -text inc/classes/exceptions/io/class_InvalidMD5ChecksumException.php -text @@ -221,6 +224,7 @@ inc/classes/exceptions/main/class_DimNotFoundInArrayException.php -text inc/classes/exceptions/main/class_EmptyVariableException.php -text inc/classes/exceptions/main/class_ExceptionNotChangedException.php -text inc/classes/exceptions/main/class_ExceptionNotFoundException.php -text +inc/classes/exceptions/main/class_FatalErrorException.php -text inc/classes/exceptions/main/class_GetterNotFoundException.php -text inc/classes/exceptions/main/class_InvalidArrayCountException.php -text inc/classes/exceptions/main/class_InvalidCommandException.php -text @@ -360,6 +364,7 @@ inc/classes/main/controller/default/class_WebLoginController.php -text inc/classes/main/controller/default/class_WebLoginFailedController.php -text inc/classes/main/controller/form/.htaccess -text inc/classes/main/controller/form/class_WebDoFormController.php -text +inc/classes/main/controller/form/class_WebLoginAreaController.php -text inc/classes/main/controller/login/.htaccess -text inc/classes/main/controller/login/class_WebLoginAreaController.php -text inc/classes/main/criteria/.htaccess -text @@ -395,6 +400,9 @@ inc/classes/main/factories/web/class_WebNewsFactory.php -text inc/classes/main/filter/.htaccess -text inc/classes/main/filter/auth/.htaccess -text inc/classes/main/filter/auth/class_UserAuthFilter.php -text +inc/classes/main/filter/change/.htaccess -text +inc/classes/main/filter/change/class_EmailChangeFilter.php -text +inc/classes/main/filter/change/class_PasswordChangeFilter.php -text inc/classes/main/filter/checkboxes/.htaccess -text inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php -text inc/classes/main/filter/class_ -text diff --git a/application/ship-simu/exceptions.php b/application/ship-simu/exceptions.php index 7f3ddca..98989ee 100644 --- a/application/ship-simu/exceptions.php +++ b/application/ship-simu/exceptions.php @@ -22,8 +22,37 @@ * along with this program. If not, see . */ +// Our own exception handler +function __exceptionHandler (FrameworkException $e) { + // Call the app_die() method + ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has been terminated due to a thrown exception: %s: %s. Backtrace:
%s
", + ApplicationHelper::getInstance()->getAppName(), + ApplicationHelper::getInstance()->getAppShortName(), + $e->__toString(), + $e->getMessage(), + $e->getPrintableBackTrace() + )); +} + // Set the new handler -//set_exception_handler('shipsimu_exception_handler'); +set_exception_handler('__exceptionHandler'); + +// Error handler +function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) { + // Construct the message + $message = sprintf("File: %s, Line: %s, Code: %s, Message: %s", + basename($errfile), + $errline, + $errno, + $errstr + ); + + // Throw an exception here + throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR); +} + +// Set error handler +set_error_handler('__errorHandler'); // [EOF] ?> diff --git a/application/ship-simu/loader.php b/application/ship-simu/loader.php index e6cf650..e18c749 100644 --- a/application/ship-simu/loader.php +++ b/application/ship-simu/loader.php @@ -27,35 +27,9 @@ $cfg = FrameworkConfiguration::getInstance(); // Load all classes for the application foreach ($lowerClasses as $class) { - // Try to load the application classes - try { - ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", $cfg->readConfig('application_path'), $cfg->readConfig('app_name'), $class)); - } catch (PathIsNoDirectoryException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path %s for this reason: %s", - $application, - $class, - $e->getMessage() - )); - } catch (PathIsEmptyException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path %s for this reason: %s", - $application, - $class, - $e->getMessage() - )); - } catch (PathReadProtectedException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path %s for this reason: %s", - $application, - $class, - $e->getMessage() - )); - } catch (DirPointerNotOpenedException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path %s for this reason: %s", - $application, - $class, - $e->getMessage() - )); - } -} + // Load the application classes + ClassLoader::getInstance()->loadClasses(sprintf("%s/%s/%s", $cfg->readConfig('application_path'), $cfg->readConfig('app_name'), $class)); +} // END - if // Clean up the global namespace unset($lowerClasses); diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php index 960ba39..60d7fa9 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php @@ -113,6 +113,16 @@ class WebShipsimuGuestLoginCommand extends BaseCommand implements Commandable { $responseInstance->addFatalMessage('failed_user_login'); } } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php new file mode 100644 index 0000000..18adfa0 --- /dev/null +++ b/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php @@ -0,0 +1,135 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebShipsimuProfileCommand extends BaseCommand implements Commandable { + /** + * Filtered request data + */ + private $requestData = array(); + + /** + * Allowed profile data to pass through + */ + private $allowedData = array( + 'pass' => 'pass1', + 'email' => 'email1', + 'surname', + 'family', + 'street', + 'city', + 'zip', + 'icq', + 'jabber', + 'yahoo', + 'aol', + 'msn', + 'rules' + ); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("Registration handling command for Ship-Simu"); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this command and sets the resolver instance + * + * @param $resolverInstance An instance of a command resolver + * @return $commandInstance The created command instance + */ + public final static function createWebShipsimuProfileCommand (CommandResolver $resolverInstance) { + // Get a new instance + $commandInstance = new WebShipsimuProfileCommand(); + + // Set the resolver instance + $commandInstance->setResolverInstance($resolverInstance); + + // Get the controller instance from the resolver (breaks MVC pattern again) + $controllerInstance = $resolverInstance->getControllerInstance(); + + /* @TODO Add some more pre/post filters to the controller */ + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_change_class')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_change_class')); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Make sure only allowed values are comming through + foreach ($this->allowedData as $alias=>$element) { + // Do we have an alias? + if (is_string($alias)) { + // Yes, so use it + $this->requestData[$alias] = $requestInstance->getRequestElement($element); + } else { + // No, default entry + $this->requestData[$element] = $requestInstance->getRequestElement($element); + } + } // END - foreach + + // Remove the array, we don't need it anymore + unset($this->allowedData); + + // Unfinished! + $this->debugInstance(); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Add user auth filter (we don't need an update of the user here because it will be redirected) + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class')); + } +} + +// [EOF] +?> + diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php index 035991d..3958ea5 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php @@ -100,6 +100,16 @@ class WebShipsimuRegisterCommand extends BaseCommand implements Commandable { // Redirect or login after registration $registerInstance->doPostAction(); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php index 6a2ab50..908d1f1 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php @@ -113,6 +113,16 @@ class WebShipsimuUserLoginCommand extends BaseCommand implements Commandable { $responseInstance->addFatalMessage('failed_user_login'); } } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php index e538928..c1d6590 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php @@ -67,13 +67,6 @@ class EconomyCabin extends BaseCabin implements TradeableItem, ConstructableShip public function isTradeable () { return true; } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF] diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php index 335477b..cb8627a 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php @@ -67,13 +67,6 @@ class LowCabin extends BaseCabin implements TradeableItem, ConstructableShipPart public function isTradeable () { return true; } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF] diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php index 8dd7574..195ee8f 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php @@ -67,13 +67,6 @@ class LuxuryCabin extends BaseCabin implements TradeableItem, ConstructableShipP public function isTradeable () { return true; } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF] diff --git a/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php b/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php index d4dfedb..30e573c 100644 --- a/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php +++ b/application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php @@ -64,13 +64,6 @@ class PremierCabin extends BaseCabin implements TradeableItem, ConstructableShip public function isTradeable () { return true; } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF] diff --git a/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php b/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php index c371454..4977d8f 100644 --- a/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php +++ b/application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php @@ -65,13 +65,6 @@ class CarDeck extends BaseDeck implements TradeableItem, ConstructableShipPart { public function isTradeable () { return true; } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF] diff --git a/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php b/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php index b2666fa..20450f7 100644 --- a/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php +++ b/application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php @@ -65,13 +65,6 @@ class TrainDeck extends BaseDeck implements TradeableItem, ConstructableShipPart public function isTradeable () { return true; } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF] diff --git a/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php b/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php index 8c99485..a20bbc2 100644 --- a/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php +++ b/application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php @@ -66,13 +66,6 @@ class TruckDeck extends BaseDeck implements TradeableItem, ConstructableShipPart public function isTradeable () { return true; } - - /** - * Limits this object with an ObjectLimits instance - */ - public function limitObject (ObjectLimits $limitInstance) { - ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!"); - } } // [EOF] diff --git a/application/ship-simu/starter.php b/application/ship-simu/starter.php index dd07fb6..738a628 100644 --- a/application/ship-simu/starter.php +++ b/application/ship-simu/starter.php @@ -46,18 +46,8 @@ if ((empty($app)) || (is_null($app))) { )); } -// Call the entry point method -try { - // Call user function - call_user_func_array(array($app, FrameworkConfiguration::getInstance()->readConfig('entry_method')), array()); -} catch (FrameworkException $e) { - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s has been terminated due to a thrown exception: %s - %s", - $application, - $e->__toString(), - $e->getMessage() - )); -} - +// Call user function +call_user_func_array(array($app, FrameworkConfiguration::getInstance()->readConfig('entry_method')), array()); // [EOF] ?> diff --git a/inc/classes/exceptions/class_FrameworkException.php b/inc/classes/exceptions/class_FrameworkException.php index 2c40396..e74dd5a 100644 --- a/inc/classes/exceptions/class_FrameworkException.php +++ b/inc/classes/exceptions/class_FrameworkException.php @@ -66,6 +66,58 @@ abstract class FrameworkException extends ReflectionException { return $this->backTrace; } + /** + * Getter for printable backtrace + * + * @return $backTrace Backtrace for web pages + */ + public final function getPrintableBackTrace () { + // Get the backtrace + $dbgTrace = $this->getBackTrace(); + + // Taken from de.php.net user comments + $dbgMsg = "
\nDebug backtrace begin:
\n"; + foreach ($dbgTrace as $dbgIndex => $dbgInfo) { + // No info by default + $info = "NULL"; + + // Are there arguments? + if ((isset($dbgInfo['args'])) && (is_array($dbgInfo['args'])) && (isset($dbgInfo['args'][0]))) { + //* DEBUG: */ echo $dbgIndex.":
".htmlentities(print_r($dbgInfo['args'], true))."
"; + $info = ""; + foreach ($dbgInfo['args'] as $debug) { + // Add only non-array elements + if (!is_array($debug)) { + $info .= $debug.", "; + } // END - if + } // END - if + + $info = substr($info, 0, -2); + } // END - if + + // Prepare argument infos + $info = "{$info}"; + + // File detection + $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 + $dbgMsg .= "Debug backtrace end
\n"; + + return $dbgMsg; + } + /** * Returns the name of the thrown exception * diff --git a/inc/classes/exceptions/database/general/class_SqlException.php b/inc/classes/exceptions/database/general/class_SqlException.php index 5cd4385..f7dddab 100644 --- a/inc/classes/exceptions/database/general/class_SqlException.php +++ b/inc/classes/exceptions/database/general/class_SqlException.php @@ -31,11 +31,11 @@ class SqlException extends DatabaseException { */ public function __construct (array $msgArray, $code) { // Construct the message - $message = sprintf("[%s:%d] SQL error detected. Message from database: %s, code: 0x%s.", + $message = sprintf("[%s:%d] SQL error detected. Message from database: %s, code: %s.", $msgArray[0]->__toString(), $this->getLine(), $msgArray[1], - dechex($msgArray[2]) + $this->getHexCode($msgArray[2]) ); // Call parent constructor diff --git a/inc/classes/exceptions/io/class_FileIsMissingException.php b/inc/classes/exceptions/io/class_FileIsMissingException.php new file mode 100644 index 0000000..a319a71 --- /dev/null +++ b/inc/classes/exceptions/io/class_FileIsMissingException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIsMissingException extends FrameworkException { + /** + * The constructor + * + * @param $fqfn Full-qualified file name of (maybe) missing file + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fqfn, $code) { + // Add a message around the missing class + $message = sprintf("The requested file %s is missing.", $fqfn); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_FileReadProtectedException.php b/inc/classes/exceptions/io/class_FileReadProtectedException.php new file mode 100644 index 0000000..c061380 --- /dev/null +++ b/inc/classes/exceptions/io/class_FileReadProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $fileName File which cannot be read from + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fileName, $code) { + // Add a message around the missing class + $message = sprintf("File %s is read-protected. Please set read access rights (CHMOD).", $fileName); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php b/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php index 29efd8f..f441ef4 100644 --- a/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php +++ b/inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php @@ -31,7 +31,7 @@ class ConfigEntryIsEmptyException extends FrameworkException { */ public function __construct (FrameworkConfiguration $class, $code) { // Add a message around the missing class - $message = sprintf("[%s:%d] Leeren Konfigurationseintrag angegeben!", + $message = sprintf("[%s:%d] Empty configuration entry provided!", $class->__toString(), $this->getLine() ); diff --git a/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php index d428331..651e8e0 100644 --- a/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php +++ b/inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php @@ -25,8 +25,8 @@ class ConfigEntryNotFoundException extends FrameworkException { /** * The constructor * - * @param $message Message from the exception - * @param $code Code number for the exception + * @param $classArray Array with class + * @param $code Code number for the exception * @return void */ public function __construct (array $classArray, $code) { @@ -34,7 +34,7 @@ class ConfigEntryNotFoundException extends FrameworkException { $classArray = (array) $classArray; // Add a message around the missing class - $message = sprintf("[%s:%d] Konfigurationseintrag %s nicht gefunden.", + $message = sprintf("[%s:%d] Configuration entry %s not found.", $classArray[0], $this->getLine(), $classArray[1] diff --git a/inc/classes/exceptions/main/class_FatalErrorException.php b/inc/classes/exceptions/main/class_FatalErrorException.php new file mode 100644 index 0000000..b9bc217 --- /dev/null +++ b/inc/classes/exceptions/main/class_FatalErrorException.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FatalErrorException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/interfaces/commands/class_Commandable.php b/inc/classes/interfaces/commands/class_Commandable.php index 76679cb..fa87963 100644 --- a/inc/classes/interfaces/commands/class_Commandable.php +++ b/inc/classes/interfaces/commands/class_Commandable.php @@ -30,6 +30,14 @@ interface Commandable extends FrameworkInterface { * @return void */ function execute (Requestable $requestInstance, Responseable $responseInstance); + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance); } // diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index ade2a9c..9432fa6 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -136,6 +136,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { const EXCEPTION_DEFAUL_CONTROLLER_GONE = 0x034; const EXCEPTION_CLASS_NOT_FOUND = 0x035; const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x036; + const EXCEPTION_FATAL_ERROR = 0x037; + const EXCEPTION_FILE_NOT_FOUND = 0x038; /** * In the super constructor these system classes shall be ignored or else @@ -919,7 +921,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Is the extra message given? if (!empty($message)) { // Then add it as well - $stubMessage .= sprintf(" Message: %s", $message); + $stubMessage .= sprintf(" Message: %s", $message); } // Debug instance is there? diff --git a/inc/classes/main/commands/web/class_WebDoFormCommand.php b/inc/classes/main/commands/web/class_WebDoFormCommand.php index 87bd1d1..79f292a 100644 --- a/inc/classes/main/commands/web/class_WebDoFormCommand.php +++ b/inc/classes/main/commands/web/class_WebDoFormCommand.php @@ -71,6 +71,17 @@ class WebDoFormCommand extends BaseCommand implements Commandable { debug_print_backtrace(); die("Good bye..."); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } + } // [EOF] diff --git a/inc/classes/main/commands/web/class_WebHomeCommand.php b/inc/classes/main/commands/web/class_WebHomeCommand.php index 1deddf2..704ee5f 100644 --- a/inc/classes/main/commands/web/class_WebHomeCommand.php +++ b/inc/classes/main/commands/web/class_WebHomeCommand.php @@ -109,6 +109,16 @@ class WebHomeCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the response class $templateInstance->transferToResponse($responseInstance); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php index ac26849..146623d 100644 --- a/inc/classes/main/commands/web/class_WebLoginAreaCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginAreaCommand.php @@ -104,6 +104,9 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { // Prepare a template instance $templateInstance = $this->prepareTemplateEngine($appInstance); + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + // Assign all the application's data with template variables $templateInstance->assignApplicationData($appInstance); @@ -128,12 +131,14 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { $templateInstance->loadCodeTemplate($action); // Assign the template with the master template as a content ... ;) + $templateInstance->compileTemplate(); $templateInstance->assignTemplateWithVariable($action, "login_content"); // Load main template $templateInstance->loadCodeTemplate("login_main"); // Assign the main template with the master template as a content ... ;) + $templateInstance->compileTemplate(); $templateInstance->assignTemplateWithVariable("login_main", "content"); // Load the master template @@ -142,17 +147,25 @@ class WebLoginAreaCommand extends BaseCommand implements Commandable { // Set title $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($action."_title")); - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - // ... and all variables. This should be merged together in a pattern // to make things easier. A cache mechanism should be added between // these two calls to cache compiled templates. + //$templateInstance->debugInstance(); $templateInstance->compileVariables(); // Get the content back from the template engine and put it in the response class $templateInstance->transferToResponse($responseInstance); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/inc/classes/main/commands/web/class_WebLoginCommand.php b/inc/classes/main/commands/web/class_WebLoginCommand.php index 64cba33..b5a89ac 100644 --- a/inc/classes/main/commands/web/class_WebLoginCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginCommand.php @@ -112,6 +112,16 @@ class WebLoginCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the response class $templateInstance->transferToResponse($responseInstance); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/inc/classes/main/commands/web/class_WebLoginFailedCommand.php b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php index 04b02c1..c7baa75 100644 --- a/inc/classes/main/commands/web/class_WebLoginFailedCommand.php +++ b/inc/classes/main/commands/web/class_WebLoginFailedCommand.php @@ -112,6 +112,16 @@ class WebLoginFailedCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the response class $templateInstance->transferToResponse($responseInstance); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php index 528f4b5..5c38d06 100644 --- a/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php +++ b/inc/classes/main/commands/web/class_WebLogoutDoneCommand.php @@ -112,6 +112,16 @@ class WebLogoutDoneCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the response class $templateInstance->transferToResponse($responseInstance); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/inc/classes/main/commands/web/class_WebRegisterCommand.php b/inc/classes/main/commands/web/class_WebRegisterCommand.php index f073baa..2a50f5e 100644 --- a/inc/classes/main/commands/web/class_WebRegisterCommand.php +++ b/inc/classes/main/commands/web/class_WebRegisterCommand.php @@ -113,6 +113,16 @@ class WebRegisterCommand extends BaseCommand implements Commandable { // Get the content back from the template engine and put it in the response class $templateInstance->transferToResponse($responseInstance); } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @return void + */ + function addExtraFilters (Controller $controllerInstance) { + // Empty for now + } } // [EOF] diff --git a/inc/classes/main/controller/form/class_WebDoFormController.php b/inc/classes/main/controller/form/class_WebDoFormController.php index db7cfb4..1856dd3 100644 --- a/inc/classes/main/controller/form/class_WebDoFormController.php +++ b/inc/classes/main/controller/form/class_WebDoFormController.php @@ -72,8 +72,17 @@ class WebDoFormController extends BaseController implements Controller { // Get command instance from resolver $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); - // Execute *very* generic pre filters - $this->executePreFilters($requestInstance, $responseInstance); + // Try to add more filters by the command + $commandInstance->addExtraFilters($this); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed_url'); + } // Is the request still valid? Post filters shall only be executed of // the request is valid diff --git a/inc/classes/main/controller/form/class_WebLoginAreaController.php b/inc/classes/main/controller/form/class_WebLoginAreaController.php new file mode 100644 index 0000000..7ea4e50 --- /dev/null +++ b/inc/classes/main/controller/form/class_WebLoginAreaController.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebLoginAreaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("Default controller with news"); + + // Create unique ID number + $this->generateUniqueId(); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function createWebLoginAreaController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new WebLoginAreaController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // User auth filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class')); + + // User update filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_class')); + + // News fetcher filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_class')); + + // News proccess/display-preparation + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class')); + + /* @TODO: Add some filters to this controller */ + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed_url'); + } + + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolvCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/change/.htaccess b/inc/classes/main/filter/change/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/filter/change/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/change/class_EmailChangeFilter.php b/inc/classes/main/filter/change/class_EmailChangeFilter.php new file mode 100644 index 0000000..8005cc9 --- /dev/null +++ b/inc/classes/main/filter/change/class_EmailChangeFilter.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmailChangeFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("A filter for email changes"); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createEmailChangeFilter () { + // Get a new instance + $filterInstance = new EmailChangeFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/filter/change/class_PasswordChangeFilter.php b/inc/classes/main/filter/change/class_PasswordChangeFilter.php new file mode 100644 index 0000000..353ad72 --- /dev/null +++ b/inc/classes/main/filter/change/class_PasswordChangeFilter.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordChangeFilter extends BaseFrameworkSystem implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("A filter for password change"); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createPasswordChangeFilter () { + // Get a new instance + $filterInstance = new PasswordChangeFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php index 5debdda..1369fe4 100644 --- a/inc/classes/main/helper/web/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/class_WebFormHelper.php @@ -134,7 +134,7 @@ class WebFormHelper extends BaseHelper { if (($this->formOpened === false) && ($formName === false)) { // Thrown an exception throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID); - } + } // END - if // Close the form is default $formContent = ""; @@ -172,7 +172,7 @@ class WebFormHelper extends BaseHelper { if ($this->groupOpened === true) { // Then automatically close it here $this->addFormGroup("", ""); - } + } // END - if /* @TODO Add some unique PIN here to bypass problems with some browser and/or extensions */ // Simply close it @@ -197,7 +197,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Generate the content $inputContent = sprintf("", @@ -239,7 +239,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Generate the content $inputContent = sprintf("", @@ -266,7 +266,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Generate the content $inputContent = sprintf("", @@ -292,7 +292,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Set wether the check box is checked... $checked = " checked=\"checked\""; @@ -322,7 +322,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, "reset"), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Generate the content $inputContent = sprintf("", @@ -347,7 +347,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, "submit"), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Generate the content $inputContent = sprintf("", @@ -374,13 +374,13 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw exception here throw new FormClosedException(array($this, $groupName), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // At least the group name should be set if ((empty($groupName)) && ($this->groupOpened === false)) { // Throw exception here throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } + } // END - if // Initialize content with closing div by default $content = " \n"; @@ -411,7 +411,7 @@ class WebFormHelper extends BaseHelper { if ($this->subGroupOpened === true) { // Close it here $this->addFormSubGroup("", ""); - } + } // END - if // Add the content $this->addContent($content); @@ -422,7 +422,7 @@ class WebFormHelper extends BaseHelper { // All call it again if the group name is not empty if (!empty($groupName)) { $this->addFormGroup($groupName, $groupText); - } + } // END - if } } @@ -442,13 +442,13 @@ class WebFormHelper extends BaseHelper { if ($this->groupOpened === false) { // Throw exception here throw new FormGroupClosedException(array($this, $subGroupName), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP); - } + } // END - if // At least the sub group name should be set if ((empty($subGroupName)) && ($this->subGroupOpened === false)) { // Throw exception here throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } + } // END - if // Initialize content with closing div by default $content = " \n"; @@ -485,7 +485,7 @@ class WebFormHelper extends BaseHelper { // All call it again if sub group name is not empty if (!empty($subGroupName)) { $this->addFormSubGroup($subGroupName, $subGroupText); - } + } // END - if } } @@ -503,7 +503,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Set the block type $block = "div"; @@ -536,13 +536,13 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === false) { // Throw an exception throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM); - } + } // END - if // Is a group open? if ($this->groupOpened === true) { // Then automatically close it here $this->addFormGroup("", ""); - } + } // END - if // Generate the content $inputContent = sprintf("
@@ -687,7 +687,7 @@ class WebFormHelper extends BaseHelper { if ($this->formOpened === true) { // Throw an exception throw new FormOpenedException ($this, self::EXCEPTION_OPENED_FORM); - } + } // END - if // Send content to template engine $this->getTemplateInstance()->assignVariable($this->formName, $this->getContent()); diff --git a/inc/classes/main/io/class_FrameworkFileInputPointer.php b/inc/classes/main/io/class_FrameworkFileInputPointer.php index 25c77cb..fe6b058 100644 --- a/inc/classes/main/io/class_FrameworkFileInputPointer.php +++ b/inc/classes/main/io/class_FrameworkFileInputPointer.php @@ -76,17 +76,23 @@ class FrameworkFileInputPointer extends BaseFrameworkSystem { */ public final static function createFrameworkFileInputPointer ($fileName) { // Some pre-sanity checks... - if (is_null($fileName)) { + if ((is_null($fileName)) || (empty($fileName))) { // No filename given throw new FileIsEmptyException(null, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!file_exists($fileName)) { + // File does not exist! + throw new FileIsMissingException($fileName, self::EXCEPTION_FILE_NOT_FOUND); + } elseif (!is_readable($fileName)) { + // File does not exist! + throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); } // Try to open a handler $filePointer = @fopen($fileName, 'rb'); - if (($filePointer === null) || ($filePointer === false)) { + if ((is_null($filePointer)) || ($filePointer === false)) { // Something bad happend throw new FilePointerNotOpenedException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID); - } + } // END - if // Create new instance $pointerInstance = new FrameworkFileInputPointer(); diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index 7bbf2e1..2a828c0 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -600,8 +600,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate foreach ($variableMatches[3] as $key=>$var) { // Try to assign it, empty strings are being ignored $this->assignTemplateVariable($variableMatches[1][$key], $var); - } - } + } // END - foreach + } // END - if } /** @@ -649,6 +649,9 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate // Remember this template for recursion detection // RECURSIVE PROTECTION! $this->loadedTemplates[] = $template; + } catch (FileIsMissingException $e) { + // Even this is not done... :/ + $this->rawTemplates[] = $template; } catch (FilePointerNotOpenedException $e) { // Even this is not done... :/ $this->rawTemplates[] = $template; @@ -752,6 +755,9 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate // Remember this template for recursion detection // RECURSIVE PROTECTION! $this->loadedTemplates[] = $template; + } catch (FileIsMissingException $e) { + // This template was never found. We silently ignore it + unset($this->rawTemplates[$key]); } catch (FilePointerNotOpenedException $e) { // This template was never found. We silently ignore it unset($this->rawTemplates[$key]); @@ -1012,6 +1018,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate } // END - while // Prepare PHP code for eval() command + $evalLength = strlen($eval); $eval = str_replace( "<%php", "\";", str_replace( @@ -1019,14 +1026,11 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate ) ); - // Debug message - if ((defined('DEBUG_EVAL')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command:
%s

\n", - $this->__toString(), - htmlentities($eval) - )); - - // Run the constructed command. This will "compile" all variables in - eval($eval); + // Did something change? + if (strlen($eval) != $eval) { + // Run the constructed command. This will "compile" all variables in + eval($eval); + } // END - if // Set raw template data $this->setRawTemplateData($result); diff --git a/inc/config.php b/inc/config.php index 321d513..131af0a 100644 --- a/inc/config.php +++ b/inc/config.php @@ -197,6 +197,12 @@ $cfg->setConfigEntry('email_verifier_class', "EmailVerifierFilter"); // CFG: PASSWORD-VERIFIER $cfg->setConfigEntry('password_verifier_class', "PasswordVerifierFilter"); +// CFG: EMAIL-CHANGE-CLASS +$cfg->setConfigEntry('email_change_class', "EmailChangeFilter"); + +// CFG: PASSWORD-CHANGE-FILTER +$cfg->setConfigEntry('password_change_class', "PasswordChangeFilter"); + // CFG: CRYPTO-HELPER $cfg->setConfigEntry('crypto_class', "CryptoHelper"); diff --git a/templates/de/code/emergency_exit.ctp b/templates/de/code/emergency_exit.ctp index 406c2b8..152a1bd 100644 --- a/templates/de/code/emergency_exit.ctp +++ b/templates/de/code/emergency_exit.ctp @@ -10,7 +10,7 @@
- Backtrace: + File inclusion backtrace:
$content[backtrace] -- 2.39.5