From: Roland Haeder Date: Mon, 6 Apr 2015 23:59:01 +0000 (+0200) Subject: Added a lot stuff from Ship-Simu for registration page and CAPTCHA, so basicly X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ba738304ef8b9c83445de5ae8fb90bcf41a218ce;p=city.git Added a lot stuff from Ship-Simu for registration page and CAPTCHA, so basicly two pages are "ready": home and register. Signed-off-by: Roland Haeder --- diff --git a/application/city/config.php b/application/city/config.php index eef9f68..40ffebb 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -56,6 +56,12 @@ $cfg->setConfigEntry('default_html_command', 'home'); // CFG: DEFAULT-CITY-HTML-COMMAND $cfg->setConfigEntry('default_city_html_command', 'home'); +// CFG: DEFAULT-HTML-CONTROLLER +$cfg->setConfigEntry('default_html_controller', 'home'); + +// CFG: DEFAULT-CITY-HTML-CONTROLLER +$cfg->setConfigEntry('default_city_html_controller', 'home'); + // CFG: CITY-HTML-CMD-HOME-RESOLVER-CLASS $cfg->setConfigEntry('city_html_cmd_home_resolver_class', 'CityHtmlCommandResolver'); @@ -77,12 +83,144 @@ $cfg->setConfigEntry('news_register_limit', 5); // CFG: CITY-HOME-MENU-CLASS $cfg->setConfigEntry('city_home_menu_class', 'CityHomeMenu'); +// CFG: CITY-REGISTER-MENU-CLASS +$cfg->setConfigEntry('city_register_menu_class', 'CityRegisterMenu'); + // CFG: MENU-TEMPLATE-CLASS $cfg->setConfigEntry('menu_template_class', 'MenuTemplateEngine'); // CFG: MENU-TEMPLATE-EXTENSION $cfg->setConfigEntry('menu_template_extension', '.xml'); +// CFG: HTML-FORM-HELPER +$cfg->setConfigEntry('html_form_helper', 'HtmlFormHelper'); + +// CFG: FORM-ACTION +$cfg->setConfigEntry('form_action', 'index.php?app={?app_short_name?}&command=do_form'); + +// CFG: FORM-METHOD +$cfg->setConfigEntry('form_method', 'post'); + +// CFG: FORM-TARGET +$cfg->setConfigEntry('form_target', '_self'); + +// CFG: REGISTER-REQUIRES-EMAIL +$cfg->setConfigEntry('register_requires_email', 'Y'); + +// CFG: REGISTER-INCLUDES-PROFILE +$cfg->setConfigEntry('register_includes_profile', 'Y'); + +// CFG: REGISTER-PERSONAL-DATA +$cfg->setConfigEntry('register_personal_data', 'Y'); + +// CFG: REGISTER-EMAIL-UNIQUE +$cfg->setConfigEntry('register_email_unique', 'Y'); + +// CFG: PROFILE-INCLUDES-BIRTHDAY +$cfg->setConfigEntry('profile_includes_birthday', 'Y'); + +// CFG: CHAT-ENABLED-ICQ +$cfg->setConfigEntry('chat_enabled_icq', 'Y'); + +// CFG: CHAT-ENABLED-JABBER +$cfg->setConfigEntry('chat_enabled_jabber', 'Y'); + +// CFG: CHAT-ENABLED-YAHOO +$cfg->setConfigEntry('chat_enabled_yahoo', 'Y'); + +// CFG: CHAT-ENABLED-AOL +$cfg->setConfigEntry('chat_enabled_aol', 'Y'); + +// CFG: CHAT-ENABLED-MSN +$cfg->setConfigEntry('chat_enabled_msn', 'Y'); + +// CFG: CITY-REGISTER-CAPTCHA-SECURED +$cfg->setConfigEntry('city_register_captcha_secured', 'Y'); + +// CFG: CITY-USER-LOGIN-CAPTCHA-SECURED +$cfg->setConfigEntry('city_user_login_captcha_secured', 'Y'); + +// CFG: CITY-GUEST-LOGIN-CAPTCHA-SECURED +$cfg->setConfigEntry('city_guest_login_captcha_secured', 'Y'); + +// CFG: CITY-PROFILE-CAPTCHA-SECURED +$cfg->setConfigEntry('city_profile_captcha_secured', 'Y'); + +// CFG: CITY-REFILL-CAPTCHA-SECURED +$cfg->setConfigEntry('city_refill_captcha_secured', 'Y'); + +// CFG: CITY-GOVERNMENT-STARTUP-CAPTCHA-SECURED +$cfg->setConfigEntry('city_government_startup_captcha_secured', 'Y'); + +// CFG: CITY-GOVERNMENT-TRAINING-CAPTCHA-SECURED +$cfg->setConfigEntry('city_government_training_captcha_secured', 'Y'); + +// CFG: CITY-REGISTER-CAPTCHA-CLASS +$cfg->setConfigEntry('city_register_captcha_class', 'GraphicalCodeCaptcha'); + +// CFG: CITY-USER-LOGIN-CAPTCHA-CLASS +$cfg->setConfigEntry('city_user_login_captcha_class', 'GraphicalCodeCaptcha'); + +// CFG: CITY-GUEST-LOGIN-CAPTCHA-CLASS +$cfg->setConfigEntry('city_guest_login_captcha_class', 'GraphicalCodeCaptcha'); + +// CFG: CITY-PROFILE-CAPTCHA-CLASS +$cfg->setConfigEntry('city_profile_captcha_class', 'GraphicalCodeCaptcha'); + +// CFG: CITY-REFILL-CAPTCHA-CLASS +$cfg->setConfigEntry('city_refill_captcha_class', 'GraphicalCodeCaptcha'); + +// CFG: CITY-GOVERNMENT-STARTUP-CAPTCHA-CLASS +$cfg->setConfigEntry('city_government_startup_captcha_class', 'GraphicalCodeCaptcha'); + +// CFG: CITY-GOVERNMENT-TRAINING-CAPTCHA-CLASS +$cfg->setConfigEntry('city_government_training_captcha_class', 'GraphicalCodeCaptcha'); + +// CFG: CAPTCHA-STRING-LENGTH +$cfg->setConfigEntry('captcha_string_length', 5); + +// CFG: CAPTCHA-SEARCH-CHARS +$cfg->setConfigEntry('captcha_search_chars', '+/='); + +// CFG: RANDOM-STRING-LENGTH +$cfg->setConfigEntry('random_string_length', 100); + +// CFG: IMAGE-TEMPLATE-CLASS +$cfg->setConfigEntry('image_template_class', 'ImageTemplateEngine'); + +// CFG: CAPTCHA-ENCRYPT-VALIDATOR-FILTER +$cfg->setConfigEntry('captcha_encrypt_validator_filter', 'CaptchaEncryptFilter'); + +// CFG: CITY-HTML-CMD-DO-FORM-RESOLVER-CLASS +$cfg->setConfigEntry('city_html_cmd_do_form_resolver_class', 'HtmlCommandResolver'); + +// CFG: CAPTCHA-GUEST-VERIFIER-FILTER +$cfg->setConfigEntry('captcha_guest_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter'); + +// CFG: CAPTCHA-USER-VERIFIER-FILTER +$cfg->setConfigEntry('captcha_user_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter'); + +// CFG: CAPTCHA-REGISTER-VERIFIER-FILTER +$cfg->setConfigEntry('captcha_register_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter'); + +// CFG: CAPTCHA-REFILL-VERFIER-FILTER +$cfg->setConfigEntry('captcha_refill_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter'); + +// CFG: CAPTCHA-GOVERNMENT-VERFIER-FILTER +$cfg->setConfigEntry('captcha_government_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter'); + +// CFG: CAPTCHA-PROFILE-VERFIER-FILTER +$cfg->setConfigEntry('captcha_profile_verifier_filter', 'GraphicalCodeCaptchaVerifierFilter'); + +// CFG: CONFIRM-CODE-VERIFIER-FILTER +$cfg->setConfigEntry('confirm_code_verifier_filter', 'ConfirmCodeVerifierFilter'); + +// CFG: BIRTHDAY-REGISTER-VERIFIER-FILTER +$cfg->setConfigEntry('birthday_register_verifier_filter', 'BirthdayVerifierFilter'); + +// CFG: BIRTHDAY-PROFILE-VERIFIER-FILTER +$cfg->setConfigEntry('birthday_profile_verifier_filter', 'BirthdayVerifierFilter'); + /****************************************************************************** * Console client * ******************************************************************************/ diff --git a/application/city/data.php b/application/city/data.php index 80bef1c..c656060 100644 --- a/application/city/data.php +++ b/application/city/data.php @@ -35,7 +35,7 @@ $app = call_user_func_array( ); // Set application name and version -$app->setAppName('Simple City Grow Simulation'); +$app->setAppName('Simple City Growth Simulation'); $app->setAppVersion('0.0.0'); $app->setAppShortName('city'); diff --git a/application/city/main/commands/html/class_CityHtmlRegisterCommand.php b/application/city/main/commands/html/class_CityHtmlRegisterCommand.php new file mode 100644 index 0000000..ad43a76 --- /dev/null +++ b/application/city/main/commands/html/class_CityHtmlRegisterCommand.php @@ -0,0 +1,80 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 Ship-Simu Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityHtmlRegisterCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * 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 static final function createCityHtmlRegisterCommand (CommandResolver $resolverInstance) { + // Get a new instance + $commandInstance = new CityHtmlRegisterCommand(); + + // Set the resolver instance + $commandInstance->setResolverInstance($resolverInstance); + + // 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) { + /* + * This is a generic HTML request, this means that a regular page with + * header, menu, content and footer shall be send to the client. + */ + $this->sendGenericGetResponse($requestInstance, $responseInstance, '_form'); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Add some more pre/post filters to the controller + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + } +} + +// [EOF] +?> diff --git a/application/city/main/commands/html/class_HtmlCityRegisterCommand.php b/application/city/main/commands/html/class_HtmlCityRegisterCommand.php new file mode 100644 index 0000000..4b82e51 --- /dev/null +++ b/application/city/main/commands/html/class_HtmlCityRegisterCommand.php @@ -0,0 +1,119 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 Ship-Simu Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlCityRegisterCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * 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 static final function createHtmlCityRegisterCommand (CommandResolver $resolverInstance) { + // Get a new instance + $commandInstance = new HtmlCityRegisterCommand(); + + // Set the resolver instance + $commandInstance->setResolverInstance($resolverInstance); + + // 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) { + // First get a UserRegistration instance + $registerInstance = ObjectFactory::createObjectByConfiguredName('user_registration_class'); + + // First set request and response instance + $registerInstance->setRequestInstance($requestInstance); + $registerInstance->setResponseInstance($responseInstance); + + // Encrypt the password + $registerInstance->encryptPassword('pass1'); + + // Do things before registration + $registerInstance->doPreRegistration(); + + // Register the new user + $registerInstance->registerNewUser(); + + /* + * Do things after registration like notifying partner pages or queueing + * them for notification + */ + $registerInstance->doPostRegistration(); + + // Redirect or login after registration + $registerInstance->doPostAction(); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Add some more pre/post filters to the controller + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Validate email address (if configured: check on double email addresses) + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_filter')); + + // Validate username and check if it does not exist + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_validator_filter')); + + // Validate if username is "guest" and not taken + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_is_guest_filter')); + + // Validate if password is set + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_validator_filter')); + + // Check if rules where accepted + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('rules_accepted_filter')); + + // Validate CAPTCHA input + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_register_verifier_filter')); + + // Validate birthday + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('birthday_register_verifier_filter')); + } +} + +// [EOF] +?> diff --git a/application/city/main/controller/html/class_CityHtmlRegisterController.php b/application/city/main/controller/html/class_CityHtmlRegisterController.php new file mode 100644 index 0000000..fd4f4b8 --- /dev/null +++ b/application/city/main/controller/html/class_CityHtmlRegisterController.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityHtmlRegisterController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach + } + + /** + * 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 static final function createCityHtmlRegisterController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new CityHtmlRegisterController(); + + // 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) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/application/city/main/controller/html/form/.htaccess b/application/city/main/controller/html/form/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/controller/html/form/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/controller/html/form/class_CityHtmlDoFormController.php b/application/city/main/controller/html/form/class_CityHtmlDoFormController.php new file mode 100644 index 0000000..be5c413 --- /dev/null +++ b/application/city/main/controller/html/form/class_CityHtmlDoFormController.php @@ -0,0 +1,102 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityHtmlDoFormController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createCityHtmlDoFormController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new CityHtmlDoFormController(); + + // Set resolver instance + $controllerInstance->setResolverInstance($resolverInstance); + + // We need the controller instance in resolver class so set it here + $resolverInstance->setControllerInstance($controllerInstance); + + // 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 "form action" + $formAction = $requestInstance->getRequestElement('form'); + + // Get command instance from resolver + $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // 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'); + + // Exit here + exit(); + } + + /* + * Is the request still valid? Post filters shall only be executed of + * the request is valid + */ + if ($requestInstance->isRequestValid()) { + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Execute *very* generic ppost filters + $this->executePostFilters($requestInstance, $responseInstance); + } // END - if + + // Flush the buffer out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/application/city/main/menu/class_CityRegisterMenu.php b/application/city/main/menu/class_CityRegisterMenu.php new file mode 100644 index 0000000..5205c00 --- /dev/null +++ b/application/city/main/menu/class_CityRegisterMenu.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityRegisterMenu extends BaseMenu implements RenderableMenu { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $menuInstance An instance of this class + */ + public static final function createCityRegisterMenu () { + // Get a new instance + $menuInstance = new CityRegisterMenu(); + + // Return the prepared instance + return $menuInstance; + } +} + +// [EOF] +?> diff --git a/application/city/main/resolver/controller/console/class_CityConsoleControllerResolver.php b/application/city/main/resolver/controller/console/class_CityConsoleControllerResolver.php index 7245db0..8bc4aed 100644 --- a/application/city/main/resolver/controller/console/class_CityConsoleControllerResolver.php +++ b/application/city/main/resolver/controller/console/class_CityConsoleControllerResolver.php @@ -36,68 +36,36 @@ class CityConsoleControllerResolver extends BaseControllerResolver implements Co } /** - * Creates an instance of a resolver class with a given command + * Creates an instance of a resolver class with a given controller * * @param $controllerName The controller we shall resolve * @param $applicationInstance An instance of a manageable application helper class * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default command is not set + * @throws EmptyVariableException Thrown if default controller is not set * @throws InvalidControllerException Thrown if default controller is invalid */ public static final function createCityConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) { // Create the new instance $resolverInstance = new CityConsoleControllerResolver(); - // Is the variable $controllerName set and the command is valid? + // Is the variable $controllerName set and the controller is valid? if (empty($controllerName)) { // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid command found + // Invalid controller found throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } // Set the application instance $resolverInstance->setApplicationInstance($applicationInstance); - // Set command name + // Set controller name $resolverInstance->setControllerName($controllerName); // Return the prepared instance return $resolverInstance; } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } } // [EOF] diff --git a/application/city/main/resolver/controller/html/class_CityHtmlControllerResolver.php b/application/city/main/resolver/controller/html/class_CityHtmlControllerResolver.php index 4164595..ea84e32 100644 --- a/application/city/main/resolver/controller/html/class_CityHtmlControllerResolver.php +++ b/application/city/main/resolver/controller/html/class_CityHtmlControllerResolver.php @@ -36,68 +36,36 @@ class CityHtmlControllerResolver extends BaseControllerResolver implements Contr } /** - * Creates an instance of a resolver class with a given command + * Creates an instance of a resolver class with a given controller * * @param $controllerName The controller we shall resolve * @param $applicationInstance An instance of a manageable application helper class * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default command is not set + * @throws EmptyVariableException Thrown if default controller is not set * @throws InvalidControllerException Thrown if default controller is invalid */ public static final function createCityHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) { // Create the new instance $resolverInstance = new CityHtmlControllerResolver(); - // Is the variable $controllerName set and the command is valid? + // Is the variable $controllerName set and the controller is valid? if (empty($controllerName)) { // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid command found + // Invalid controller found throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } // Set the application instance $resolverInstance->setApplicationInstance($applicationInstance); - // Set command name + // Set controller name $resolverInstance->setControllerName($controllerName); // Return the prepared instance return $resolverInstance; } - - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default - * command - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the command name - $controllerName = $this->getControllerName(); - - // Get the command - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } } // [EOF] diff --git a/application/city/main/resolver/controller/image/.htaccess b/application/city/main/resolver/controller/image/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/resolver/controller/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/resolver/controller/image/class_CityImageControllerResolver.php b/application/city/main/resolver/controller/image/class_CityImageControllerResolver.php new file mode 100644 index 0000000..c6d302b --- /dev/null +++ b/application/city/main/resolver/controller/image/class_CityImageControllerResolver.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CityImageControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'image' + $this->setClassPrefix('image'); + } + + /** + * Creates an instance of a resolver class with a given controller + * + * @param $controllerName The controller we shall resolve + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default controller is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public static final function createCityImageControllerResolver ($controllerName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new CityImageControllerResolver(); + + // Is the variable $controllerName set and the controller is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { + // Invalid controller found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Set controller name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/application/city/main/states/city/class_ b/application/city/main/states/city/class_ index 5df9aa5..250c39d 100644 --- a/application/city/main/states/city/class_ +++ b/application/city/main/states/city/class_ @@ -48,9 +48,6 @@ class City???State extends BaseCityState implements Stateable { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CITY-STATE: Has changed from ' . $cityInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Set the city instance - $stateInstance->setCityInstance($cityInstance); - // Return the prepared instance return $stateInstance; } diff --git a/application/city/main/states/city/init/class_CityInitState.php b/application/city/main/states/city/init/class_CityInitState.php index 28584cd..ea9d5b8 100644 --- a/application/city/main/states/city/init/class_CityInitState.php +++ b/application/city/main/states/city/init/class_CityInitState.php @@ -45,9 +45,6 @@ class CityInitState extends BaseCityState implements Stateable { // Get new instance $stateInstance = new CityInitState(); - // Set the city instance - $stateInstance->setCityInstance($cityInstance); - // Return the prepared instance return $stateInstance; } diff --git a/application/city/main/states/city/virgin/class_CityVirginState.php b/application/city/main/states/city/virgin/class_CityVirginState.php index 97a3432..14c53a5 100644 --- a/application/city/main/states/city/virgin/class_CityVirginState.php +++ b/application/city/main/states/city/virgin/class_CityVirginState.php @@ -45,9 +45,6 @@ class CityVirginState extends BaseCityState implements Stateable { // Get new instance $stateInstance = new CityVirginState(); - // Set the city instance - $stateInstance->setCityInstance($cityInstance); - // Return the prepared instance return $stateInstance; } diff --git a/application/city/templates/de/code/captch_graphic_code.ctp b/application/city/templates/de/code/captch_graphic_code.ctp new file mode 100644 index 0000000..942d94c --- /dev/null +++ b/application/city/templates/de/code/captch_graphic_code.ctp @@ -0,0 +1,23 @@ +addFieldText('captcha_code', "Bitte wiederhole den Code:"); +$captchaHelper->addInputTextField('c_code'); + +// Add hidden field with validation hash +$captchaHelper->addInputHiddenField('hash', $this->readVariable('captcha_hash')); + +// Flush content +$captchaHelper->flushContent(); + +// [EOC] +?> +
+ CAPTCHA-Bild +
+
+ {?captcha_code?} +
diff --git a/application/city/templates/de/code/home.ctp b/application/city/templates/de/code/home.ctp index 72fd839..fe59655 100644 --- a/application/city/templates/de/code/home.ctp +++ b/application/city/templates/de/code/home.ctp @@ -5,3 +5,7 @@
{?city_news?}
+ +
+ Hier wird der Gast zum Spiel begrüsst. +
diff --git a/application/city/templates/de/code/register_form.ctp b/application/city/templates/de/code/register_form.ctp new file mode 100644 index 0000000..3a9c354 --- /dev/null +++ b/application/city/templates/de/code/register_form.ctp @@ -0,0 +1,134 @@ +addFormGroup('login', "Bitte gebe hier gewünschten Nickname und dein Zugangspasswort ein."); +$helperInstance->addFormSubGroup('username', "Dein Nickname wird erst nach Absenden des Formulares geprüft. Später bauen wir dann einen automatischen Test ein, der dir sofort zeigt, ob der Nickname bereits vergeben ist."); +$helperInstance->addFieldText('username', "Nickname im Spiel:"); +$helperInstance->addInputTextField('username'); +$helperInstance->addFormSubGroup('pass', "Dein Passwort sollte nicht zu leicht erratbar sein. Später bauen wir hier noch einen automatischen Test ein, der dir sofort die Passwortstärke anzeigt."); +$helperInstance->addFieldText('pass1', "Passwort:"); +$helperInstance->addInputPasswordField('pass1'); +$helperInstance->addFieldText('pass2', "Passwortwiederholung:"); +$helperInstance->addInputPasswordField('pass2'); + +// Does this registration require an email? +if ($helperInstance->ifRegisterRequiresEmailVerification()) { + $helperInstance->addFormGroup('email', "Bitte gebe deine Email zweimal (ein zweites Mal zur Bestätigung) ein, damit wir dir deinen Freischaltlink zusenden können."); + $helperInstance->addFieldText('email1', "Email-Adresse:"); + $helperInstance->addInputTextField('email1'); + $helperInstance->addFieldText('email2', "Wiederholung Email-Adresse:"); + $helperInstance->addInputTextField('email2'); + + // Must the email address be unique in this system? + if ($helperInstance->ifEmailMustBeUnique()) { + $helperInstance->addFormNote('email', "Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein."); + } // END - if +} // END - if + +// Shall we also ask some personal data to complete the profile? +if ($helperInstance->ifRegisterIncludesProfile()) { + $helperInstance->addFormGroup('profile', "Hier kannst du zusätzlich deine Profildaten vorweg eingeben, du kannst sie aber auch nach dem Login vervollständigen!"); + + if (!$helperInstance->ifRegisterRequiresEmailVerification()) { + $helperInstance->addFormSubGroup('email', "Die Angabe deiner Email-Adresse ist nur dann nötig, wenn du auch Email-Benachrichtigungen (*1) haben möchtest."); + $helperInstance->addFieldText('email1', "Email-Adresse:"); + $helperInstance->addInputTextField('email1'); + + // Must the email address be unique in this system? + if ($helperInstance->ifEmailMustBeUnique()) { + $helperInstance->addFormNote('email', "Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein."); + } // END - if + } // END - if + + // Persoenliche Daten mit in der Anmeldung abfragen? + if ($helperInstance->ifRegisterIncludesPersonaData()) { + $helperInstance->addFormSubGroup('persona', "Wenn du magst, dann vervollständige deine komplette Adresse mit deinem Namen."); + $helperInstance->addFieldText('surname', "Dein Vorname:"); + $helperInstance->addInputTextField('surname'); + $helperInstance->addFieldText('family', "Dein Nachname:"); + $helperInstance->addInputTextField('family'); + $helperInstance->addFieldText('street', "Strasse und Hausnummer:"); + $helperInstance->addInputTextField('street'); + $helperInstance->addFieldText('city', "Wohnort:"); + $helperInstance->addInputTextField('city'); + + // Include birthday? + if ($helperInstance->ifProfileIncludesBirthDay()) { + $helperInstance->addFormSubGroup('birthday', "Verrate uns doch dein Geburtsdatum, als Dankeschön erhälst du interessante Prämien - ausschliesslich per Email - zum Geburtstag zugesandt! Gültiges Format: TT.MM.JJJJ"); + $helperInstance->addInputTextField('birth_day'); + $helperInstance->addFieldText('birth_day', "."); + $helperInstance->addInputTextField('birth_month'); + $helperInstance->addFieldText('birth_day', "."); + $helperInstance->addInputTextField('birth_year'); + } // END - if + } // END - if + + $helperInstance->addFormSubGroup('zip', "Magst du uns auch deine Postleitzahl verraten?"); + $helperInstance->addFieldText('zip', "Postleitzahl:"); + $helperInstance->addInputTextField('zip'); + + $helperInstance->addFormSubGroup('chat', "Gebe hier deine Nicknames bzw. Nummern an:"); + + if ($helperInstance->ifChatEnabled('icq')) { + $helperInstance->addFieldText('icq', "ICQ-Nummer:"); + $helperInstance->addInputTextField('icq'); + } // END - if + + if ($helperInstance->ifChatEnabled('jabber')) { + $helperInstance->addFieldText('jabber', "Jabber:"); + $helperInstance->addInputTextField('jabber'); + } // END - if + + if ($helperInstance->ifChatEnabled('yahoo')) { + $helperInstance->addFieldText('yahoo', "Yahoo!:"); + $helperInstance->addInputTextField('yahoo'); + } // END - if + + if ($helperInstance->ifChatEnabled('aol')) { + $helperInstance->addFieldText('aol', "AOL-Screenname:"); + $helperInstance->addInputTextField('aol'); + } // END - if + + if ($helperInstance->ifChatEnabled('msn')) { + $helperInstance->addFieldText('msn', "MSN:"); + $helperInstance->addInputTextField('msn'); + } // END - if + + if (!$helperInstance->ifRegisterRequiresEmailVerification()) { + $helperInstance->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst."); + } // END - Extra note + +} // END - ask profile data + +// Spielregeln abfragen +$helperInstance->addFormGroup('rules', "Bitte lese dir die Spieleregeln gut durch und kreuze dann "Ja, ich akzeptiere die aktuellen Spielregeln" an."); +$helperInstance->addFieldText('rules', "Ja, ich akzeptiere die aktuellen Spielregeln:"); +$helperInstance->addInputCheckboxField('rules', false); + +// Add CAPTCHA? +if ($helperInstance->ifFormSecuredWithCaptcha()) { + $helperInstance->addFormGroup('captcha', "Bitte wiederhole den angezeigten Code damit die Anmeldung abgeschlossen werden kann."); + $helperInstance->addCaptcha(); +} // END - if + +// Final note and submit buttons +$helperInstance->addFormGroup('buttons', "Wenn du alle benötigten Felder korrekt ausgefüt hast, kannst du die Anmeldung abschliessen."); + +$helperInstance->addInputResetButton("Alles nochmal eingeben"); +$helperInstance->addInputSubmitButton("Anmeldung zum Spiel abschliessen"); +$helperInstance->addFormNote('data_protection', "Deine Daten werden nach den gültigen Datenschutzgesetzen gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link "Datenschutz"."); +$helperInstance->flushContent(); + +// [EOC] +?> +
+ Anmeldung bei {?app_full_name?} +
+ +
+ {?city_register?} +
diff --git a/application/city/templates/de/image/.htaccess b/application/city/templates/de/image/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/templates/de/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/templates/de/image/base_code.xml b/application/city/templates/de/image/base_code.xml new file mode 100644 index 0000000..5de71be --- /dev/null +++ b/application/city/templates/de/image/base_code.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/city/templates/de/image/code_captcha.img b/application/city/templates/de/image/code_captcha.img new file mode 100644 index 0000000..223e4fb --- /dev/null +++ b/application/city/templates/de/image/code_captcha.img @@ -0,0 +1,78 @@ +setImageName('code_captcha'); +$helper->setBaseImage('base_code'); + +// Set image dimensions +$helper->setWidth(100); +$helper->setHeight(50); + +// Get random number +$rand = $helper->getRngInstance()->randomNumber(0, 6); + +// Background and foreground color +switch ($rand) { + case 1: + // First varriant + $helper->setBackgroundColorRedGreenBlue('rand', 0x90 , 0x00 ); + $helper->setForegroundColorRedGreenBlue(0x00 , 0xff , 'rand'); + break; + + case 2: + // Second varriant + $helper->setBackgroundColorRedGreenBlue(0x90 , 'rand', 0x00 ); + $helper->setForegroundColorRedGreenBlue(0xff , 0x00 , 'rand'); + break; + + case 3: + // Third varriant + $helper->setBackgroundColorRedGreenBlue('rand', 0x00 , 0x90 ); + $helper->setForegroundColorRedGreenBlue(0x00 , 'rand', 0xff ); + break; + + case 4: + // Forth varriant + $helper->setBackgroundColorRedGreenBlue(0x00 , 0x90 , 'rand'); + $helper->setForegroundColorRedGreenBlue(0x00 , 'rand', 0xa0 ); + break; + + case 5: + // Fith varriant + $helper->setBackgroundColorRedGreenBlue('rand', 0x00 , 0x90 ); + $helper->setForegroundColorRedGreenBlue(0x00 , 0xe0 , 'rand'); + break; + + default: + // Last varriant + $helper->setBackgroundColorRedGreenBlue(0x00 , 'rand', 0x90 ); + $helper->setForegroundColorRedGreenBlue(0xff , 0x00 , 'rand'); + break; +} + +// Random X/Y factors... +$xRand = $helper->getRngInstance()->randomNumber(0, 45); +$yRand = $helper->getRngInstance()->randomNumber(0, 25); + +// Add code +$helper->addTextLine('code'); +$helper->setCoord((5 + $xRand), (5 + $yRand)); +$helper->setFontSize('rand'); +$helper->setImageString('{?decrypted_code?}'); + +// Only for debug! +/* +$helper->addTextLine('debug'); +$helper->setCoord(90, 35); +$helper->setFontSize(3); +$helper->setImageString($rand); +*/ + +// Flush content to the template engine +$helper->flushContent(); + +// Comment this out if image is done +//$this->debugInstance(); + +// [EOF] +?> diff --git a/application/city/templates/de/image/emergency_exit.img b/application/city/templates/de/image/emergency_exit.img new file mode 100644 index 0000000..bf67aa7 --- /dev/null +++ b/application/city/templates/de/image/emergency_exit.img @@ -0,0 +1,18 @@ +setImageName('emergency_exit'); +$helper->setBaseImage('base_exit'); + +// Set image dimensions +$helper->setWidth(100); +$helper->setHeight(50); + +// Flush content to the template engine +//$helper->flushContent(); + +// Comment this out if image is done +$this->debugInstance(); + +// [EOF] +?> diff --git a/core b/core index 3b3947b..bbb4031 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 3b3947b86b38904aa1100b54846c14d3b31cb97d +Subproject commit bbb4031b65beb69a02f8c476ae4cdc36da851d84 diff --git a/templates/.htaccess b/templates/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/templates/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/templates/images/.htaccess b/templates/images/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/templates/images/.htaccess @@ -0,0 +1 @@ +Deny from all