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
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
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
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
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
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
// 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);
private $authMethod = "";
// Exception constants
- const EXCEPTION_INVALID_USER_INSTANCE = 0x900;
+ const EXCEPTION_INVALID_USER_INSTANCE = 0x190;
/**
* Protected constructor
--- /dev/null
+Deny from all
--- /dev/null
+<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>
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
/**
* 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);
* @return void
*/
public function __construct ($message, $code) {
+ die($message);
// Call parent constructor
parent::__construct($message, $code);
}
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
*
* @return $cfgInstance Configuration instance
*/
- protected final function getConfigInstance () {
+ public final function getConfigInstance () {
$cfgInstance = Registry::getRegistry()->getInstance('config');
return $cfgInstance;
}
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
* 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
*/
*/
abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontendInterface {
// Constants for exceptions
- const EXCEPTION_SQL_QUERY = 0x500;
+ const EXCEPTION_SQL_QUERY = 0x140;
/**
* The limiter instance
private $cacheInstance = null;
// Constants for exceptions
- const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x700;
+ const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x160;
// Constants for database columns
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";
*/
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
*/
class BaseFilter extends BaseFrameworkSystem {
// Exception constants
- const EXCEPTION_FILTER_CHAIN_ABORTED = 0xa00;
+ const EXCEPTION_FILTER_CHAIN_ABORTED = 0x1a0;
/**
* Protected constructor
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
}
/**
- * 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;
}
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
*/
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
+++ /dev/null
-Deny from all
+++ /dev/null
-<?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]
-?>
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
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
*/
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
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
*/
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;
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
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
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