From: Roland Häder Date: Tue, 24 Jun 2008 20:52:50 +0000 (+0000) Subject: CAPTCHA support basicly finished (weak CAPTCHA!) X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=commitdiff_plain;h=1cc728fe28f6fe71a8d581a0dc1f2505bb0baa33 CAPTCHA support basicly finished (weak CAPTCHA!) --- diff --git a/.gitattributes b/.gitattributes index 268477a..74a28e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -151,8 +151,11 @@ application/ship-simu/templates/de/html/.htaccess -text application/ship-simu/templates/de/html/nav_advert.tpl -text application/ship-simu/templates/de/html/selector_ship-simu.tpl -text application/ship-simu/templates/images/.htaccess -text +application/ship-simu/templates/images/_cache/.htaccess -text application/ship-simu/templates/images/de/.htaccess -text application/ship-simu/templates/images/de/image/.htaccess -text +application/ship-simu/templates/images/de/image/base_code.itp -text +application/ship-simu/templates/images/de/image/code_captcha.itp -text db/.htaccess -text db/news/.htaccess -text db/user/.htaccess -text @@ -185,6 +188,9 @@ inc/classes/exceptions/controller/.htaccess -text inc/classes/exceptions/controller/class_DefaultControllerException.php -text inc/classes/exceptions/controller/class_InvalidControllerException.php -text inc/classes/exceptions/criteria/.htaccess -text +inc/classes/exceptions/crypto/.htaccess -text +inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php -text +inc/classes/exceptions/crypto/class_EncryptMissingException.php -text inc/classes/exceptions/database/.htaccess -text inc/classes/exceptions/database/class_DatabaseException.php -text inc/classes/exceptions/database/general/.htaccess -text @@ -372,6 +378,8 @@ inc/classes/main/class_FrameworkArrayObject.php -text inc/classes/main/commands/.htaccess -text inc/classes/main/commands/class_ -text inc/classes/main/commands/class_BaseCommand.php -text +inc/classes/main/commands/image/.htaccess -text +inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php -text inc/classes/main/commands/web/.htaccess -text inc/classes/main/commands/web/class_WebDoFormCommand.php -text inc/classes/main/commands/web/class_WebHomeCommand.php -text @@ -388,6 +396,8 @@ inc/classes/main/compressor/class_NullCompressor.php -text inc/classes/main/console/.htaccess -text inc/classes/main/console/class_ConsoleTools.php -text inc/classes/main/controller/.htaccess -text +inc/classes/main/controller/captcha/.htaccess -text +inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php -text inc/classes/main/controller/class_ -text inc/classes/main/controller/class_BaseController.php -text inc/classes/main/controller/form/.htaccess -text @@ -445,6 +455,8 @@ inc/classes/main/filter/class_ -text inc/classes/main/filter/class_AbstractFilterDecorator.php -text inc/classes/main/filter/class_BaseFilter.php -text inc/classes/main/filter/class_FilterChain.php -text +inc/classes/main/filter/crypto/.htaccess -text +inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php -text inc/classes/main/filter/decorator/.htaccess -text inc/classes/main/filter/guest/.htaccess -text inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php -text @@ -470,12 +482,12 @@ inc/classes/main/helper/.htaccess -text inc/classes/main/helper/captcha/.htaccess -text inc/classes/main/helper/captcha/class_ -text inc/classes/main/helper/captcha/class_BaseCaptcha.php -text +inc/classes/main/helper/captcha/images/.htaccess -text +inc/classes/main/helper/captcha/images/class_ImageHelper.php -text inc/classes/main/helper/captcha/web/.htaccess -text inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php -text inc/classes/main/helper/class_ -text inc/classes/main/helper/class_BaseHelper.php -text -inc/classes/main/helper/images/.htaccess -text -inc/classes/main/helper/images/class_ImageHelper.php -text inc/classes/main/helper/login/.htaccess -text inc/classes/main/helper/login/class_BaseLoginHelper.php -text inc/classes/main/helper/web/.htaccess -text diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index 53dff5c..3a41965 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -127,6 +127,9 @@ $cfg->setConfigEntry('user_auth_class', "UserAuthFilter"); // CFG: USER-UPDATE-CLASS $cfg->setConfigEntry('user_update_class', "UserUpdateFilter"); +// CFG: CAPTCHA-ENCRYPT-VALIDATOR-CLASS +$cfg->setConfigEntry('captcha_encrypt_validator_class', "CaptchaEncryptFilter"); + // CFG: NEWS-HOME-LIMIT $cfg->setConfigEntry('news_home_limit', 10); diff --git a/application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php b/application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php index a4bebd6..b17acb2 100644 --- a/application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php +++ b/application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php @@ -36,7 +36,7 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin { private $authMethod = ""; // Exception constants - const EXCEPTION_INVALID_USER_INSTANCE = 0x900; + const EXCEPTION_INVALID_USER_INSTANCE = 0x190; /** * Protected constructor diff --git a/application/ship-simu/templates/images/_cache/.htaccess b/application/ship-simu/templates/images/_cache/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/templates/images/_cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/ship-simu/templates/images/de/image/base_code.itp b/application/ship-simu/templates/images/de/image/base_code.itp new file mode 100644 index 0000000..ecba6c9 --- /dev/null +++ b/application/ship-simu/templates/images/de/image/base_code.itp @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/ship-simu/templates/images/de/image/code_captcha.itp b/application/ship-simu/templates/images/de/image/code_captcha.itp new file mode 100644 index 0000000..2e28522 --- /dev/null +++ b/application/ship-simu/templates/images/de/image/code_captcha.itp @@ -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/inc/classes/exceptions/crypto/.htaccess b/inc/classes/exceptions/crypto/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/exceptions/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php new file mode 100644 index 0000000..e6ee352 --- /dev/null +++ b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EncryptInvalidLengthException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct(Filterable $filterInstance, $code) { + // Get length + $length = $filterInstance->getConfigInstance()->readConfig('captcha_string_length'); + + // Construct message + $message = sprintf("[%s:%d] Encrypt string has an invalid length. Valid: %d", + $filterInstance->__toString(), + $this->getLine(), + $length + ); + + // Set extra data + $this->setExtraData($filterInstance->__toString().":".$length); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/crypto/class_EncryptMissingException.php b/inc/classes/exceptions/crypto/class_EncryptMissingException.php new file mode 100644 index 0000000..2b3f6b4 --- /dev/null +++ b/inc/classes/exceptions/crypto/class_EncryptMissingException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EncryptMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct(Filterable $filterInstance, $code) { + // Construct message + $message = sprintf("[%s:%d] Encrypt string is missing.", + $filterInstance->__toString(), + $this->getLine() + ); + + // Set extra data + $this->setExtraData($filterInstance->__toString()); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/io/class_FileNotFoundException.php b/inc/classes/exceptions/io/class_FileNotFoundException.php index a8ff449..6266544 100644 --- a/inc/classes/exceptions/io/class_FileNotFoundException.php +++ b/inc/classes/exceptions/io/class_FileNotFoundException.php @@ -25,13 +25,18 @@ class FileNotFoundException extends FrameworkException { /** * The constructor * - * @param $fqfn Full-qualified file name of (maybe) missing file - * @param $code Code number for the exception + * @param $fqfn Full-qualified file name of (maybe) missing file + * @param $code Code number for the exception * @return void */ public function __construct ($fqfn, $code) { // Add a message around the missing class - $message = sprintf("The requested file %s was not found.", $fqfn); + $message = sprintf("The requested file %s was not found.", + $fqfn + ); + + // Set extra data + $this->setExtraData(basename($fqfn)); // Call parent constructor parent::__construct($message, $code); diff --git a/inc/classes/exceptions/main/class_FatalErrorException.php b/inc/classes/exceptions/main/class_FatalErrorException.php index 320dae7..b7ac3d0 100644 --- a/inc/classes/exceptions/main/class_FatalErrorException.php +++ b/inc/classes/exceptions/main/class_FatalErrorException.php @@ -30,6 +30,7 @@ class FatalErrorException extends FrameworkException { * @return void */ public function __construct ($message, $code) { + die($message); // Call parent constructor parent::__construct($message, $code); } diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index b49be03..3c1b5fc 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -152,6 +152,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { const EXCEPTION_FATAL_ERROR = 0x035; const EXCEPTION_FILE_NOT_FOUND = 0x036; const EXCEPTION_ASSERTION_FAILED = 0x037; + const EXCEPTION_FILE_CANNOT_BE_READ = 0x038; /** * In the super constructor these system classes shall be ignored or else @@ -398,7 +399,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * @return $cfgInstance Configuration instance */ - protected final function getConfigInstance () { + public final function getConfigInstance () { $cfgInstance = Registry::getRegistry()->getInstance('config'); return $cfgInstance; } diff --git a/inc/classes/main/commands/image/.htaccess b/inc/classes/main/commands/image/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/commands/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php b/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php new file mode 100644 index 0000000..53cd32d --- /dev/null +++ b/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCodeCaptchaCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set special description + $this->setObjectDescription(""); + + // Create unique ID number + $this->generateUniqueId(); + + // Clean up a little + $this->removeSystemArray(); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createImageCodeCaptchaCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new ImageCodeCaptchaCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the given 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) { + // Get the decrypted string from request (previously created by a filter!) + $decryptedCode = $requestInstance->getRequestElement('decrypted'); + + // Get the application instance + $appInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateEngine($appInstance); + + // Assign variable + $templateInstance->assignVariable('decrypted_code', $decryptedCode); + + // Load the code (pardon, image...) template + $templateInstance->loadCodeTemplate('code_captcha'); + + // Compile the template + $templateInstance->compileTemplate(); + + // Compile all variables + $templateInstance->compileVariables(); + + // Transfer it to the response + $templateInstance->transferToResponse($responseInstance); + } + + /** + * 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 + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Extra filters here... + } +} + +// [EOF] +?> diff --git a/inc/classes/main/controller/captcha/.htaccess b/inc/classes/main/controller/captcha/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/controller/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php b/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php new file mode 100644 index 0000000..794b26d --- /dev/null +++ b/inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCodeCaptchaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + + // 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 createImageCodeCaptchaController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ImageCodeCaptchaController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filter for checking the "encrypt" string + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_class')); + + // 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) { + // Execute pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Execute post filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index aab3784..681ec64 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -22,6 +22,10 @@ * along with this program. If not, see . */ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { + // Exception constants + const EXCEPTION_ENCRYPT_MISSING = 0x1f0; + const EXCEPTION_ENCRYPT_INVALID = 0x1f1; + /** * An instance of this own clas */ diff --git a/inc/classes/main/database/class_BaseDatabaseFrontend.php b/inc/classes/main/database/class_BaseDatabaseFrontend.php index 046ae8b..74dedfa 100644 --- a/inc/classes/main/database/class_BaseDatabaseFrontend.php +++ b/inc/classes/main/database/class_BaseDatabaseFrontend.php @@ -24,7 +24,7 @@ */ abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontendInterface { // Constants for exceptions - const EXCEPTION_SQL_QUERY = 0x500; + const EXCEPTION_SQL_QUERY = 0x140; /** * The limiter instance diff --git a/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php index 1b8b6ad..7188be1 100644 --- a/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php @@ -29,7 +29,7 @@ class NewsDatabaseWrapper extends BaseDatabaseWrapper { private $cacheInstance = null; // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x700; + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x160; // Constants for database columns diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index f1caa49..97e7344 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -29,7 +29,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { private $cacheInstance = null; // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x800; + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; // Constants for database columns const DB_COLUMN_USERNAME = "username"; diff --git a/inc/classes/main/filter/auth/class_UserAuthFilter.php b/inc/classes/main/filter/auth/class_UserAuthFilter.php index fc001a3..c346615 100644 --- a/inc/classes/main/filter/auth/class_UserAuthFilter.php +++ b/inc/classes/main/filter/auth/class_UserAuthFilter.php @@ -23,7 +23,7 @@ */ class UserAuthFilter extends BaseFilter implements Filterable { // Exception constants - const EXCEPTION_AUTH_DATA_INVALID = 0xb00; + const EXCEPTION_AUTH_DATA_INVALID = 0x1b0; /** * The login method we shall choose diff --git a/inc/classes/main/filter/class_BaseFilter.php b/inc/classes/main/filter/class_BaseFilter.php index 195d3e1..2d31471 100644 --- a/inc/classes/main/filter/class_BaseFilter.php +++ b/inc/classes/main/filter/class_BaseFilter.php @@ -23,7 +23,7 @@ */ class BaseFilter extends BaseFrameworkSystem { // Exception constants - const EXCEPTION_FILTER_CHAIN_ABORTED = 0xa00; + const EXCEPTION_FILTER_CHAIN_ABORTED = 0x1a0; /** * Protected constructor diff --git a/inc/classes/main/filter/crypto/.htaccess b/inc/classes/main/filter/crypto/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/filter/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php new file mode 100644 index 0000000..9208cef --- /dev/null +++ b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CaptchaEncryptFilter 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 checking encryption data"); + + // 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 createCaptchaEncryptFilter () { + // Get a new instance + $filterInstance = new CaptchaEncryptFilter(); + + // 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 + * @throws EncryptMissingException If the "encrypt" value is not set + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get "encrypt" string barely from the request + $encryptRequest = $requestInstance->getRequestElement('encrypt'); + + // Is it there? + if (is_null($encryptRequest)) { + // Not found, so request is invalid + $requestInstance->requestIsValid(false); + + // Throw exception + throw new EncryptMissingException($this, CryptoHelper::EXCEPTION_ENCRYPT_MISSING); + } // END - if + + // Decode it fully + $encryptDecoded = base64_decode(str_replace(" ", "+", urldecode($encryptRequest))); + + // Get a crypto helper and decrypt the string + $decryptedString = ObjectFactory::createObjectByConfiguredName('crypto_class')->decryptString($encryptDecoded); + + // Is it the expected length? + if (strlen($decryptedString) != $this->getConfigInstance()->readConfig('captcha_string_length')) { + // Not found, so request is invalid + $requestInstance->requestIsValid(false); + + // Throw exception + throw new EncryptInvalidLengthException($this, CryptoHelper::EXCEPTION_ENCRYPT_INVALID); + } // END - if + + // Write it to the request + $requestInstance->setRequestElement('decrypted', $decryptedString); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/captcha/class_BaseCaptcha.php b/inc/classes/main/helper/captcha/class_BaseCaptcha.php index 09b3e91..a589548 100644 --- a/inc/classes/main/helper/captcha/class_BaseCaptcha.php +++ b/inc/classes/main/helper/captcha/class_BaseCaptcha.php @@ -59,11 +59,11 @@ class BaseCaptcha extends BaseHelper { } /** - * Protected getter for RNG instance + * Getter for RNG instance * * @return $rngInstance An instance of a random number generator (RNG) */ - protected final function getRngInstance () { + public final function getRngInstance () { return $this->rngInstance; } diff --git a/inc/classes/main/helper/captcha/images/.htaccess b/inc/classes/main/helper/captcha/images/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/helper/captcha/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/captcha/images/class_ImageHelper.php b/inc/classes/main/helper/captcha/images/class_ImageHelper.php new file mode 100644 index 0000000..48ad6f0 --- /dev/null +++ b/inc/classes/main/helper/captcha/images/class_ImageHelper.php @@ -0,0 +1,394 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageHelper extends BaseCaptcha implements HelpableTemplate { + /** + * The image type + */ + private $imageType = "png"; + + /** + * The image name + */ + private $imageName = ""; + + /** + * Width of the image in pixel + */ + private $width = 0; + + /** + * Height of the image in pixel + */ + private $height = 0; + + /** + * Array for background color values + */ + private $backgroundColor = array( + 'red' => 0, + 'green' => 0, + 'blue' => 0 + ); + + /** + * Array for foreground color values + */ + private $foregroundColor = array( + 'red' => 0, + 'green' => 0, + 'blue' => 0 + ); + + /** + * All image strings + */ + private $imageStrings = array(); + + /** + * Current string name + */ + private $currString = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("A image helper class"); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $imageType Type of the image + * @return $helperInstance A preparedf instance of this class + */ + public final static function createImageHelper (CompileableTemplate $templateInstance, $imageType) { + // Get new instance + $helperInstance = new ImageHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set image type (blindly) + $helperInstance->setImageType($imageType); + + // Initialize RNG + $helperInstance->initializeRandomNumberGenerator($templateInstance); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Setter for image type + * + * @param $imageType Type of the image + * @return void + */ + protected final function setImageType ($imageType) { + $this->imageType = (string) $imageType; + } + + /** + * Getter for image name + * + * @return $imageType Type of the image + */ + public final function getImageType () { + return $this->imageType; + } + + /** + * Setter for base image + * + * @param $baseImage A base image template + * @return void + */ + public final function setBaseImage ($baseImage) { + $this->baseImage = (string) $baseImage; + } + + /** + * Getter for base image + * + * @return $baseImage A base image template + */ + public final function getBaseImage () { + return $this->baseImage; + } + + /** + * Setter for image name + * + * @param $imageName Name of the image + * @return void + */ + public final function setImageName ($imageName) { + $this->imageName = (string) $imageName; + } + + /** + * Getter for image name + * + * @return $imageName Name of the image + */ + protected final function getImageName () { + return $this->imageName; + } + + /** + * Setter for image width + * + * @param $width Width of the image + * @return void + */ + public final function setWidth ($width) { + $this->width = (int) $width; + } + + /** + * Getter for image width + * + * @return $width Width of the image + */ + public final function getWidth () { + return $this->width; + } + + /** + * Setter for image height + * + * @param $height Height of the image + * @return void + */ + public final function setHeight ($height) { + $this->height = (int) $height; + } + + /** + * Getter for image height + * + * @return $height Height of the image + */ + public final function getHeight () { + return $this->height; + } + + /** + * Setter for RGB of background color + * + * @param $red Color value for red + * @param $green Color value for green + * @param $blue Color value for blue + * @return void + */ + public final function setBackgroundColorRedGreenBlue ($red, $green, $blue) { + // Random numbers? + if ($red === "rand") { + $red = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($green === "rand") { + $green = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($blue === "rand") { + $blue = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + + $this->backgroundColor['red'] = (int) $red; + $this->backgroundColor['green'] = (int) $green; + $this->backgroundColor['blue'] = (int) $blue; + } + + /** + * Setter for RGB of foreground color + * + * @param $red Color value for red + * @param $green Color value for green + * @param $blue Color value for blue + * @return void + */ + public final function setForegroundColorRedGreenBlue ($red, $green, $blue) { + // Random numbers? + if ($red === "rand") { + $red = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($green === "rand") { + $green = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + if ($blue === "rand") { + $blue = $this->getRngInstance()->randomNumber(0, 255); + } // END - if + + $this->foregroundColor['red'] = (int) $red; + $this->foregroundColor['green'] = (int) $green; + $this->foregroundColor['blue'] = (int) $blue; + } + + /** + * Adds an image string to the buffer by the given string name + * + * @param $stringName String name (identifier) + */ + public function addTextLine ($stringName) { + // Create the image string + $this->imageStrings[$stringName] = array( + 'x' => "", + 'y' => "", + 'size' => "", + 'string' => "" + ); + + // Set current string name + $this->currString = $stringName; + } + + /** + * Setter for image message string + * + * @param $imageString A message to display in the image + * @return void + */ + public final function setImageString ($imageString) { + $this->imageStrings[$this->currString]['string'] = (string) $imageString; + } + + /** + * Getter for image message string + * + * @return $imageString A message to display in the image + */ + public final function getImageString () { + return $this->imageStrings[$this->currString]['string']; + } + + /** + * Setter for X/Y coordinates for strings + * + * @param $x X coordinate + * @param $y Y coordinate + * @return void + */ + public final function setCoord ($x, $y) { + $this->imageStrings[$this->currString]['x'] = (int) $x; + $this->imageStrings[$this->currString]['y'] = (int) $y; + } + + /** + * Getter for X coordinate + * + * @return $x X coordinate + */ + public final function getX () { + return $this->imageStrings[$this->currString]['x']; + } + + /** + * Getter for Y coordinate + * + * @return $y Y coordinate + */ + public final function getY () { + return $this->imageStrings[$this->currString]['y']; + } + + /** + * Setter for font size + * + * @param $fontSize Font size for strings + * @return void + */ + public final function setFontSize ($fontSize) { + // Random font size? + if ($fontSize === "rand") { + $fontSize = $this->getRngInstance()->randomNumber(3, 9); + } // END - if + + $this->imageStrings[$this->currString]['size'] = (int) $fontSize; + } + + /** + * Getter for font size + * + * @return $fontSize Font size for strings + */ + public final function getFontSize () { + return $this->imageStrings[$this->currString]['size']; + } + + /** + * Flushs the content out + * + * @return void + */ + public function flushContent () { + // Get a template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the base image + $templateInstance->loadCodeTemplate($this->getBaseImage()); + + // Assign all the image values with the template + $templateInstance->assignVariable("image_name" , $this->getImageName()); + $templateInstance->assignVariable("image_type" , $this->getImageType()); + $templateInstance->assignVariable("image_width" , $this->getWidth()); + $templateInstance->assignVariable("image_height" , $this->getHeight()); + $templateInstance->assignVariable("image_bg_red" , $this->backgroundColor['red']); + $templateInstance->assignVariable("image_bg_green", $this->backgroundColor['green']); + $templateInstance->assignVariable("image_bg_blue" , $this->backgroundColor['blue']); + $templateInstance->assignVariable("image_fg_red" , $this->foregroundColor['red']); + $templateInstance->assignVariable("image_fg_green", $this->foregroundColor['green']); + $templateInstance->assignVariable("image_fg_blue" , $this->foregroundColor['blue']); + + // Add all strings + foreach ($this->imageStrings as $id=>$imageString) { + // Set current string id + $this->currString = $id; + + // Set variable group + $templateInstance->setVariableGroup($id); + + // Add group variables + $templateInstance->addGroupVariable("image_x" , $this->getX()); + $templateInstance->addGroupVariable("image_y" , $this->getY()); + $templateInstance->addGroupVariable("image_size" , $this->getFontSize()); + $templateInstance->addGroupVariable("image_string", $this->getImageString()); + } // END - foreach + + // Get the raw content + $imageContent = $templateInstance->getRawTemplateData(); + + // Transfer all to the template engine + $templateInstance->renderImageContent($imageContent); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index 2c0c3c8..adb1f01 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -23,9 +23,9 @@ */ class BaseHelper extends BaseFrameworkSystem { // Exception constants - const EXCEPTION_XML_PARSER_ERROR = 0xe00; - const EXCEPTION_XML_NODE_UNKNOWN = 0xe01; - const EXCEPTION_XML_NODE_MISMATCH = 0xe02; + const EXCEPTION_XML_PARSER_ERROR = 0x1e0; + const EXCEPTION_XML_NODE_UNKNOWN = 0x1e1; + const EXCEPTION_XML_NODE_MISMATCH = 0x1e2; /** * Rendered content created by the helper class diff --git a/inc/classes/main/helper/images/.htaccess b/inc/classes/main/helper/images/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/inc/classes/main/helper/images/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/images/class_ImageHelper.php b/inc/classes/main/helper/images/class_ImageHelper.php deleted file mode 100644 index 84081a1..0000000 --- a/inc/classes/main/helper/images/class_ImageHelper.php +++ /dev/null @@ -1,364 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageHelper extends BaseHelper implements HelpableTemplate { - /** - * The image type - */ - private $imageType = "png"; - - /** - * The image name - */ - private $imageName = ""; - - /** - * Width of the image in pixel - */ - private $width = 0; - - /** - * Height of the image in pixel - */ - private $height = 0; - - /** - * Array for background color values - */ - private $backgroundColor = array( - 'red' => 0, - 'green' => 0, - 'blue' => 0 - ); - - /** - * Array for foreground color values - */ - private $foregroundColor = array( - 'red' => 0, - 'green' => 0, - 'blue' => 0 - ); - - /** - * All image strings - */ - private $imageStrings = array(); - - /** - * Current string name - */ - private $currString = ""; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A image helper class"); - } - - /** - * Creates the helper class - * - * @param $templateInstance An instance of a template engine - * @param $imageType Type of the image - * @return $helperInstance A preparedf instance of this class - */ - public final static function createImageHelper (CompileableTemplate $templateInstance, $imageType) { - // Get new instance - $helperInstance = new ImageHelper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Set image type (blindly) - $helperInstance->setImageType($imageType); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Setter for image type - * - * @param $imageType Type of the image - * @return void - */ - protected final function setImageType ($imageType) { - $this->imageType = (string) $imageType; - } - - /** - * Getter for image name - * - * @return $imageType Type of the image - */ - public final function getImageType () { - return $this->imageType; - } - - /** - * Setter for base image - * - * @param $baseImage A base image template - * @return void - */ - public final function setBaseImage ($baseImage) { - $this->baseImage = (string) $baseImage; - } - - /** - * Getter for base image - * - * @return $baseImage A base image template - */ - public final function getBaseImage () { - return $this->baseImage; - } - - /** - * Setter for image name - * - * @param $imageName Name of the image - * @return void - */ - public final function setImageName ($imageName) { - $this->imageName = (string) $imageName; - } - - /** - * Getter for image name - * - * @return $imageName Name of the image - */ - protected final function getImageName () { - return $this->imageName; - } - - /** - * Setter for image width - * - * @param $width Width of the image - * @return void - */ - public final function setWidth ($width) { - $this->width = (int) $width; - } - - /** - * Getter for image width - * - * @return $width Width of the image - */ - public final function getWidth () { - return $this->width; - } - - /** - * Setter for image height - * - * @param $height Height of the image - * @return void - */ - public final function setHeight ($height) { - $this->height = (int) $height; - } - - /** - * Getter for image height - * - * @return $height Height of the image - */ - public final function getHeight () { - return $this->height; - } - - /** - * Setter for RGB of background color - * - * @param $red Color value for red - * @param $green Color value for green - * @param $blue Color value for blue - * @return void - */ - public final function setBackgroundColorRedGreenBlue ($red, $green, $blue) { - $this->backgroundColor['red'] = (int) $red; - $this->backgroundColor['green'] = (int) $green; - $this->backgroundColor['blue'] = (int) $blue; - } - - /** - * Setter for RGB of foreground color - * - * @param $red Color value for red - * @param $green Color value for green - * @param $blue Color value for blue - * @return void - */ - public final function setForegroundColorRedGreenBlue ($red, $green, $blue) { - $this->foregroundColor['red'] = (int) $red; - $this->foregroundColor['green'] = (int) $green; - $this->foregroundColor['blue'] = (int) $blue; - } - - /** - * Adds an image string to the buffer by the given string name - * - * @param $stringName String name (identifier) - */ - public function addTextLine ($stringName) { - // Create the image string - $this->imageStrings[$stringName] = array( - 'x' => "", - 'y' => "", - 'size' => "", - 'string' => "" - ); - - // Set current string name - $this->currString = $stringName; - } - - /** - * Setter for image message string - * - * @param $imageString A message to display in the image - * @return void - */ - public final function setImageString ($imageString) { - $this->imageStrings[$this->currString]['string'] = (string) $imageString; - } - - /** - * Getter for image message string - * - * @return $imageString A message to display in the image - */ - public final function getImageString () { - return $this->imageStrings[$this->currString]['string']; - } - - /** - * Setter for X/Y coordinates for strings - * - * @param $x X coordinate - * @param $y Y coordinate - * @return void - */ - public final function setCoord ($x, $y) { - $this->imageStrings[$this->currString]['x'] = (int) $x; - $this->imageStrings[$this->currString]['y'] = (int) $y; - } - - /** - * Getter for X coordinate - * - * @return $x X coordinate - */ - public final function getX () { - return $this->imageStrings[$this->currString]['x']; - } - - /** - * Getter for Y coordinate - * - * @return $y Y coordinate - */ - public final function getY () { - return $this->imageStrings[$this->currString]['y']; - } - - /** - * Setter for font size - * - * @param $fontSize Font size for strings - * @return void - */ - public final function setFontSize ($fontSize) { - $this->imageStrings[$this->currString]['size'] = (int) $fontSize; - } - - /** - * Getter for font size - * - * @return $fontSize Font size for strings - */ - public final function getFontSize () { - return $this->imageStrings[$this->currString]['size']; - } - - /** - * Flushs the content out - * - * @return void - */ - public function flushContent () { - // Get a template instance - $templateInstance = $this->getTemplateInstance(); - - // Get the base image - $templateInstance->loadCodeTemplate($this->getBaseImage()); - - // Assign all the image values with the template - $templateInstance->assignVariable("image_name" , $this->getImageName()); - $templateInstance->assignVariable("image_type" , $this->getImageType()); - $templateInstance->assignVariable("image_width" , $this->getWidth()); - $templateInstance->assignVariable("image_height" , $this->getHeight()); - $templateInstance->assignVariable("image_bg_red" , $this->backgroundColor['red']); - $templateInstance->assignVariable("image_bg_green", $this->backgroundColor['green']); - $templateInstance->assignVariable("image_bg_blue" , $this->backgroundColor['blue']); - $templateInstance->assignVariable("image_fg_red" , $this->foregroundColor['red']); - $templateInstance->assignVariable("image_fg_green", $this->foregroundColor['green']); - $templateInstance->assignVariable("image_fg_blue" , $this->foregroundColor['blue']); - - // Add all strings - foreach ($this->imageStrings as $id=>$imageString) { - // Set current string id - $this->currString = $id; - - // Set variable group - $templateInstance->setVariableGroup($id); - - // Add group variables - $templateInstance->addGroupVariable("image_x" , $this->getX()); - $templateInstance->addGroupVariable("image_y" , $this->getY()); - $templateInstance->addGroupVariable("image_size" , $this->getFontSize()); - $templateInstance->addGroupVariable("image_string", $this->getImageString()); - } // END - foreach - - // Get the raw content - $imageContent = $templateInstance->getRawTemplateData(); - - // Transfer all to the template engine - $templateInstance->renderImageContent($imageContent); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php index 9a668d1..603f70b 100644 --- a/inc/classes/main/helper/web/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/class_WebFormHelper.php @@ -64,10 +64,10 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate { private $formEnabled = true; // Class Constants - const EXCEPTION_FORM_NAME_INVALID = 0x300; - const EXCEPTION_CLOSED_FORM = 0x301; - const EXCEPTION_OPENED_FORM = 0x302; - const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x303; + const EXCEPTION_FORM_NAME_INVALID = 0x120; + const EXCEPTION_CLOSED_FORM = 0x121; + const EXCEPTION_OPENED_FORM = 0x122; + const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123; /** * Protected constructor diff --git a/inc/classes/main/resolver/class_BaseResolver.php b/inc/classes/main/resolver/class_BaseResolver.php index 539a425..dbe3c8f 100644 --- a/inc/classes/main/resolver/class_BaseResolver.php +++ b/inc/classes/main/resolver/class_BaseResolver.php @@ -28,9 +28,9 @@ class BaseResolver extends BaseFrameworkSystem { private $className = ""; // Exception constants - const EXCEPTION_INVALID_COMMAND = 0xd00; - const EXCEPTION_INVALID_CONTROLLER = 0xd01; - const EXCEPTION_INVALID_ACTION = 0xd02; + const EXCEPTION_INVALID_COMMAND = 0x1d0; + const EXCEPTION_INVALID_CONTROLLER = 0x1d1; + const EXCEPTION_INVALID_ACTION = 0x1d2; /** * Protected constructor diff --git a/inc/classes/main/result/class_DatabaseResult.php b/inc/classes/main/result/class_DatabaseResult.php index 08bf403..09e8fc0 100644 --- a/inc/classes/main/result/class_DatabaseResult.php +++ b/inc/classes/main/result/class_DatabaseResult.php @@ -23,8 +23,8 @@ */ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, UpdateableResult, SeekableIterator { // Exception constants - const EXCEPTION_INVALID_DATABASE_RESULT = 0xc00; - const EXCEPTION_RESULT_UPDATE_FAILED = 0xc01; + const EXCEPTION_INVALID_DATABASE_RESULT = 0x1c0; + const EXCEPTION_RESULT_UPDATE_FAILED = 0x1c1; /** * Current position in array diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index bdeec74..e0983b8 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -122,9 +122,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem { private $varGroups = array(); // Exception codes for the template engine - const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x200; - const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x201; - const EXCEPTION_INVALID_VIEW_HELPER = 0x202; + const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x110; + const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111; + const EXCEPTION_INVALID_VIEW_HELPER = 0x112; /** * Protected constructor diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php index c2542d8..c4d30e9 100644 --- a/inc/classes/main/template/image/class_ImageTemplateEngine.php +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -464,7 +464,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl */ public function getImageCacheFqfn () { // Get the FQFN ready - $fqfn = $this->getBasePath()."_cache/" . md5($this->imageInstance->getImageName()) . "." . $this->imageInstance->getImageType(); + $fqfn = $this->getBasePath()."_cache/" . md5($this->imageInstance->getImageName().":".$this->__toString().":".$this->imageInstance->__toString()) . "." . $this->imageInstance->getImageType(); // Return it return $fqfn; diff --git a/inc/classes/main/user/class_Guest.php b/inc/classes/main/user/class_Guest.php index fa9a50d..73ecb5a 100644 --- a/inc/classes/main/user/class_Guest.php +++ b/inc/classes/main/user/class_Guest.php @@ -38,9 +38,9 @@ class Guest extends BaseFrameworkSystem implements ManageableGuest, Registerable private $email = ""; // Exceptions - const EXCEPTION_USERNAME_NOT_FOUND = 0x700; - const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x701; - const EXCEPTION_USER_PASS_MISMATCH = 0x702; + const EXCEPTION_USERNAME_NOT_FOUND = 0x170; + const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171; + const EXCEPTION_USER_PASS_MISMATCH = 0x172; /** * Protected constructor diff --git a/inc/classes/main/user/class_User.php b/inc/classes/main/user/class_User.php index 0e998a0..5f4ebb8 100644 --- a/inc/classes/main/user/class_User.php +++ b/inc/classes/main/user/class_User.php @@ -38,9 +38,9 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable { private $email = ""; // Exceptions - const EXCEPTION_USERNAME_NOT_FOUND = 0x600; - const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x601; - const EXCEPTION_USER_PASS_MISMATCH = 0x602; + const EXCEPTION_USERNAME_NOT_FOUND = 0x150; + const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151; + const EXCEPTION_USER_PASS_MISMATCH = 0x152; /** * Protected constructor diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 32453ab..6d3b99f 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -39,8 +39,8 @@ class FrameworkConfiguration implements Registerable { private static $cfgInstance = null; // Some constants for the configuration system - const EXCEPTION_CONFIG_ENTRY_IS_EMPTY = 0x400; - const EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND = 0x401; + const EXCEPTION_CONFIG_ENTRY_IS_EMPTY = 0x130; + const EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND = 0x131; /** * Protected constructor