Simple exception handler and error handler added, profile update added with stubs
authorRoland Häder <roland@mxchange.org>
Fri, 20 Jun 2008 16:10:03 +0000 (16:10 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 20 Jun 2008 16:10:03 +0000 (16:10 +0000)
41 files changed:
.gitattributes
application/ship-simu/exceptions.php
application/ship-simu/loader.php
application/ship-simu/main/commands/web/class_WebShipsimuGuestLoginCommand.php
application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php [new file with mode: 0644]
application/ship-simu/main/commands/web/class_WebShipsimuRegisterCommand.php
application/ship-simu/main/commands/web/class_WebShipsimuUserLoginCommand.php
application/ship-simu/main/structures/extended/cabines/ship/class_EconomyCabin.php
application/ship-simu/main/structures/extended/cabines/ship/class_LowCabin.php
application/ship-simu/main/structures/extended/cabines/ship/class_LuxuryCabin.php
application/ship-simu/main/structures/extended/cabines/ship/class_PremierCabin.php
application/ship-simu/main/structures/extended/decks/cargo/class_CarDeck.php
application/ship-simu/main/structures/extended/decks/cargo/class_TrainDeck.php
application/ship-simu/main/structures/extended/decks/cargo/class_TruckDeck.php
application/ship-simu/starter.php
inc/classes/exceptions/class_FrameworkException.php
inc/classes/exceptions/database/general/class_SqlException.php
inc/classes/exceptions/io/class_FileIsMissingException.php [new file with mode: 0644]
inc/classes/exceptions/io/class_FileReadProtectedException.php [new file with mode: 0644]
inc/classes/exceptions/main/class_ConfigEntryIsEmptyException.php
inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php
inc/classes/exceptions/main/class_FatalErrorException.php [new file with mode: 0644]
inc/classes/interfaces/commands/class_Commandable.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/web/class_WebDoFormCommand.php
inc/classes/main/commands/web/class_WebHomeCommand.php
inc/classes/main/commands/web/class_WebLoginAreaCommand.php
inc/classes/main/commands/web/class_WebLoginCommand.php
inc/classes/main/commands/web/class_WebLoginFailedCommand.php
inc/classes/main/commands/web/class_WebLogoutDoneCommand.php
inc/classes/main/commands/web/class_WebRegisterCommand.php
inc/classes/main/controller/form/class_WebDoFormController.php
inc/classes/main/controller/form/class_WebLoginAreaController.php [new file with mode: 0644]
inc/classes/main/filter/change/.htaccess [new file with mode: 0644]
inc/classes/main/filter/change/class_EmailChangeFilter.php [new file with mode: 0644]
inc/classes/main/filter/change/class_PasswordChangeFilter.php [new file with mode: 0644]
inc/classes/main/helper/web/class_WebFormHelper.php
inc/classes/main/io/class_FrameworkFileInputPointer.php
inc/classes/main/template/class_TemplateEngine.php
inc/config.php
templates/de/code/emergency_exit.ctp

index 5364a5e..7a90d3b 100644 (file)
@@ -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
index 7f3ddca..98989ee 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
+// Our own exception handler
+function __exceptionHandler (FrameworkException $e) {
+       // Call the app_die() method
+       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <strong>%s</strong> (<strong>%s</strong>) has been terminated due to a thrown exception: <strong>%s: <span id=\"debug_exception\">%s</em></strong>. Backtrace: <div id=\"debug_backtrace\">%s</div>",
+               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: <span id=\"debug_file\">%s</span>, Line: <span id=\"debug_line\">%s</span>, Code: <span id=\"debug_code\">%s</span>, Message: <span id=\"debug_message\">%s</span>",
+               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]
 ?>
index e6cf650..e18c749 100644 (file)
@@ -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 <u>%s</u> for this reason: <u>%s</u>",
-                       $application,
-                       $class,
-                       $e->getMessage()
-               ));
-       } catch (PathIsEmptyException $e) {
-               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
-                       $application,
-                       $class,
-                       $e->getMessage()
-               ));
-       } catch (PathReadProtectedException $e) {
-               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
-                       $application,
-                       $class,
-                       $e->getMessage()
-               ));
-       } catch (DirPointerNotOpenedException $e) {
-               ApplicationEntryPoint::app_die(sprintf("[Main:%s] Cannot find application classes in path <u>%s</u> for this reason: <u>%s</u>",
-                       $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);
index 960ba39..60d7fa9 100644 (file)
@@ -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 (file)
index 0000000..18adfa0
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+/**
+ * A command for profile-update handling
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
+
index 035991d..3958ea5 100644 (file)
@@ -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]
index 6a2ab50..908d1f1 100644 (file)
@@ -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]
index e538928..c1d6590 100644 (file)
@@ -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]
index 335477b..cb8627a 100644 (file)
@@ -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]
index 8dd7574..195ee8f 100644 (file)
@@ -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]
index d4dfedb..30e573c 100644 (file)
@@ -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]
index c371454..4977d8f 100644 (file)
@@ -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]
index b2666fa..20450f7 100644 (file)
@@ -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]
index 8c99485..a20bbc2 100644 (file)
@@ -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]
index dd07fb6..738a628 100644 (file)
@@ -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 <strong>%s</strong> has been terminated due to a thrown exception: <strong>%s - %s</strong>",
-               $application,
-               $e->__toString(),
-               $e->getMessage()
-       ));
-}
-
+// Call user function
+call_user_func_array(array($app, FrameworkConfiguration::getInstance()->readConfig('entry_method')), array());
 
 // [EOF]
 ?>
index 2c40396..e74dd5a 100644 (file)
@@ -67,6 +67,58 @@ abstract class FrameworkException extends ReflectionException {
        }
 
        /**
+        * 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 = "<br />\nDebug backtrace begin:<br />\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.": <pre>".htmlentities(print_r($dbgInfo['args'], true))."</pre>";
+                               $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 = "<em id=\"debug_args\">{$info}</em>";
+
+                       // 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 <em id=\"debug_id\">".$dbgIndex."</em> <em id=\"debug_file\">".$file."</em> (<em id=\"debug_line\">".$line."</em>) -&gt; ".$dbgInfo['function']."(".$info.")<br />\n";
+               } // END - if
+               $dbgMsg .= "Debug backtrace end<br />\n";
+
+               return $dbgMsg;
+       }
+
+       /**
         * Returns the name of the thrown exception
         *
         * @return      $toString               The name of the thrown exception
index 5cd4385..f7dddab 100644 (file)
@@ -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: <u>%s</u>, code: <u>0x%s</u>.",
+               $message = sprintf("[%s:%d] SQL error detected. Message from database: <u>%s</u>, code: <u>%s</u>.",
                        $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 (file)
index 0000000..a319a71
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * An exception thrown when a file pointer is not opened
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 <u>%s</u> 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 (file)
index 0000000..c061380
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * An exception thrown when a file is read-protected
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 <u>%s</u> is read-protected. Please set read access rights (CHMOD).", $fileName);
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index 29efd8f..f441ef4 100644 (file)
@@ -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()
                );
index d428331..651e8e0 100644 (file)
@@ -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 <u>%s</u> nicht gefunden.",
+               $message = sprintf("[%s:%d] Configuration entry <u>%s</u> 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 (file)
index 0000000..b9bc217
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/**
+ * An exception thrown when a "fatal" error has been captured by an error handler
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 76679cb..fa87963 100644 (file)
@@ -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);
 }
 
 //
index ade2a9c..9432fa6 100644 (file)
@@ -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: <u>%s</u>", $message);
+                       $stubMessage .= sprintf(" Message: <span id=\"stub_message\">%s</span>", $message);
                }
 
                // Debug instance is there?
index 87bd1d1..79f292a 100644 (file)
@@ -71,6 +71,17 @@ class WebDoFormCommand extends BaseCommand implements Commandable {
                debug_print_backtrace();
                die("</pre>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]
index 1deddf2..704ee5f 100644 (file)
@@ -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]
index ac26849..146623d 100644 (file)
@@ -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]
index 64cba33..b5a89ac 100644 (file)
@@ -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]
index 04b02c1..c7baa75 100644 (file)
@@ -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]
index 528f4b5..5c38d06 100644 (file)
@@ -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]
index f073baa..2a50f5e 100644 (file)
@@ -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]
index db7cfb4..1856dd3 100644 (file)
@@ -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 (file)
index 0000000..7ea4e50
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/**
+ * Controller for login area with news
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..8005cc9
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A filter for detecting email changes
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..353ad72
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A filter for password change detection
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 5debdda..1369fe4 100644 (file)
@@ -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 = "</form>";
@@ -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("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" value=\"%s\" />",
@@ -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("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" value=\"%s\" />",
@@ -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("<input type=\"hidden\" name=\"%s\" value=\"%s\" />",
@@ -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("<input type=\"reset\" class=\"reset_button\" id=\"%s_reset\" value=\"%s\" />",
@@ -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("<input type=\"submit\" class=\"submit_button\" id=\"%s_submit\" name=\"%s_button\" value=\"%s\" />",
@@ -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 = "    </div>\n</div><!-- Group - CLOSE //-->";
@@ -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 = "    </div>\n</div><!-- Sub group- CLOSE //-->";
@@ -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("       <div id=\"form_note\">
@@ -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());
index 25c77cb..fe6b058 100644 (file)
@@ -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();
index 7bbf2e1..2a828c0 100644 (file)
@@ -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: <pre><em>%s</em></pre><br />\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);
index 321d513..131af0a 100644 (file)
@@ -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");
 
index 406c2b8..152a1bd 100644 (file)
@@ -10,7 +10,7 @@
 
        <div id="emergency_exit backtrace_box">
                <div id="backtrace_header">
-                       Backtrace:
+                       File inclusion backtrace:
                </div>
                <div id="backtrace_content">
                        $content[backtrace]