inc/classes/main/controller/web/class_WebDefaultNewsController.php -text
inc/classes/main/controller/web/class_WebLoginController.php -text
inc/classes/main/controller/web/class_WebLoginFailedController.php -text
+inc/classes/main/controller/web/class_WebLogoutDoneController.php -text
inc/classes/main/controller/web/class_WebRegisterController.php -text
inc/classes/main/criteria/.htaccess -text
inc/classes/main/criteria/class_DataSetCriteria.php -text
inc/classes/main/filter/verifier/.htaccess -text
inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php -text
inc/classes/main/filter/verifier/class_EmailValidatorFilter.php -text
+inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php -text
inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php -text
+inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php -text
inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php -text
inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php -text
inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php -text
$loginInstance->setRequestInstance($requestInstance);
// Encrypt the password
- $loginInstance->encryptPassword('pass');
+ $loginInstance->encryptPassword('passwd');
// Do the login here
$loginInstance->doLogin($requestInstance, $responseInstance);
* @todo Add more filters
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Which login type do we have?
- switch ($this->getConfigInstance()->readConfig('login_type')) {
- case "username": // Login via username
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class'));
- break;
-
- case "email": // Login via email
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_class'));
- break;
-
- default: // Wether username or email is set
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_class'));
- break;
- }
+ // Add username
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_guest_verifier_class'));
// Add password verifier filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('passwd_guest_verifier_class'));
}
}
unset($this->allowedData);
// Unfinished!
- $this->debugInstance();
+ $this->partialStub("Unfinished work.");
+ $this->debugBackTrace();
}
/**
$data = "";
// Detect login method (username or email) and try to get a userinstance
- if (!is_null($requestInstance->getRequestElement('username'))) {
+ if (!is_null($requestInstance->getRequestElement('user'))) {
// Username found!
$method = "createGuestByUsername";
- $data = $requestInstance->getRequestElement('username');
- } elseif (!is_null($requestInstance->getRequestElement('email'))) {
- // Email found!
- $method = "createGuestByEmail";
- $data = $requestInstance->getRequestElement('email');
+ $data = $requestInstance->getRequestElement('user');
}
// Is a method detected?
}
// Is this a guest account?
- if ((($element == "username") || ($alias == "username")) && ($this->getRequestInstance()->getRequestElement($element) == $this->getConfigInstance()->readConfig('guest_login_username'))) {
+ if ((($element == "username") || ($alias == "username")) && ($this->getRequestInstance()->getRequestElement($element) == $this->getConfigInstance()->readConfig('guest_login_user'))) {
// Yes, then set the config entry to guest status
$configEntry = 'user_status_guest';
} // END - if
--- /dev/null
+<?php
+/**
+ * Controller for logout done page
+ *
+ * @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 WebLogoutDoneController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("Controller for login form");
+
+ // 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
+ * @todo Add some filters to this controller
+ */
+ public final static function createWebLogoutDoneController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new WebLogoutDoneController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+
+ // 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) {
+ // Get the command instance from the resolver by sending a request instance to the resolver
+ $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+ // Add more filters by the command
+ $commandInstance->addExtraFilters($this, $requestInstance);
+
+ // Run the pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+
+ // 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]
+?>
} // END - if
// Now, try to get a user or guest instance
- if ($authLogin == $this->getConfigInstance()->readConfig('guest_login_username')) {
+ if ($authLogin == $this->getConfigInstance()->readConfig('guest_login_user')) {
// Guest login!
$userInstance = Guest::createGuestByUserName($authLogin);
} else {
$userName = $requestInstance->getRequestElement('username');
// Does the user name match the guest login?
- if ($userName == $this->getConfigInstance()->readConfig('guest_login_username')) {
+ if ($userName == $this->getConfigInstance()->readConfig('guest_login_user')) {
// Then set the password to the configured password
- $requestInstance->setRequestElement('pass1', $this->getConfigInstance()->readConfig('guest_login_password'));
- $requestInstance->setRequestElement('pass2', $this->getConfigInstance()->readConfig('guest_login_password'));
+ $requestInstance->setRequestElement('pass1', $this->getConfigInstance()->readConfig('guest_login_passwd'));
+ $requestInstance->setRequestElement('pass2', $this->getConfigInstance()->readConfig('guest_login_passwd'));
} // END - if
}
}
--- /dev/null
+<?php
+/**
+ * A concrete filter for validating the guest password. This filter may intercept
+ * the filter chain if no password is given or the password is invalid
+ *
+ * @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 PasswordGuestVerifierFilter extends BaseFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A filter for password verification");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createPasswordGuestVerifierFilter () {
+ // Get a new instance
+ $filterInstance = new PasswordGuestVerifierFilter();
+
+ // 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) {
+ // Get password
+ $password = $requestInstance->getRequestElement('passwd');
+
+ // Is the password still not set?
+ if (is_null($password)) {
+ // Not found in form so stop the filtering process
+ $requestInstance->requestIsValid(false);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('password_unset');
+
+ // Abort here
+ return false;
+ } elseif (empty($password)) {
+ // Password is empty
+ $requestInstance->requestIsValid(false);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('password_empty');
+
+ // Abort here
+ return false;
+ }
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A concrete filter for verfying the guest username. This filter may intercept the
+ * filter chain if no username is given or if the supplied username has an
+ * invalid form. It could also intercept the filter chain if the username was
+ * not found.
+ *
+ * @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 UserGuestVerifierFilter extends BaseFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set part description
+ $this->setObjectDescription("A filter for username verification");
+
+ // Create unique ID number
+ $this->generateUniqueId();
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createUserGuestVerifierFilter () {
+ // Get a new instance
+ $filterInstance = new UserGuestVerifierFilter();
+
+ // 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) {
+ // Get username from request
+ $userName = $requestInstance->getRequestElement('user');
+
+ // Is the username set?
+ if (is_null($userName)) {
+ // Not found in form so stop the filtering process
+ $requestInstance->requestIsValid(false);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('username_unset');
+
+ // Abort here
+ return false;
+ } elseif (empty($userName)) {
+ // Empty field!
+ $requestInstance->requestIsValid(false);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('username_empty');
+
+ // Abort here
+ return false;
+ } elseif (!$this->ifUserGuestIsTaken($userName)) {
+ // Username is already taken
+ $requestInstance->requestIsValid(false);
+
+ // Add a message to the response
+ $responseInstance->addFatalMessage('username_not_found');
+
+ // Abort here
+ return false;
+ }
+
+ // Set the element for compatiblity reasons
+ $requestInstance->setRequestElement('username', $userName);
+ }
+
+ /**
+ * Check wether the username as already been taken
+ *
+ * @param $userName Username to check for existence
+ * @return $alreadyTaken Wether the username has been taken
+ */
+ private function ifUserGuestIsTaken ($userName) {
+ // Default is already taken
+ $alreadyTaken = true;
+
+ // Initialize instance
+ $userInstance = null;
+
+ // Get a registry instance
+ $registry = Registry::getRegistry();
+
+ // Is the user already there?
+ if ($registry->instanceExists('user')) {
+ // Use the instance for checking for the email
+ $userInstance = $registry->getInstance('user');
+ $userInstance->setUserGuest($userName);
+ } else {
+ // If this instance is created then the username *does* exist
+ try {
+ // Get a new instance
+ $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('guest_class'), "createGuestByUsername"), array($userName));
+
+ // Remember this user instance in our registry for later usage
+ $registry->addInstance('user', $userInstance);
+ } catch (UsernameMissingException $e) {
+ // User was not found
+ }
+ }
+
+ // Does the username exist?
+ if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+ // This username is still available
+ $alreadyTaken = false;
+ }
+
+ // Return the result
+ return $alreadyTaken;
+ }
+}
+
+// [EOF]
+?>
* @todo this will send only one cookie out, the first one.
*/
public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = null) {
+ //* DEBUG: */ echo $cookieName."=".$cookieValue."<br />\n";
// Are headers already sent?
if (headers_sent()) {
// Throw an exception here
+ //* DEBUG: */ return;
throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
} // END - if
// CFG: RULES-ACCEPTED-CLASS
$cfg->setConfigEntry('rules_accepted_class', "RulesAcceptedFilter");
-// CFG: USERNAME-VERIFIER
+// CFG: USERNAME-VERIFIER-CLASS
$cfg->setConfigEntry('username_verifier_class', "UserNameVerifierFilter");
+// CFG: USER-GUEST-VERIFIER-CLASS
+$cfg->setConfigEntry('user_guest_verifier_class', "UserGuestVerifierFilter");
+
// CFG: EMAIL-VERIFIER
$cfg->setConfigEntry('email_verifier_class', "EmailVerifierFilter");
// CFG: PASSWORD-VERIFIER-CLASS
$cfg->setConfigEntry('password_verifier_class', "PasswordVerifierFilter");
+// CFG: PASSWD-GUEST-VERIFIER-CLASS
+$cfg->setConfigEntry('passwd_guest_verifier_class', "PasswordGuestVerifierFilter");
+
// CFG: EMAIL-CHANGE-CLASS
$cfg->setConfigEntry('email_change_class', "EmailChangeFilter");
// At least 5.1.0 is required for this!
if (version_compare(phpversion(), "5.1.0")) {
@date_default_timezone_set($zone);
- }
+ } // END - if
}
/**
// Base path is already added
$fqfn = $inc;
}
- }
+ } // END - if
// Include them all here
require($fqfn);
}
- }
+ } // END - if
}
/**
// Debug message
if ((defined('DEBUG_CONFIG')) || (defined('DEBUG_ALL'))) {
echo "[".__METHOD__."] Configuration entry ".$cfgEntry." requested.<br />\n";
- }
+ } // END - if
// Return the requested value
return $this->config[$cfgEntry];
if (empty($cfgEntry)) {
// Entry is empty
throw new ConfigEntryIsEmptyException($this, self::EXCEPTION_CONFIG_ENTRY_IS_EMPTY);
- }
+ } // END - if
// Set the configuration value
$this->config[$cfgEntry] = $cfgValue;