]> git.mxchange.org Git - shipsimu.git/commitdiff
CAPTCHA support basicly finished (weak CAPTCHA!)
authorRoland Häder <roland@mxchange.org>
Tue, 24 Jun 2008 20:52:50 +0000 (20:52 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 24 Jun 2008 20:52:50 +0000 (20:52 +0000)
38 files changed:
.gitattributes
application/ship-simu/config.php
application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php
application/ship-simu/templates/images/_cache/.htaccess [new file with mode: 0644]
application/ship-simu/templates/images/de/image/base_code.itp [new file with mode: 0644]
application/ship-simu/templates/images/de/image/code_captcha.itp [new file with mode: 0644]
inc/classes/exceptions/crypto/.htaccess [new file with mode: 0644]
inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php [new file with mode: 0644]
inc/classes/exceptions/crypto/class_EncryptMissingException.php [new file with mode: 0644]
inc/classes/exceptions/io/class_FileNotFoundException.php
inc/classes/exceptions/main/class_FatalErrorException.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/image/.htaccess [new file with mode: 0644]
inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php [new file with mode: 0644]
inc/classes/main/controller/captcha/.htaccess [new file with mode: 0644]
inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php [new file with mode: 0644]
inc/classes/main/crypto/class_CryptoHelper.php
inc/classes/main/database/class_BaseDatabaseFrontend.php
inc/classes/main/database/wrapper/class_NewsDatabaseWrapper.php
inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php
inc/classes/main/filter/auth/class_UserAuthFilter.php
inc/classes/main/filter/class_BaseFilter.php
inc/classes/main/filter/crypto/.htaccess [new file with mode: 0644]
inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php [new file with mode: 0644]
inc/classes/main/helper/captcha/class_BaseCaptcha.php
inc/classes/main/helper/captcha/images/.htaccess [new file with mode: 0644]
inc/classes/main/helper/captcha/images/class_ImageHelper.php [new file with mode: 0644]
inc/classes/main/helper/class_BaseHelper.php
inc/classes/main/helper/images/.htaccess [deleted file]
inc/classes/main/helper/images/class_ImageHelper.php [deleted file]
inc/classes/main/helper/web/class_WebFormHelper.php
inc/classes/main/resolver/class_BaseResolver.php
inc/classes/main/result/class_DatabaseResult.php
inc/classes/main/template/class_BaseTemplateEngine.php
inc/classes/main/template/image/class_ImageTemplateEngine.php
inc/classes/main/user/class_Guest.php
inc/classes/main/user/class_User.php
inc/config/class_FrameworkConfiguration.php

index 268477a12e30ec0c782ec4d17dac6430fd673419..74a28e0bc79e0ba0d2d32aab7097e0110768d0ec 100644 (file)
@@ -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
index 53dff5c35216497bfc584abe6b94f6a2b560aa94..3a4196595712f28496db863e604736128b16d857 100644 (file)
@@ -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);
 
index a4bebd6589c2ef204f989081a5ed7b0ce21e6ce2..b17acb2ac76d6bf03d6635a1e7f9c0a481450b71 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..ecba6c9
--- /dev/null
@@ -0,0 +1,27 @@
+<image>
+       <type value="{?image_type?}" />
+       <base>
+               <name value="{?image_name?}" />
+       </base>
+       <resolution>
+               <width value="{?image_width?}" />
+               <height value="{?image_height?}" />
+       </resolution>
+       <background-color>
+               <red value="{?image_bg_red?}" />
+               <green value="{?image_bg_green?}" />
+               <blue value="{?image_bg_blue?}" />
+       </background-color>
+       <foreground-color>
+               <red value="{?image_fg_red?}" />
+               <green value="{?image_fg_green?}" />
+               <blue value="{?image_fg_blue?}" />
+       </foreground-color>
+       <image-string value="groupable">
+               <string-name value="{?image_string_name?}" />
+               <x value="{?image_x?}" />
+               <y value="{?image_y?}" />
+               <font-size value="{?image_size?}" />
+               <text value="{?image_string?}" />
+       </image-string>
+</image>
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 (file)
index 0000000..2e28522
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+// Needed in every image template to initialy set the image type
+$helper = ImageHelper::createImageHelper($this, "png");
+$helper->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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..e6ee352
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ * An exception thrown when the decrypted "encrypt" string has an invalid length
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class 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 (file)
index 0000000..2b3f6b4
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * An exception thrown when the "encrypt" string is missing
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class 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]
+?>
index a8ff4499719e519faee01ddc4b45501b0ee38daf..62665447e5553b1119dd82a90e4fe25930302302 100644 (file)
@@ -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 <span id=\"exception_reason\">%s</span> was not found.", $fqfn);
+               $message = sprintf("The requested file <span id=\"exception_reason\">%s</span> was not found.",
+                       $fqfn
+               );
+
+               // Set extra data
+               $this->setExtraData(basename($fqfn));
 
                // Call parent constructor
                parent::__construct($message, $code);
index 320dae73add2ac0b1711f8217c40eaded9849a3c..b7ac3d04a18fefb786e69a695f95b7321eeddfcc 100644 (file)
@@ -30,6 +30,7 @@ class FatalErrorException extends FrameworkException {
         * @return      void
         */
        public function __construct ($message, $code) {
+               die($message);
                // Call parent constructor
                parent::__construct($message, $code);
        }
index b49be0347e958253b368d416ad11b529c1390d95..3c1b5fc9ac8c38e5fd09e5d9629e0d8322c6a599 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..53cd32d
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/**
+ * A command for creating code CAPTCHAs
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class 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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..794b26d
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/**
+ * A controller for a code-based CAPTCHA where the user has to repeat a shown code
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class 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]
+?>
index aab378491f31119b6166e52ca99a700bb0f3ee82..681ec646b8e44210d6e482c6ba253a08c401bb99 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
+       // Exception constants
+       const EXCEPTION_ENCRYPT_MISSING = 0x1f0;
+       const EXCEPTION_ENCRYPT_INVALID = 0x1f1;
+
        /**
         * An instance of this own clas
         */
index 046ae8b192e53f2f4be998543d8e708ee2631aa8..74dedfae467d21bbe47d0b2ff3eb6e0077cba3d9 100644 (file)
@@ -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
index 1b8b6ad5917c164541cf3f63d97acc6200184079..7188be1abd6246819d8f587fbfd5e59f4570797c 100644 (file)
@@ -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
 
index f1caa49379c4c604261fbd39ab84486b1ab3b2cb..97e7344d23573322b3a1bc806091269b78c90441 100644 (file)
@@ -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";
index fc001a32fc55c91ca4fa80d41e4846b5f71be5fd..c346615239a8d0ff20f23caa832a02d2d0d85b58 100644 (file)
@@ -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
index 195d3e1b8bbf9ed60e4e91280a23ff1027e64277..2d314716854122e02271ef028ab05e5cc1b354f3 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..9208cef
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+/**
+ * A filter for checking if the "encrypt" value is set and fine
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class 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]
+?>
index 09b3e911701e33cf5133fff2be9e92ac202734d9..a589548f88542d2b7a91b4298e9f656f59d8ca06 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..48ad6f0
--- /dev/null
@@ -0,0 +1,394 @@
+<?php
+/**
+ * A helper for creating images
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class 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]
+?>
index 2c0c3c8b3a88fcd0302f90a9ad7ef5f978016b61..adb1f0145301e409b01635409bb13bf355516fb2 100644 (file)
@@ -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 (file)
index 3a42882..0000000
+++ /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 (file)
index 84081a1..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-<?php
-/**
- * A helper for creating images
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class 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]
-?>
index 9a668d123d193ac82efb4c1ba485dca028fec194..603f70b79f94825f55791541c044ce8836a12d09 100644 (file)
@@ -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
index 539a42535ed5d155a143d689630dd7f4222380f1..dbe3c8fc088658b025ad98272de16fb9977ee2d4 100644 (file)
@@ -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
index 08bf40355dbaa9a102859f4bc5ca68b575a385d2..09e8fc04c0daedb47cb6f48e6f1e3d5b36e61146 100644 (file)
@@ -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
index bdeec74ac59fe13e35161021e184a4f61460f32f..e0983b8d53ab6f6dea9dadcdca9eb522aea75272 100644 (file)
@@ -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
index c2542d816f991c81de1fa2e336447a9b83c282e0..c4d30e9b25f0473e58b1e6102c6a08364d0e9f87 100644 (file)
@@ -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;
index fa9a50d012e4baffc670daca21e7a830b901a07f..73ecb5aaba096bce76e343372b6e66f36f2ab16f 100644 (file)
@@ -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
index 0e998a0fc5774406c81df8a4a0634b7947ac6d32..5f4ebb8236f10ed609d56b362c64c4923f42daf2 100644 (file)
@@ -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
index 32453ab45cb0a54e4280f4f11a5bef5c43b7f0bb..6d3b99fb9d03187b10c31ecfbf12fbed4ddbf8a7 100644 (file)
@@ -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