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
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
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
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
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
* 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]
?>
// 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);
$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]
--- /dev/null
+<?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]
+?>
+
// 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]
$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]
public function isTradeable () {
return true;
}
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
public function isTradeable () {
return true;
}
-
- /**
- * Limits this object with an ObjectLimits instance
- */
- public function limitObject (ObjectLimits $limitInstance) {
- ApplicationEntryPoint::app_die("".__METHOD__." reached! Stub!");
- }
}
// [EOF]
));
}
-// 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]
?>
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 = "<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>) -> ".$dbgInfo['function']."(".$info.")<br />\n";
+ } // END - if
+ $dbgMsg .= "Debug backtrace end<br />\n";
+
+ return $dbgMsg;
+ }
+
/**
* Returns the name of the thrown exception
*
*/
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
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
*/
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()
);
/**
* 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) {
$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]
--- /dev/null
+<?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]
+?>
* @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);
}
//
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
// 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?
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]
// 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]
// 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);
$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
// 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]
// 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]
// 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]
// 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]
// 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]
// 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
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
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>";
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
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\" />",
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\" />",
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\" />",
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\"";
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\" />",
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\" />",
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 //-->";
if ($this->subGroupOpened === true) {
// Close it here
$this->addFormSubGroup("", "");
- }
+ } // END - if
// Add the content
$this->addContent($content);
// All call it again if the group name is not empty
if (!empty($groupName)) {
$this->addFormGroup($groupName, $groupText);
- }
+ } // END - if
}
}
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 //-->";
// All call it again if sub group name is not empty
if (!empty($subGroupName)) {
$this->addFormSubGroup($subGroupName, $subGroupText);
- }
+ } // END - if
}
}
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";
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\">
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());
*/
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();
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
}
/**
// 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;
// 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]);
} // END - while
// Prepare PHP code for eval() command
+ $evalLength = strlen($eval);
$eval = str_replace(
"<%php", "\";",
str_replace(
)
);
- // 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);
// 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");
<div id="emergency_exit backtrace_box">
<div id="backtrace_header">
- Backtrace:
+ File inclusion backtrace:
</div>
<div id="backtrace_content">
$content[backtrace]